diff --git a/.gradle/8.10/checksums/checksums.lock b/.gradle/8.10/checksums/checksums.lock deleted file mode 100644 index 66803cb..0000000 Binary files a/.gradle/8.10/checksums/checksums.lock and /dev/null differ diff --git a/.gradle/8.10/dependencies-accessors/gc.properties b/.gradle/8.10/dependencies-accessors/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/.gradle/8.10/executionHistory/executionHistory.bin b/.gradle/8.10/executionHistory/executionHistory.bin deleted file mode 100644 index 5601952..0000000 Binary files a/.gradle/8.10/executionHistory/executionHistory.bin and /dev/null differ diff --git a/.gradle/8.10/executionHistory/executionHistory.lock b/.gradle/8.10/executionHistory/executionHistory.lock deleted file mode 100644 index 62d1bdb..0000000 Binary files a/.gradle/8.10/executionHistory/executionHistory.lock and /dev/null differ diff --git a/.gradle/8.10/fileChanges/last-build.bin b/.gradle/8.10/fileChanges/last-build.bin deleted file mode 100644 index f76dd23..0000000 Binary files a/.gradle/8.10/fileChanges/last-build.bin and /dev/null differ diff --git a/.gradle/8.10/fileHashes/fileHashes.bin b/.gradle/8.10/fileHashes/fileHashes.bin deleted file mode 100644 index cb892d7..0000000 Binary files a/.gradle/8.10/fileHashes/fileHashes.bin and /dev/null differ diff --git a/.gradle/8.10/fileHashes/fileHashes.lock b/.gradle/8.10/fileHashes/fileHashes.lock deleted file mode 100644 index 4c67ab2..0000000 Binary files a/.gradle/8.10/fileHashes/fileHashes.lock and /dev/null differ diff --git a/.gradle/8.10/gc.properties b/.gradle/8.10/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock index 5c78718..f787e49 100644 Binary files a/.gradle/8.8/checksums/checksums.lock and b/.gradle/8.8/checksums/checksums.lock differ diff --git a/.gradle/8.8/checksums/md5-checksums.bin b/.gradle/8.8/checksums/md5-checksums.bin index 617185d..a1dc2b7 100644 Binary files a/.gradle/8.8/checksums/md5-checksums.bin and b/.gradle/8.8/checksums/md5-checksums.bin differ diff --git a/.gradle/8.8/checksums/sha1-checksums.bin b/.gradle/8.8/checksums/sha1-checksums.bin index 6d31e91..6fdd350 100644 Binary files a/.gradle/8.8/checksums/sha1-checksums.bin and b/.gradle/8.8/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 32685f8..b53b41e 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.bin and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index cbc62da..f712e03 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index fcced11..bfe8f92 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.bin and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index aba5571..f8cb79a 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin index 1d15fc8..3154177 100644 Binary files a/.gradle/8.8/fileHashes/resourceHashesCache.bin and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 559d3bb..bb62ea5 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties index 265572d..40acb26 100644 --- a/.gradle/buildOutputCleanup/cache.properties +++ b/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Thu Apr 17 16:02:04 MST 2025 -gradle.version=8.8 +#Sun May 18 10:19:41 MST 2025 +gradle.version=8.8 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 1c7e95d..35d38a7 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 7729496..760e89a 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 6a4d306..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -raven-bS \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index cb36dcb..b477c12 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,21 +1,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 05eca02..4572dc3 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,17 +1,17 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index b0051c8..1541b48 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index b323707..d40e4e5 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -1,8 +1,10 @@ - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/raven-bS.main.iml b/.idea/modules/raven-bS.main.iml index afc1871..9b82daa 100644 --- a/.idea/modules/raven-bS.main.iml +++ b/.idea/modules/raven-bS.main.iml @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/.idea/modules/raven-bs-alpha.raven-bS.main.iml b/.idea/modules/raven-bs-alpha.raven-bS.main.iml new file mode 100644 index 0000000..9b82daa --- /dev/null +++ b/.idea/modules/raven-bs-alpha.raven-bS.main.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..9661ac7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a631b6b..9af74b9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,617 +1,782 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + { "lastFilter": { "state": "OPEN", "assignee": "itmejd" } -} +} { "selectedUrlAndAccountId": { "url": "https://github.com/feud/raven-bs-alpha.git", "accountId": "5f945698-8953-4408-a413-9e67376194bc" } -} - - +} + + { "associatedIndex": 3 -} - - - - - + + + + + { + "keyToString": { + "Gradle.raven-bs-alpha [:net.fabricmc.devlaunchinjector.Main.main()].executor": "Run", + "Gradle.raven-bs-alpha [build].executor": "Run", + "Gradle.raven-bs-alpha [clean].executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "master", + "kotlin-language-version-configured": "true", + "last_opened_file_path": "C:/Users/jackh/Desktop/raven-bs-alpha-993/raven-bs-alpha", + "project.structure.last.edited": "Facets", + "project.structure.proportion": "0.0", + "project.structure.side.proportion": "0.2", + "settings.editor.selected.configurable": "reference.settingsdialog.project.gradle" } -}]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - false - false - - - - - - - - true - true - false - false - - - - - - - - - - - - - - 1736536952705 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + false + false + + + + + + + + true + true + false + false + + + + + + + + + + + + + + + + + + + + + + 1736536952705 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/src/main/java/keystrokesmod/src/main/java/keystrokesmod/event/ReceivePacketEvent.java + 11 + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 8a2741b..78b5bd6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,156 +1,156 @@ -import org.apache.commons.lang3.SystemUtils - -plugins { - idea - java - id("gg.essential.loom") version "0.10.0.5" - id("dev.architectury.architectury-pack200") version "0.1.3" - id("com.github.johnrengelman.shadow") version "8.1.1" -} - -val baseGroup: String by project -val mcVersion: String by project -val version: String by project -val mixinGroup = "$baseGroup.mixin" -val modid: String by project - -java { - toolchain.languageVersion.set(JavaLanguageVersion.of(8)) -} - -loom { - log4jConfigs.from(file("log4j2.xml")) - launchConfigs { - "client" { - property("mixin.debug", "true") - arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") - } - } - runConfigs { - "client" { - if (SystemUtils.IS_OS_MAC_OSX) { - vmArgs.remove("-XstartOnFirstThread") - } - } - remove(getByName("server")) - } - forge { - pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter()) - mixinConfig("mixins.raven.json") - } - - mixin { - defaultRefmapName.set("mixins.raven.refmap.json") - } -} - -sourceSets.main { - output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory }) -} - -repositories { - mavenCentral() - maven("https://repo.spongepowered.org/maven/") -} - -val shadowImpl: Configuration by configurations.creating { - configurations.implementation.get().extendsFrom(this) -} - -dependencies { - minecraft("com.mojang:minecraft:1.8.9") - mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") - forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") - - shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { - isTransitive = false - exclude(module = "gson") - exclude(module = "guava") - exclude(module = "jarjar") - exclude(module = "commons-codec") - exclude(module = "commons-io") - exclude(module = "launchwrapper") - exclude(module = "asm-commons") - exclude(module = "slf4j-api") - } - annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT") - shadowImpl("org.java-websocket:Java-WebSocket:1.6.0") -} - -tasks.withType(JavaCompile::class) { - options.encoding = "UTF-8" -} - -tasks.withType(org.gradle.jvm.tasks.Jar::class) { - archiveBaseName.set(modid) - manifest.attributes.run { - this["FMLCorePluginContainsFMLMod"] = "true" - this["ForceLoadAsMod"] = "true" - - this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" - this["MixinConfigs"] = "mixins.raven.json" - } -} - -tasks.processResources { - inputs.property("version", project.version) - inputs.property("mcversion", mcVersion) - inputs.property("modid", modid) - inputs.property("basePackage", baseGroup) - - filesMatching(listOf("mcmod.info", "mixins.raven.json")) { - expand(inputs.properties) - } - - rename("accesstransformer.cfg", "META-INF/${modid}_at.cfg") -} - - -val remapJar by tasks.named("remapJar") { - archiveClassifier.set("") - from(tasks.shadowJar) - input.set(tasks.shadowJar.get().archiveFile) -} - -tasks.jar { - archiveClassifier.set("without-deps") - destinationDirectory.set(layout.buildDirectory.dir("intermediates")) -} - -tasks.shadowJar { - destinationDirectory.set(layout.buildDirectory.dir("intermediates")) - archiveClassifier.set("non-obfuscated-with-deps") - configurations = listOf(shadowImpl) - - exclude( - "dummyThing", - "LICENSE.txt", - "META-INF/MUMFREY.RSA", - "META-INF/maven/**", - "org/**/*.html", - "LICENSE.md", - "pack.mcmeta", - "**/module-info.class", - "*.so", - "*.dylib", - "*.dll", - "*.jnilib", - "ibxm/**", - "com/jcraft/**", - "org/lwjgl/**", - "net/java/**", - "META-INF/proguard/**", - "META-INF/versions/**", - "META-INF/com.android.tools/**", - "fabric.mod.json" - ) - - doLast { - configurations.forEach { - println("Copying dependencies into mod: ${it.files}") - } - } - fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name") -} - +import org.apache.commons.lang3.SystemUtils + +plugins { + idea + java + id("gg.essential.loom") version "0.10.0.5" + id("dev.architectury.architectury-pack200") version "0.1.3" + id("com.github.johnrengelman.shadow") version "8.1.1" +} + +val baseGroup: String by project +val mcVersion: String by project +val version: String by project +val mixinGroup = "$baseGroup.mixin" +val modid: String by project + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) +} + +loom { + log4jConfigs.from(file("log4j2.xml")) + launchConfigs { + "client" { + property("mixin.debug", "true") + arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") + } + } + runConfigs { + "client" { + if (SystemUtils.IS_OS_MAC_OSX) { + vmArgs.remove("-XstartOnFirstThread") + } + } + remove(getByName("server")) + } + forge { + pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter()) + mixinConfig("mixins.raven.json") + } + + mixin { + defaultRefmapName.set("mixins.raven.refmap.json") + } +} + +sourceSets.main { + output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory }) +} + +repositories { + mavenCentral() + maven("https://repo.spongepowered.org/maven/") +} + +val shadowImpl: Configuration by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} + +dependencies { + minecraft("com.mojang:minecraft:1.8.9") + mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") + forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + + shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + isTransitive = false + exclude(module = "gson") + exclude(module = "guava") + exclude(module = "jarjar") + exclude(module = "commons-codec") + exclude(module = "commons-io") + exclude(module = "launchwrapper") + exclude(module = "asm-commons") + exclude(module = "slf4j-api") + } + annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT") + shadowImpl("org.java-websocket:Java-WebSocket:1.6.0") +} + +tasks.withType(JavaCompile::class) { + options.encoding = "UTF-8" +} + +tasks.withType(org.gradle.jvm.tasks.Jar::class) { + archiveBaseName.set(modid) + manifest.attributes.run { + this["FMLCorePluginContainsFMLMod"] = "true" + this["ForceLoadAsMod"] = "true" + + this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" + this["MixinConfigs"] = "mixins.raven.json" + } +} + +tasks.processResources { + inputs.property("version", project.version) + inputs.property("mcversion", mcVersion) + inputs.property("modid", modid) + inputs.property("basePackage", baseGroup) + + filesMatching(listOf("mcmod.info", "mixins.raven.json")) { + expand(inputs.properties) + } + + rename("accesstransformer.cfg", "META-INF/${modid}_at.cfg") +} + + +val remapJar by tasks.named("remapJar") { + archiveClassifier.set("") + from(tasks.shadowJar) + input.set(tasks.shadowJar.get().archiveFile) +} + +tasks.jar { + archiveClassifier.set("without-deps") + destinationDirectory.set(layout.buildDirectory.dir("intermediates")) +} + +tasks.shadowJar { + destinationDirectory.set(layout.buildDirectory.dir("intermediates")) + archiveClassifier.set("non-obfuscated-with-deps") + configurations = listOf(shadowImpl) + + exclude( + "dummyThing", + "LICENSE.txt", + "META-INF/MUMFREY.RSA", + "META-INF/maven/**", + "org/**/*.html", + "LICENSE.md", + "pack.mcmeta", + "**/module-info.class", + "*.so", + "*.dylib", + "*.dll", + "*.jnilib", + "ibxm/**", + "com/jcraft/**", + "org/lwjgl/**", + "net/java/**", + "META-INF/proguard/**", + "META-INF/versions/**", + "META-INF/com.android.tools/**", + "fabric.mod.json" + ) + + doLast { + configurations.forEach { + println("Copying dependencies into mod: ${it.files}") + } + } + fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name") +} + tasks.assemble.get().dependsOn(tasks.remapJar) \ No newline at end of file diff --git a/build/classes/java/main/assets/minecraft/shaders/vertex.vsh b/build/classes/java/main/assets/minecraft/shaders/vertex.vsh index 1eb5182..ec33951 100644 --- a/build/classes/java/main/assets/minecraft/shaders/vertex.vsh +++ b/build/classes/java/main/assets/minecraft/shaders/vertex.vsh @@ -1,6 +1,6 @@ -#version 120 - -void main() { - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +#version 120 + +void main() { + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } \ No newline at end of file diff --git a/build/classes/java/main/keystrokesmod/Raven.class b/build/classes/java/main/keystrokesmod/Raven.class index 0ba1e12..ccf7ecf 100644 Binary files a/build/classes/java/main/keystrokesmod/Raven.class and b/build/classes/java/main/keystrokesmod/Raven.class differ diff --git a/build/classes/java/main/keystrokesmod/event/NoEventPacketEvent.class b/build/classes/java/main/keystrokesmod/event/NoEventPacketEvent.class index a0b3b9d..b5d90f4 100644 Binary files a/build/classes/java/main/keystrokesmod/event/NoEventPacketEvent.class and b/build/classes/java/main/keystrokesmod/event/NoEventPacketEvent.class differ diff --git a/build/classes/java/main/keystrokesmod/event/PlayerMoveEvent.class b/build/classes/java/main/keystrokesmod/event/PlayerMoveEvent.class new file mode 100644 index 0000000..6aa22ca Binary files /dev/null and b/build/classes/java/main/keystrokesmod/event/PlayerMoveEvent.class differ diff --git a/build/classes/java/main/keystrokesmod/event/PrePlayerInputEvent.class b/build/classes/java/main/keystrokesmod/event/PrePlayerInputEvent.class index be006b6..7208736 100644 Binary files a/build/classes/java/main/keystrokesmod/event/PrePlayerInputEvent.class and b/build/classes/java/main/keystrokesmod/event/PrePlayerInputEvent.class differ diff --git a/build/classes/java/main/keystrokesmod/event/PrePlayerMovementInputEvent.class b/build/classes/java/main/keystrokesmod/event/PrePlayerMovementInputEvent.class new file mode 100644 index 0000000..1ceb303 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/event/PrePlayerMovementInputEvent.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntity.class b/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntity.class new file mode 100644 index 0000000..eecbda9 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntity.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.class b/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.class index 26bb5c5..89b24d4 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.class and b/build/classes/java/main/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinGameSettings.class b/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinGameSettings.class index 15ed6fa..17ee35b 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinGameSettings.class and b/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinGameSettings.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.class b/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.class index aa55f66..f77367f 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.class and b/build/classes/java/main/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntity.class b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntity.class index b009f4a..d82c81c 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntity.class and b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntity.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.class b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.class index f71cef3..dbaf81c 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.class and b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.class b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.class index 8f55054..f8fcda8 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.class and b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.class differ diff --git a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.class b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.class index a4494d7..71677c0 100644 Binary files a/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.class and b/build/classes/java/main/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.class differ diff --git a/build/classes/java/main/keystrokesmod/module/Module$category.class b/build/classes/java/main/keystrokesmod/module/Module$category.class index 649b104..1211547 100644 Binary files a/build/classes/java/main/keystrokesmod/module/Module$category.class and b/build/classes/java/main/keystrokesmod/module/Module$category.class differ diff --git a/build/classes/java/main/keystrokesmod/module/Module.class b/build/classes/java/main/keystrokesmod/module/Module.class index b0141ba..3811d5d 100644 Binary files a/build/classes/java/main/keystrokesmod/module/Module.class and b/build/classes/java/main/keystrokesmod/module/Module.class differ diff --git a/build/classes/java/main/keystrokesmod/module/ModuleManager.class b/build/classes/java/main/keystrokesmod/module/ModuleManager.class index 0560d57..bbd38a4 100644 Binary files a/build/classes/java/main/keystrokesmod/module/ModuleManager.class and b/build/classes/java/main/keystrokesmod/module/ModuleManager.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/AimAssist.class b/build/classes/java/main/keystrokesmod/module/impl/combat/AimAssist.class index 52b7a9e..7af9d5b 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/AimAssist.class and b/build/classes/java/main/keystrokesmod/module/impl/combat/AimAssist.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/AntiKnockback.class b/build/classes/java/main/keystrokesmod/module/impl/combat/AntiKnockback.class deleted file mode 100644 index 200a94f..0000000 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/AntiKnockback.class and /dev/null differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/AutoClicker.class b/build/classes/java/main/keystrokesmod/module/impl/combat/AutoClicker.class index 3ac0ed8..3f7f3d5 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/AutoClicker.class and b/build/classes/java/main/keystrokesmod/module/impl/combat/AutoClicker.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/JumpReset.class b/build/classes/java/main/keystrokesmod/module/impl/combat/JumpReset.class deleted file mode 100644 index ec7ba13..0000000 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/JumpReset.class and /dev/null differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/KillAura.class b/build/classes/java/main/keystrokesmod/module/impl/combat/KillAura.class index a966733..f73ec09 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/KillAura.class and b/build/classes/java/main/keystrokesmod/module/impl/combat/KillAura.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/LagRange.class b/build/classes/java/main/keystrokesmod/module/impl/combat/LagRange.class new file mode 100644 index 0000000..8e7188a Binary files /dev/null and b/build/classes/java/main/keystrokesmod/module/impl/combat/LagRange.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/Velocity.class b/build/classes/java/main/keystrokesmod/module/impl/combat/Velocity.class index 9a52bc4..9a7d1db 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/Velocity.class and b/build/classes/java/main/keystrokesmod/module/impl/combat/Velocity.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/combat/WTap.class b/build/classes/java/main/keystrokesmod/module/impl/combat/WTap.class index 720db94..77c4fd9 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/combat/WTap.class and b/build/classes/java/main/keystrokesmod/module/impl/combat/WTap.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/minigames/BedWars.class b/build/classes/java/main/keystrokesmod/module/impl/minigames/BedWars.class index 8647d52..278b060 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/minigames/BedWars.class and b/build/classes/java/main/keystrokesmod/module/impl/minigames/BedWars.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/movement/Bhop.class b/build/classes/java/main/keystrokesmod/module/impl/movement/Bhop.class index f84e532..c8464e1 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/movement/Bhop.class and b/build/classes/java/main/keystrokesmod/module/impl/movement/Bhop.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/movement/LongJump.class b/build/classes/java/main/keystrokesmod/module/impl/movement/LongJump.class index f6eae8c..85214ab 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/movement/LongJump.class and b/build/classes/java/main/keystrokesmod/module/impl/movement/LongJump.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/movement/NoSlow.class b/build/classes/java/main/keystrokesmod/module/impl/movement/NoSlow.class index 5aa47cb..652be02 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/movement/NoSlow.class and b/build/classes/java/main/keystrokesmod/module/impl/movement/NoSlow.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/other/Spammer.class b/build/classes/java/main/keystrokesmod/module/impl/other/Spammer.class index 546cd0f..8d9c5aa 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/other/Spammer.class and b/build/classes/java/main/keystrokesmod/module/impl/other/Spammer.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/other/Timers.class b/build/classes/java/main/keystrokesmod/module/impl/other/Timers.class new file mode 100644 index 0000000..c337318 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/module/impl/other/Timers.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/AntiAFK.class b/build/classes/java/main/keystrokesmod/module/impl/player/AntiAFK.class index fb1a35c..79a5d0e 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/AntiAFK.class and b/build/classes/java/main/keystrokesmod/module/impl/player/AntiAFK.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/AntiFireball.class b/build/classes/java/main/keystrokesmod/module/impl/player/AntiFireball.class index d0520f4..04824d5 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/AntiFireball.class and b/build/classes/java/main/keystrokesmod/module/impl/player/AntiFireball.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/AntiVoid.class b/build/classes/java/main/keystrokesmod/module/impl/player/AntiVoid.class index d395217..e6552f6 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/AntiVoid.class and b/build/classes/java/main/keystrokesmod/module/impl/player/AntiVoid.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/AutoPlace.class b/build/classes/java/main/keystrokesmod/module/impl/player/AutoPlace.class index 05398a3..4802ad5 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/AutoPlace.class and b/build/classes/java/main/keystrokesmod/module/impl/player/AutoPlace.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/AutoSwap.class b/build/classes/java/main/keystrokesmod/module/impl/player/AutoSwap.class index 909f6c7..b573d20 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/AutoSwap.class and b/build/classes/java/main/keystrokesmod/module/impl/player/AutoSwap.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/BedAura.class b/build/classes/java/main/keystrokesmod/module/impl/player/BedAura.class index 884ec9f..34ff1fe 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/BedAura.class and b/build/classes/java/main/keystrokesmod/module/impl/player/BedAura.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Blink.class b/build/classes/java/main/keystrokesmod/module/impl/player/Blink.class index 6f286f2..cc95e08 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Blink.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Blink.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Disabler.class b/build/classes/java/main/keystrokesmod/module/impl/player/Disabler.class index 97330a0..7a7ca7f 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Disabler.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Disabler.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/NoFall.class b/build/classes/java/main/keystrokesmod/module/impl/player/NoFall.class index 996a184..9e22bb7 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/NoFall.class and b/build/classes/java/main/keystrokesmod/module/impl/player/NoFall.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Safewalk.class b/build/classes/java/main/keystrokesmod/module/impl/player/Safewalk.class index f66aae9..3379923 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Safewalk.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Safewalk.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$1.class b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$1.class index 8a90db0..d27cdc2 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$1.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$1.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$PlaceData.class b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$PlaceData.class index c403f94..c79ad9e 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$PlaceData.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold$PlaceData.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold.class b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold.class index f6d1144..7bc6e6d 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Scaffold.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/player/Tower.class b/build/classes/java/main/keystrokesmod/module/impl/player/Tower.class index e52b78e..043e668 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/player/Tower.class and b/build/classes/java/main/keystrokesmod/module/impl/player/Tower.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/HUD$EditScreen.class b/build/classes/java/main/keystrokesmod/module/impl/render/HUD$EditScreen.class index 1440dad..4fbab52 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/render/HUD$EditScreen.class and b/build/classes/java/main/keystrokesmod/module/impl/render/HUD$EditScreen.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/HUD.class b/build/classes/java/main/keystrokesmod/module/impl/render/HUD.class index 63cbe73..70044cf 100644 Binary files a/build/classes/java/main/keystrokesmod/module/impl/render/HUD.class and b/build/classes/java/main/keystrokesmod/module/impl/render/HUD.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD$EditScreen.class b/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD$EditScreen.class deleted file mode 100644 index d8ee77b..0000000 Binary files a/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD$EditScreen.class and /dev/null differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD.class b/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD.class deleted file mode 100644 index 6e1223a..0000000 Binary files a/build/classes/java/main/keystrokesmod/module/impl/render/TargetHUD.class and /dev/null differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo$EditScreen.class b/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo$EditScreen.class new file mode 100644 index 0000000..26ef4e4 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo$EditScreen.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo.class b/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo.class new file mode 100644 index 0000000..1caa7b7 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/module/impl/render/TargetInfo.class differ diff --git a/build/classes/java/main/keystrokesmod/module/impl/render/Trajectories$1.class b/build/classes/java/main/keystrokesmod/module/impl/render/Trajectories$1.class new file mode 100644 index 0000000..8a3764b Binary files /dev/null and b/build/classes/java/main/keystrokesmod/module/impl/render/Trajectories$1.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$client.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$client.class index bd1177d..2038545 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$client.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$client.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$config.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$config.class index 48f085e..f25ade4 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$config.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$config.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$gl.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$gl.class index d42de03..40716b9 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$gl.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$gl.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$inventory.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$inventory.class index 98dea82..6ed811d 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$inventory.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$inventory.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$keybinds.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$keybinds.class index 0949038..8a699d1 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$keybinds.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$keybinds.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$modules.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$modules.class index b26aa6b..7d85231 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$modules.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$modules.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$EmptyGuiScreen.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$EmptyGuiScreen.class index 59572e5..a89eb6f 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$EmptyGuiScreen.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$EmptyGuiScreen.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$bloom.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$bloom.class index d03f343..db31b2b 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$bloom.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$bloom.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$blur.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$blur.class index bcf6225..09741ad 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$blur.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render$blur.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render.class index ca41e97..da6d879 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$render.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$util.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$util.class index 5d2d771..b652610 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$util.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$util.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$world.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$world.class index 3296858..4f2d69e 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults$world.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults$world.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptDefaults.class b/build/classes/java/main/keystrokesmod/script/ScriptDefaults.class index 433deae..a50dc8a 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptDefaults.class and b/build/classes/java/main/keystrokesmod/script/ScriptDefaults.class differ diff --git a/build/classes/java/main/keystrokesmod/script/ScriptEvents.class b/build/classes/java/main/keystrokesmod/script/ScriptEvents.class index 4ed7510..64c8267 100644 Binary files a/build/classes/java/main/keystrokesmod/script/ScriptEvents.class and b/build/classes/java/main/keystrokesmod/script/ScriptEvents.class differ diff --git a/build/classes/java/main/keystrokesmod/script/model/MovementInput.class b/build/classes/java/main/keystrokesmod/script/model/MovementInput.class new file mode 100644 index 0000000..5b8c5bd Binary files /dev/null and b/build/classes/java/main/keystrokesmod/script/model/MovementInput.class differ diff --git a/build/classes/java/main/keystrokesmod/script/model/SimulatedPlayer.class b/build/classes/java/main/keystrokesmod/script/model/SimulatedPlayer.class new file mode 100644 index 0000000..c713fc0 Binary files /dev/null and b/build/classes/java/main/keystrokesmod/script/model/SimulatedPlayer.class differ diff --git a/build/classes/java/main/keystrokesmod/script/model/Simulation.class b/build/classes/java/main/keystrokesmod/script/model/Simulation.class new file mode 100644 index 0000000..67c934e Binary files /dev/null and b/build/classes/java/main/keystrokesmod/script/model/Simulation.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/BlinkHandler.class b/build/classes/java/main/keystrokesmod/utility/BlinkHandler.class new file mode 100644 index 0000000..7bd8e1f Binary files /dev/null and b/build/classes/java/main/keystrokesmod/utility/BlinkHandler.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/BlockUtils.class b/build/classes/java/main/keystrokesmod/utility/BlockUtils.class index 56f1358..e8ee385 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/BlockUtils.class and b/build/classes/java/main/keystrokesmod/utility/BlockUtils.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/ModuleUtils.class b/build/classes/java/main/keystrokesmod/utility/ModuleUtils.class index 2f79814..70fb828 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/ModuleUtils.class and b/build/classes/java/main/keystrokesmod/utility/ModuleUtils.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/ReflectionUtils.class b/build/classes/java/main/keystrokesmod/utility/ReflectionUtils.class index a3ec7e5..379ce74 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/ReflectionUtils.class and b/build/classes/java/main/keystrokesmod/utility/ReflectionUtils.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/RotationUtils.class b/build/classes/java/main/keystrokesmod/utility/RotationUtils.class index 5ff783f..faeeea8 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/RotationUtils.class and b/build/classes/java/main/keystrokesmod/utility/RotationUtils.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/Utils$keybinds.class b/build/classes/java/main/keystrokesmod/utility/Utils$keybinds.class index 721b1ab..83f6cd7 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/Utils$keybinds.class and b/build/classes/java/main/keystrokesmod/utility/Utils$keybinds.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/Utils.class b/build/classes/java/main/keystrokesmod/utility/Utils.class index 7a17a39..701fa26 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/Utils.class and b/build/classes/java/main/keystrokesmod/utility/Utils.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/command/impl/Q.class b/build/classes/java/main/keystrokesmod/utility/command/impl/Q.class index 8cfb706..e8aee7d 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/command/impl/Q.class and b/build/classes/java/main/keystrokesmod/utility/command/impl/Q.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/command/impl/SpammerUtil.class b/build/classes/java/main/keystrokesmod/utility/command/impl/SpammerUtil.class index 52e1b67..c54aa21 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/command/impl/SpammerUtil.class and b/build/classes/java/main/keystrokesmod/utility/command/impl/SpammerUtil.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/command/impl/Status.class b/build/classes/java/main/keystrokesmod/utility/command/impl/Status.class index 2032bbc..f885766 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/command/impl/Status.class and b/build/classes/java/main/keystrokesmod/utility/command/impl/Status.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/command/impl/StopSpammer.class b/build/classes/java/main/keystrokesmod/utility/command/impl/StopSpammer.class index f061605..058d3d8 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/command/impl/StopSpammer.class and b/build/classes/java/main/keystrokesmod/utility/command/impl/StopSpammer.class differ diff --git a/build/classes/java/main/keystrokesmod/utility/profile/ProfileManager.class b/build/classes/java/main/keystrokesmod/utility/profile/ProfileManager.class index 436a564..30fccac 100644 Binary files a/build/classes/java/main/keystrokesmod/utility/profile/ProfileManager.class and b/build/classes/java/main/keystrokesmod/utility/profile/ProfileManager.class differ diff --git a/build/classes/java/main/mixins.raven.json b/build/classes/java/main/mixins.raven.json index 1b6b046..0488932 100644 --- a/build/classes/java/main/mixins.raven.json +++ b/build/classes/java/main/mixins.raven.json @@ -44,6 +44,7 @@ "accessor.IAccessorGuiScreen", "accessor.IAccessorS14PacketEntity", "accessor.IAccessorRenderManager", - "accessor.IAccessorNetworkManager" + "accessor.IAccessorNetworkManager", + "accessor.IAccessorEntity" ] } \ No newline at end of file diff --git a/build/classes/java/main/mixins.raven.refmap.json b/build/classes/java/main/mixins.raven.refmap.json index 4c43d16..17ba840 100644 --- a/build/classes/java/main/mixins.raven.refmap.json +++ b/build/classes/java/main/mixins.raven.refmap.json @@ -109,7 +109,9 @@ }, "keystrokesmod/mixin/impl/entity/MixinEntityLivingBase": { "updateDistance": "Lnet/minecraft/entity/EntityLivingBase;func_110146_f(FF)F", - "isPotionActive(Lnet/minecraft/potion/Potion;)Z": "Lnet/minecraft/entity/EntityLivingBase;func_70644_a(Lnet/minecraft/potion/Potion;)Z" + "isPotionActive(Lnet/minecraft/potion/Potion;)Z": "Lnet/minecraft/entity/EntityLivingBase;func_70644_a(Lnet/minecraft/potion/Potion;)Z", + "onLivingUpdate": "Lnet/minecraft/entity/EntityLivingBase;func_70636_d()V", + "Lnet/minecraft/entity/EntityLivingBase;moveEntityWithHeading(FF)V": "Lnet/minecraft/entity/EntityLivingBase;func_70612_e(FF)V" }, "keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer": { "useShader": "field_175083_ad:Z", @@ -129,6 +131,11 @@ "sendAutocompleteRequest": "Lnet/minecraft/client/gui/GuiChat;func_146405_a(Ljava/lang/String;Ljava/lang/String;)V", "keyTyped": "Lnet/minecraft/client/gui/GuiChat;func_73869_a(CI)V" }, + "keystrokesmod/mixin/impl/accessor/IAccessorEntity": { + "isInWeb": "field_70134_J:Z", + "nextStepDistance": "field_70150_b:I", + "fire": "field_70151_c:I" + }, "keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP": { "lastReportedPitch": "field_175165_bM:F", "lastReportedPosY": "field_175166_bJ:D", @@ -278,7 +285,9 @@ }, "keystrokesmod/mixin/impl/entity/MixinEntityLivingBase": { "updateDistance": "Lnet/minecraft/entity/EntityLivingBase;func_110146_f(FF)F", - "isPotionActive(Lnet/minecraft/potion/Potion;)Z": "Lnet/minecraft/entity/EntityLivingBase;func_70644_a(Lnet/minecraft/potion/Potion;)Z" + "isPotionActive(Lnet/minecraft/potion/Potion;)Z": "Lnet/minecraft/entity/EntityLivingBase;func_70644_a(Lnet/minecraft/potion/Potion;)Z", + "onLivingUpdate": "Lnet/minecraft/entity/EntityLivingBase;func_70636_d()V", + "Lnet/minecraft/entity/EntityLivingBase;moveEntityWithHeading(FF)V": "Lnet/minecraft/entity/EntityLivingBase;func_70612_e(FF)V" }, "keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer": { "useShader": "field_175083_ad:Z", @@ -298,6 +307,11 @@ "sendAutocompleteRequest": "Lnet/minecraft/client/gui/GuiChat;func_146405_a(Ljava/lang/String;Ljava/lang/String;)V", "keyTyped": "Lnet/minecraft/client/gui/GuiChat;func_73869_a(CI)V" }, + "keystrokesmod/mixin/impl/accessor/IAccessorEntity": { + "isInWeb": "field_70134_J:Z", + "nextStepDistance": "field_70150_b:I", + "fire": "field_70151_c:I" + }, "keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP": { "lastReportedPitch": "field_175165_bM:F", "lastReportedPosY": "field_175166_bJ:D", diff --git a/build/intermediates/raven-bS-100-beta-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-100-beta-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..bb3dccb Binary files /dev/null and b/build/intermediates/raven-bS-100-beta-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-100-beta-without-deps.jar b/build/intermediates/raven-bS-100-beta-without-deps.jar new file mode 100644 index 0000000..bcd1f10 Binary files /dev/null and b/build/intermediates/raven-bS-100-beta-without-deps.jar differ diff --git a/build/intermediates/raven-bS-13-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-99-beta-non-obfuscated-with-deps.jar similarity index 83% rename from build/intermediates/raven-bS-13-non-obfuscated-with-deps.jar rename to build/intermediates/raven-bS-99-beta-non-obfuscated-with-deps.jar index 4601dc6..fdfe85f 100644 Binary files a/build/intermediates/raven-bS-13-non-obfuscated-with-deps.jar and b/build/intermediates/raven-bS-99-beta-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-13-without-deps.jar b/build/intermediates/raven-bS-99-beta-without-deps.jar similarity index 66% rename from build/intermediates/raven-bS-13-without-deps.jar rename to build/intermediates/raven-bS-99-beta-without-deps.jar index 9d2583a..fc776cd 100644 Binary files a/build/intermediates/raven-bS-13-without-deps.jar and b/build/intermediates/raven-bS-99-beta-without-deps.jar differ diff --git a/build/intermediates/raven-bS-99-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-99-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..b59f2a2 Binary files /dev/null and b/build/intermediates/raven-bS-99-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-99-without-deps.jar b/build/intermediates/raven-bS-99-without-deps.jar new file mode 100644 index 0000000..33e8c13 Binary files /dev/null and b/build/intermediates/raven-bS-99-without-deps.jar differ diff --git a/build/intermediates/raven-bS-992-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-992-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..143f2e0 Binary files /dev/null and b/build/intermediates/raven-bS-992-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-992-without-deps.jar b/build/intermediates/raven-bS-992-without-deps.jar new file mode 100644 index 0000000..391f5b8 Binary files /dev/null and b/build/intermediates/raven-bS-992-without-deps.jar differ diff --git a/build/intermediates/raven-bS-993-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-993-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..38cde2a Binary files /dev/null and b/build/intermediates/raven-bS-993-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-993-without-deps.jar b/build/intermediates/raven-bS-993-without-deps.jar new file mode 100644 index 0000000..2368446 Binary files /dev/null and b/build/intermediates/raven-bS-993-without-deps.jar differ diff --git a/build/intermediates/raven-bS-994-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-994-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..f627903 Binary files /dev/null and b/build/intermediates/raven-bS-994-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-994-without-deps.jar b/build/intermediates/raven-bS-994-without-deps.jar new file mode 100644 index 0000000..48c7c1f Binary files /dev/null and b/build/intermediates/raven-bS-994-without-deps.jar differ diff --git a/build/intermediates/raven-bS-995-non-obfuscated-with-deps.jar b/build/intermediates/raven-bS-995-non-obfuscated-with-deps.jar new file mode 100644 index 0000000..2fc7faa Binary files /dev/null and b/build/intermediates/raven-bS-995-non-obfuscated-with-deps.jar differ diff --git a/build/intermediates/raven-bS-995-without-deps.jar b/build/intermediates/raven-bS-995-without-deps.jar new file mode 100644 index 0000000..e5440d8 Binary files /dev/null and b/build/intermediates/raven-bS-995-without-deps.jar differ diff --git a/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.0.tiny b/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.0.tiny index 61ffb59..6f50c38 100644 --- a/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.0.tiny +++ b/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.0.tiny @@ -1,64 +1,64 @@ -v1 named intermediary -FIELD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions Lnet/minecraft/client/settings/GameSettings; gameSettings field_78903_e -FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionX field_70159_w -FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionZ field_70179_y -FIELD keystrokesmod/mixin/impl/entity/MixinEntity F rotationYaw field_70177_z -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F rotationYawHead field_70759_as -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F renderYawOffset field_70761_aq -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F swingProgress field_70733_aJ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintingTicksLeft field_71157_e -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintToggleTimer field_71156_d -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F prevTimeInPortal field_71080_cy -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F timeInPortal field_71086_bY -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/Minecraft; mc field_71159_c -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/util/MovementInput; movementInput field_71158_b -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I horseJumpPowerCounter field_110320_a -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F horseJumpPower field_110321_bQ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSprintState field_175171_bO -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/network/NetHandlerPlayClient; sendQueue field_71174_a -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSneakState field_175170_bN -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosX field_175172_bI -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosY field_175166_bJ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosZ field_175167_bK -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedYaw field_175164_bL -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedPitch field_175165_bM -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I positionUpdateTicks field_175168_bP -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Lnet/minecraft/client/gui/GuiTextField; inputField field_146415_a -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Ljava/util/List; foundPlayerNames field_146412_t -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Z waitingOnAutocomplete field_146414_r -FIELD keystrokesmod/mixin/impl/render/MixinGuiScreen Lnet/minecraft/client/Minecraft; mc field_146297_k -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer Lnet/minecraft/item/ItemStack; itemToRender field_78453_b -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F equippedProgress field_78454_c -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F prevEquippedProgress field_78451_d -FIELD keystrokesmod/mixin/impl/render/MixinLayerCape Lnet/minecraft/client/renderer/entity/RenderPlayer; playerRenderer field_177167_a -FIELD keystrokesmod/mixin/impl/render/MixinRendererLivingEntity Z renderOutlines field_177098_i -FIELD keystrokesmod/mixin/impl/render/MixinRenderGlobal Lnet/minecraft/client/Minecraft; mc field_72777_q -FIELD keystrokesmod/mixin/impl/world/MixinWorld Z isRemote field_72995_K -METHOD keystrokesmod/mixin/impl/client/MixinGameSettings (Lnet/minecraft/client/settings/KeyBinding;)Z isKeyDown func_100015_a -METHOD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions ()V updatePlayerMoveState func_78898_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FFF)V moveFlying func_70060_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FF)Lnet/minecraft/util/Vec3; getVectorForRotation func_174806_f -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect; getActivePotionEffect func_70660_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Z isPotionActive func_70644_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()F getJumpUpwardsMotion func_175134_bD -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()V jump func_70664_aZ -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getHeldItem func_70694_bm -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onCriticalHit func_71009_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onEnchantmentCritical func_71047_c -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;)V triggerAchievement func_71029_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getCurrentEquippedItem func_71045_bC -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()V destroyCurrentEquippedItem func_71028_bD -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;I)V addStat func_71064_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (F)V addExhaustion func_71020_j -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V attackTargetEntityWithCurrentItem func_71059_n -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP (Z)V setSprinting func_70031_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendPlayerAbilities func_71016_p -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isCurrentViewEntity func_175160_A -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isRidingHorse func_110317_t -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendHorseJump func_110318_g -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isSneaking func_70093_af -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onUpdateWalkingPlayer func_175161_p -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onLivingUpdate func_70636_d -METHOD keystrokesmod/mixin/impl/render/MixinGuiChat ([Ljava/lang/String;)V onAutocompleteResponse func_146406_a -METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/util/AxisAlignedBB; getCollisionBoundingBox func_180640_a -METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)V addCollisionBoxesToList func_180638_a +v1 named intermediary +FIELD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions Lnet/minecraft/client/settings/GameSettings; gameSettings field_78903_e +FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionX field_70159_w +FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionZ field_70179_y +FIELD keystrokesmod/mixin/impl/entity/MixinEntity F rotationYaw field_70177_z +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F rotationYawHead field_70759_as +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F renderYawOffset field_70761_aq +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F swingProgress field_70733_aJ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintingTicksLeft field_71157_e +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintToggleTimer field_71156_d +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F prevTimeInPortal field_71080_cy +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F timeInPortal field_71086_bY +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/Minecraft; mc field_71159_c +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/util/MovementInput; movementInput field_71158_b +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I horseJumpPowerCounter field_110320_a +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F horseJumpPower field_110321_bQ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSprintState field_175171_bO +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/network/NetHandlerPlayClient; sendQueue field_71174_a +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSneakState field_175170_bN +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosX field_175172_bI +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosY field_175166_bJ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosZ field_175167_bK +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedYaw field_175164_bL +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedPitch field_175165_bM +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I positionUpdateTicks field_175168_bP +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Lnet/minecraft/client/gui/GuiTextField; inputField field_146415_a +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Ljava/util/List; foundPlayerNames field_146412_t +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Z waitingOnAutocomplete field_146414_r +FIELD keystrokesmod/mixin/impl/render/MixinGuiScreen Lnet/minecraft/client/Minecraft; mc field_146297_k +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer Lnet/minecraft/item/ItemStack; itemToRender field_78453_b +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F equippedProgress field_78454_c +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F prevEquippedProgress field_78451_d +FIELD keystrokesmod/mixin/impl/render/MixinLayerCape Lnet/minecraft/client/renderer/entity/RenderPlayer; playerRenderer field_177167_a +FIELD keystrokesmod/mixin/impl/render/MixinRendererLivingEntity Z renderOutlines field_177098_i +FIELD keystrokesmod/mixin/impl/render/MixinRenderGlobal Lnet/minecraft/client/Minecraft; mc field_72777_q +FIELD keystrokesmod/mixin/impl/world/MixinWorld Z isRemote field_72995_K +METHOD keystrokesmod/mixin/impl/client/MixinGameSettings (Lnet/minecraft/client/settings/KeyBinding;)Z isKeyDown func_100015_a +METHOD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions ()V updatePlayerMoveState func_78898_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FFF)V moveFlying func_70060_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FF)Lnet/minecraft/util/Vec3; getVectorForRotation func_174806_f +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect; getActivePotionEffect func_70660_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Z isPotionActive func_70644_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()F getJumpUpwardsMotion func_175134_bD +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()V jump func_70664_aZ +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getHeldItem func_70694_bm +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onCriticalHit func_71009_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onEnchantmentCritical func_71047_c +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;)V triggerAchievement func_71029_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getCurrentEquippedItem func_71045_bC +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()V destroyCurrentEquippedItem func_71028_bD +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;I)V addStat func_71064_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (F)V addExhaustion func_71020_j +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V attackTargetEntityWithCurrentItem func_71059_n +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP (Z)V setSprinting func_70031_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendPlayerAbilities func_71016_p +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isCurrentViewEntity func_175160_A +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isRidingHorse func_110317_t +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendHorseJump func_110318_g +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isSneaking func_70093_af +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onUpdateWalkingPlayer func_175161_p +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onLivingUpdate func_70636_d +METHOD keystrokesmod/mixin/impl/render/MixinGuiChat ([Ljava/lang/String;)V onAutocompleteResponse func_146406_a +METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/util/AxisAlignedBB; getCollisionBoundingBox func_180640_a +METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)V addCollisionBoxesToList func_180638_a diff --git a/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.1.tiny b/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.1.tiny index 61ffb59..6f50c38 100644 --- a/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.1.tiny +++ b/build/loom-cache/mixin-map-de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9.1.tiny @@ -1,64 +1,64 @@ -v1 named intermediary -FIELD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions Lnet/minecraft/client/settings/GameSettings; gameSettings field_78903_e -FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionX field_70159_w -FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionZ field_70179_y -FIELD keystrokesmod/mixin/impl/entity/MixinEntity F rotationYaw field_70177_z -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F rotationYawHead field_70759_as -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F renderYawOffset field_70761_aq -FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F swingProgress field_70733_aJ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintingTicksLeft field_71157_e -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintToggleTimer field_71156_d -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F prevTimeInPortal field_71080_cy -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F timeInPortal field_71086_bY -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/Minecraft; mc field_71159_c -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/util/MovementInput; movementInput field_71158_b -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I horseJumpPowerCounter field_110320_a -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F horseJumpPower field_110321_bQ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSprintState field_175171_bO -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/network/NetHandlerPlayClient; sendQueue field_71174_a -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSneakState field_175170_bN -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosX field_175172_bI -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosY field_175166_bJ -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosZ field_175167_bK -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedYaw field_175164_bL -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedPitch field_175165_bM -FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I positionUpdateTicks field_175168_bP -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Lnet/minecraft/client/gui/GuiTextField; inputField field_146415_a -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Ljava/util/List; foundPlayerNames field_146412_t -FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Z waitingOnAutocomplete field_146414_r -FIELD keystrokesmod/mixin/impl/render/MixinGuiScreen Lnet/minecraft/client/Minecraft; mc field_146297_k -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer Lnet/minecraft/item/ItemStack; itemToRender field_78453_b -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F equippedProgress field_78454_c -FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F prevEquippedProgress field_78451_d -FIELD keystrokesmod/mixin/impl/render/MixinLayerCape Lnet/minecraft/client/renderer/entity/RenderPlayer; playerRenderer field_177167_a -FIELD keystrokesmod/mixin/impl/render/MixinRendererLivingEntity Z renderOutlines field_177098_i -FIELD keystrokesmod/mixin/impl/render/MixinRenderGlobal Lnet/minecraft/client/Minecraft; mc field_72777_q -FIELD keystrokesmod/mixin/impl/world/MixinWorld Z isRemote field_72995_K -METHOD keystrokesmod/mixin/impl/client/MixinGameSettings (Lnet/minecraft/client/settings/KeyBinding;)Z isKeyDown func_100015_a -METHOD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions ()V updatePlayerMoveState func_78898_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FFF)V moveFlying func_70060_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FF)Lnet/minecraft/util/Vec3; getVectorForRotation func_174806_f -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect; getActivePotionEffect func_70660_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Z isPotionActive func_70644_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()F getJumpUpwardsMotion func_175134_bD -METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()V jump func_70664_aZ -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getHeldItem func_70694_bm -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onCriticalHit func_71009_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onEnchantmentCritical func_71047_c -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;)V triggerAchievement func_71029_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getCurrentEquippedItem func_71045_bC -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()V destroyCurrentEquippedItem func_71028_bD -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;I)V addStat func_71064_a -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (F)V addExhaustion func_71020_j -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V attackTargetEntityWithCurrentItem func_71059_n -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP (Z)V setSprinting func_70031_b -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendPlayerAbilities func_71016_p -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isCurrentViewEntity func_175160_A -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isRidingHorse func_110317_t -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendHorseJump func_110318_g -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isSneaking func_70093_af -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onUpdateWalkingPlayer func_175161_p -METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onLivingUpdate func_70636_d -METHOD keystrokesmod/mixin/impl/render/MixinGuiChat ([Ljava/lang/String;)V onAutocompleteResponse func_146406_a -METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/util/AxisAlignedBB; getCollisionBoundingBox func_180640_a -METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)V addCollisionBoxesToList func_180638_a +v1 named intermediary +FIELD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions Lnet/minecraft/client/settings/GameSettings; gameSettings field_78903_e +FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionX field_70159_w +FIELD keystrokesmod/mixin/impl/entity/MixinEntity D motionZ field_70179_y +FIELD keystrokesmod/mixin/impl/entity/MixinEntity F rotationYaw field_70177_z +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F rotationYawHead field_70759_as +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F renderYawOffset field_70761_aq +FIELD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase F swingProgress field_70733_aJ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintingTicksLeft field_71157_e +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I sprintToggleTimer field_71156_d +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F prevTimeInPortal field_71080_cy +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F timeInPortal field_71086_bY +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/Minecraft; mc field_71159_c +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/util/MovementInput; movementInput field_71158_b +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I horseJumpPowerCounter field_110320_a +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F horseJumpPower field_110321_bQ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSprintState field_175171_bO +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Lnet/minecraft/client/network/NetHandlerPlayClient; sendQueue field_71174_a +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP Z serverSneakState field_175170_bN +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosX field_175172_bI +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosY field_175166_bJ +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP D lastReportedPosZ field_175167_bK +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedYaw field_175164_bL +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP F lastReportedPitch field_175165_bM +FIELD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP I positionUpdateTicks field_175168_bP +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Lnet/minecraft/client/gui/GuiTextField; inputField field_146415_a +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Ljava/util/List; foundPlayerNames field_146412_t +FIELD keystrokesmod/mixin/impl/render/MixinGuiChat Z waitingOnAutocomplete field_146414_r +FIELD keystrokesmod/mixin/impl/render/MixinGuiScreen Lnet/minecraft/client/Minecraft; mc field_146297_k +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer Lnet/minecraft/item/ItemStack; itemToRender field_78453_b +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F equippedProgress field_78454_c +FIELD keystrokesmod/mixin/impl/render/MixinItemRenderer F prevEquippedProgress field_78451_d +FIELD keystrokesmod/mixin/impl/render/MixinLayerCape Lnet/minecraft/client/renderer/entity/RenderPlayer; playerRenderer field_177167_a +FIELD keystrokesmod/mixin/impl/render/MixinRendererLivingEntity Z renderOutlines field_177098_i +FIELD keystrokesmod/mixin/impl/render/MixinRenderGlobal Lnet/minecraft/client/Minecraft; mc field_72777_q +FIELD keystrokesmod/mixin/impl/world/MixinWorld Z isRemote field_72995_K +METHOD keystrokesmod/mixin/impl/client/MixinGameSettings (Lnet/minecraft/client/settings/KeyBinding;)Z isKeyDown func_100015_a +METHOD keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions ()V updatePlayerMoveState func_78898_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FFF)V moveFlying func_70060_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntity (FF)Lnet/minecraft/util/Vec3; getVectorForRotation func_174806_f +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect; getActivePotionEffect func_70660_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase (Lnet/minecraft/potion/Potion;)Z isPotionActive func_70644_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()F getJumpUpwardsMotion func_175134_bD +METHOD keystrokesmod/mixin/impl/entity/MixinEntityLivingBase ()V jump func_70664_aZ +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getHeldItem func_70694_bm +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onCriticalHit func_71009_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V onEnchantmentCritical func_71047_c +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;)V triggerAchievement func_71029_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()Lnet/minecraft/item/ItemStack; getCurrentEquippedItem func_71045_bC +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer ()V destroyCurrentEquippedItem func_71028_bD +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/stats/StatBase;I)V addStat func_71064_a +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (F)V addExhaustion func_71020_j +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayer (Lnet/minecraft/entity/Entity;)V attackTargetEntityWithCurrentItem func_71059_n +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP (Z)V setSprinting func_70031_b +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendPlayerAbilities func_71016_p +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isCurrentViewEntity func_175160_A +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isRidingHorse func_110317_t +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V sendHorseJump func_110318_g +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()Z isSneaking func_70093_af +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onUpdateWalkingPlayer func_175161_p +METHOD keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP ()V onLivingUpdate func_70636_d +METHOD keystrokesmod/mixin/impl/render/MixinGuiChat ([Ljava/lang/String;)V onAutocompleteResponse func_146406_a +METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/util/AxisAlignedBB; getCollisionBoundingBox func_180640_a +METHOD keystrokesmod/mixin/impl/world/MixinBlock (Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/entity/Entity;)V addCollisionBoxesToList func_180638_a diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index cbd7c8c..b6cdb75 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/jar/MANIFEST.MF b/build/tmp/jar/MANIFEST.MF index 058ca86..159612a 100644 --- a/build/tmp/jar/MANIFEST.MF +++ b/build/tmp/jar/MANIFEST.MF @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -FMLCorePluginContainsFMLMod: true -ForceLoadAsMod: true -TweakClass: org.spongepowered.asm.launch.MixinTweaker -MixinConfigs: mixins.raven.json - +Manifest-Version: 1.0 +FMLCorePluginContainsFMLMod: true +ForceLoadAsMod: true +TweakClass: org.spongepowered.asm.launch.MixinTweaker +MixinConfigs: mixins.raven.json + diff --git a/build/tmp/remapJar/MANIFEST.MF b/build/tmp/remapJar/MANIFEST.MF index 058ca86..159612a 100644 --- a/build/tmp/remapJar/MANIFEST.MF +++ b/build/tmp/remapJar/MANIFEST.MF @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -FMLCorePluginContainsFMLMod: true -ForceLoadAsMod: true -TweakClass: org.spongepowered.asm.launch.MixinTweaker -MixinConfigs: mixins.raven.json - +Manifest-Version: 1.0 +FMLCorePluginContainsFMLMod: true +ForceLoadAsMod: true +TweakClass: org.spongepowered.asm.launch.MixinTweaker +MixinConfigs: mixins.raven.json + diff --git a/build/tmp/shadowJar/MANIFEST.MF b/build/tmp/shadowJar/MANIFEST.MF index 058ca86..159612a 100644 --- a/build/tmp/shadowJar/MANIFEST.MF +++ b/build/tmp/shadowJar/MANIFEST.MF @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -FMLCorePluginContainsFMLMod: true -ForceLoadAsMod: true -TweakClass: org.spongepowered.asm.launch.MixinTweaker -MixinConfigs: mixins.raven.json - +Manifest-Version: 1.0 +FMLCorePluginContainsFMLMod: true +ForceLoadAsMod: true +TweakClass: org.spongepowered.asm.launch.MixinTweaker +MixinConfigs: mixins.raven.json + diff --git a/gradle.properties b/gradle.properties index 7c83c96..3464025 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ -loom.platform=forge -org.gradle.jvmargs=-Xmx2g -baseGroup = keystrokesmod -mcVersion = 1.8.9 -modid = raven-bS -version = 13 \ No newline at end of file +loom.platform=forge +org.gradle.jvmargs=-Xmx2g +baseGroup = keystrokesmod +mcVersion = 1.8.9 +modid = raven-bS +version = 995 \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index ef92061..5211ec7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,26 +1,26 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://maven.architectury.dev/") - maven("https://maven.fabricmc.net") - maven("https://maven.minecraftforge.net/") - maven("https://repo.spongepowered.org/maven/") - maven("https://repo.sk1er.club/repository/maven-releases/") - } - resolutionStrategy { - eachPlugin { - when (requested.id.id) { - "gg.essential.loom" -> useModule("gg.essential:architectury-loom:${requested.version}") - } - } - } -} - -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version("0.6.0") -} - - +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + maven("https://oss.sonatype.org/content/repositories/snapshots") + maven("https://maven.architectury.dev/") + maven("https://maven.fabricmc.net") + maven("https://maven.minecraftforge.net/") + maven("https://repo.spongepowered.org/maven/") + maven("https://repo.sk1er.club/repository/maven-releases/") + } + resolutionStrategy { + eachPlugin { + when (requested.id.id) { + "gg.essential.loom" -> useModule("gg.essential:architectury-loom:${requested.version}") + } + } + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version("0.6.0") +} + + rootProject.name = "raven-bS" \ No newline at end of file diff --git a/src/main/java/keystrokesmod/Raven.java b/src/main/java/keystrokesmod/Raven.java index d96f0bb..d1b4ec2 100644 --- a/src/main/java/keystrokesmod/Raven.java +++ b/src/main/java/keystrokesmod/Raven.java @@ -70,6 +70,7 @@ public class Raven { MinecraftForge.EVENT_BUS.register(new PingHelper()); MinecraftForge.EVENT_BUS.register(packetsHandler = new PacketsHandler()); MinecraftForge.EVENT_BUS.register(new ModuleUtils(this.mc)); + MinecraftForge.EVENT_BUS.register(new BlinkHandler(this.mc)); MinecraftForge.EVENT_BUS.register(knockBackHelper = new KnockBackHelper()); ReflectionUtils.setupFields(); moduleManager.register(); @@ -83,6 +84,7 @@ public class Raven { profileManager.loadProfile("default"); ReflectionUtils.setKeyBindings(); MinecraftForge.EVENT_BUS.register(ModuleManager.scaffold); + MinecraftForge.EVENT_BUS.register(ModuleManager.timers); MinecraftForge.EVENT_BUS.register(ModuleManager.tower); commandManager = new CommandManager(); } diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java index a576c9e..143fab2 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java @@ -1,170 +1,170 @@ -package keystrokesmod.clickgui.components.impl; - -import keystrokesmod.Raven; -import keystrokesmod.clickgui.components.Component; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.client.Gui; -import keystrokesmod.module.setting.impl.KeySetting; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.profile.ProfileModule; -import net.minecraft.client.Minecraft; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - -public class BindComponent extends Component { - public boolean isBinding; - public ModuleComponent moduleComponent; - public float o; - public float x; - private float y; - public KeySetting keySetting; - public float xOffset; - - public BindComponent(ModuleComponent moduleComponent, float o) { - this.moduleComponent = moduleComponent; - this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); - this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; - this.o = o; - } - - public BindComponent(ModuleComponent moduleComponent, KeySetting keySetting, float o) { - this.moduleComponent = moduleComponent; - this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); - this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; - this.keySetting = keySetting; - this.o = o; - } - - public void updateHeight(float n) { - this.o = n; - } - - public void render() { - GL11.glPushMatrix(); - GL11.glScaled(0.5D, 0.5D, 0.5D); - if (keySetting == null) { - this.drawString(!this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.mod.script == null ? "Module cannot be bound." : this.isBinding ? "Press a key..." : "Current bind: '§e" + getKeyAsStr(false) + "§r'"); - } - else { - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(this.isBinding ? "Press a key..." : this.keySetting.getName() + ": '§e" + getKeyAsStr(true) + "§r'", (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2) + xOffset, (float) ((this.moduleComponent.categoryComponent.getY() + this.o + (this.keySetting == null ? 3 : 4)) * 2), Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0)); - } - GL11.glPopMatrix(); - } - - public void drawScreen(int x, int y) { - this.y = this.moduleComponent.categoryComponent.getModuleY() + this.o; - this.x = this.moduleComponent.categoryComponent.getX(); - } - - public boolean onClick(int x, int y, int button) { - if (this.overSetting(x, y) && this.moduleComponent.isOpened && this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.isVisible(this)) { - if (button == 0) { - this.isBinding = !this.isBinding; - } - else if (button == 1 && this.moduleComponent.mod.moduleCategory() != Module.category.profiles && this.keySetting == null) { - this.moduleComponent.mod.setHidden(!this.moduleComponent.mod.isHidden()); - if (Raven.currentProfile != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - } - else if (button > 1) { - if (this.isBinding) { - if (this.keySetting != null) { - this.keySetting.setKey(button + 1000); - } - else { - this.moduleComponent.mod.setBind(button + 1000); - } - if (Raven.currentProfile != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - this.isBinding = false; - } - } - } - return false; - } - - public void onScroll(int scroll) { - if (this.isBinding && scroll != 0) { - if (this.keySetting != null) { - this.keySetting.setKey(scroll > 0 ? 1069 : 1070); // 1069 for up, 1070 for down - } - else { - this.moduleComponent.mod.setBind(scroll > 0 ? 1069 : 1070); // might cause issues if your mouse has more than 69 buttons for some reason??? - } - if (Raven.currentProfile != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - this.isBinding = false; - } - } - - public void keyTyped(char t, int keybind) { - if (this.isBinding) { - if (keybind == Keyboard.KEY_0 || keybind == Keyboard.KEY_ESCAPE) { - if (this.moduleComponent.mod instanceof Gui) { - this.moduleComponent.mod.setBind(54); - } - else { - if (this.keySetting != null) { - this.keySetting.setKey(0); - } - else { - this.moduleComponent.mod.setBind(0); - } - } - if (Raven.currentProfile != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - } - else { - if (Raven.currentProfile != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - if (this.keySetting != null) { - this.keySetting.setKey(keybind); - } - else { - this.moduleComponent.mod.setBind(keybind); - } - } - - this.isBinding = false; - } - } - - public boolean overSetting(int x, int y) { - return x > this.x && x < this.x + this.moduleComponent.categoryComponent.getWidth() && y > this.y - 1 && y < this.y + 12; - } - - public String getKeyAsStr(boolean isKey) { - int key = isKey ? this.keySetting.getKey() : this.moduleComponent.mod.getKeycode(); - return (key >= 1000 ? ((key == 1069 || key == 1070) ? getScroll(key) : "M" + (key - 1000)) : Keyboard.getKeyName(key)); - } - - public String getScroll(int key) { - if (key == 1069) { - return "MScrollUp"; - } - else if (key == 1070) { - return "MScrollDown"; - } - return "&cERROR"; - } - - public int getHeight() { - if (this.keySetting != null) { - return 0; - } - return 16; - } - - private void drawString(String s) { - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(s, (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2) + xOffset, (float) ((this.moduleComponent.categoryComponent.getY() + this.o + (this.keySetting == null ? 3 : 4)) * 2), !this.moduleComponent.mod.hidden ? Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0) : Theme.getGradient(Theme.hiddenBind[0], Theme.hiddenBind[1], 0)); - } - - public void onGuiClosed() { - this.isBinding = false; - } +package keystrokesmod.clickgui.components.impl; + +import keystrokesmod.Raven; +import keystrokesmod.clickgui.components.Component; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.client.Gui; +import keystrokesmod.module.setting.impl.KeySetting; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.profile.ProfileModule; +import net.minecraft.client.Minecraft; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +public class BindComponent extends Component { + public boolean isBinding; + public ModuleComponent moduleComponent; + public float o; + public float x; + private float y; + public KeySetting keySetting; + public float xOffset; + + public BindComponent(ModuleComponent moduleComponent, float o) { + this.moduleComponent = moduleComponent; + this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); + this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; + this.o = o; + } + + public BindComponent(ModuleComponent moduleComponent, KeySetting keySetting, float o) { + this.moduleComponent = moduleComponent; + this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); + this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; + this.keySetting = keySetting; + this.o = o; + } + + public void updateHeight(float n) { + this.o = n; + } + + public void render() { + GL11.glPushMatrix(); + GL11.glScaled(0.5D, 0.5D, 0.5D); + if (keySetting == null) { + this.drawString(!this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.mod.script == null ? "Module cannot be bound." : this.isBinding ? "Press a key..." : "Current bind: '§e" + getKeyAsStr(false) + "§r'"); + } + else { + Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(this.isBinding ? "Press a key..." : this.keySetting.getName() + ": '§e" + getKeyAsStr(true) + "§r'", (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2) + xOffset, (float) ((this.moduleComponent.categoryComponent.getY() + this.o + (this.keySetting == null ? 3 : 4)) * 2), Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0)); + } + GL11.glPopMatrix(); + } + + public void drawScreen(int x, int y) { + this.y = this.moduleComponent.categoryComponent.getModuleY() + this.o; + this.x = this.moduleComponent.categoryComponent.getX(); + } + + public boolean onClick(int x, int y, int button) { + if (this.overSetting(x, y) && this.moduleComponent.isOpened && this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.isVisible(this)) { + if (button == 0) { + this.isBinding = !this.isBinding; + } + else if (button == 1 && this.moduleComponent.mod.moduleCategory() != Module.category.profiles && this.keySetting == null) { + this.moduleComponent.mod.setHidden(!this.moduleComponent.mod.isHidden()); + if (Raven.currentProfile != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + } + else if (button > 1) { + if (this.isBinding) { + if (this.keySetting != null) { + this.keySetting.setKey(button + 1000); + } + else { + this.moduleComponent.mod.setBind(button + 1000); + } + if (Raven.currentProfile != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + this.isBinding = false; + } + } + } + return false; + } + + public void onScroll(int scroll) { + if (this.isBinding && scroll != 0) { + if (this.keySetting != null) { + this.keySetting.setKey(scroll > 0 ? 1069 : 1070); // 1069 for up, 1070 for down + } + else { + this.moduleComponent.mod.setBind(scroll > 0 ? 1069 : 1070); // might cause issues if your mouse has more than 69 buttons for some reason??? + } + if (Raven.currentProfile != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + this.isBinding = false; + } + } + + public void keyTyped(char t, int keybind) { + if (this.isBinding) { + if (keybind == Keyboard.KEY_0 || keybind == Keyboard.KEY_ESCAPE) { + if (this.moduleComponent.mod instanceof Gui) { + this.moduleComponent.mod.setBind(54); + } + else { + if (this.keySetting != null) { + this.keySetting.setKey(0); + } + else { + this.moduleComponent.mod.setBind(0); + } + } + if (Raven.currentProfile != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + } + else { + if (Raven.currentProfile != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + if (this.keySetting != null) { + this.keySetting.setKey(keybind); + } + else { + this.moduleComponent.mod.setBind(keybind); + } + } + + this.isBinding = false; + } + } + + public boolean overSetting(int x, int y) { + return x > this.x && x < this.x + this.moduleComponent.categoryComponent.getWidth() && y > this.y - 1 && y < this.y + 12; + } + + public String getKeyAsStr(boolean isKey) { + int key = isKey ? this.keySetting.getKey() : this.moduleComponent.mod.getKeycode(); + return (key >= 1000 ? ((key == 1069 || key == 1070) ? getScroll(key) : "M" + (key - 1000)) : Keyboard.getKeyName(key)); + } + + public String getScroll(int key) { + if (key == 1069) { + return "MScrollUp"; + } + else if (key == 1070) { + return "MScrollDown"; + } + return "&cERROR"; + } + + public int getHeight() { + if (this.keySetting != null) { + return 0; + } + return 16; + } + + private void drawString(String s) { + Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(s, (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2) + xOffset, (float) ((this.moduleComponent.categoryComponent.getY() + this.o + (this.keySetting == null ? 3 : 4)) * 2), !this.moduleComponent.mod.hidden ? Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0) : Theme.getGradient(Theme.hiddenBind[0], Theme.hiddenBind[1], 0)); + } + + public void onGuiClosed() { + this.isBinding = false; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/GroupComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/GroupComponent.java index 82e0ae1..ad8cb14 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/GroupComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/GroupComponent.java @@ -1,87 +1,87 @@ -package keystrokesmod.clickgui.components.impl; - -import keystrokesmod.Raven; -import keystrokesmod.clickgui.components.Component; -import keystrokesmod.module.setting.impl.GroupSetting; -import net.minecraft.client.Minecraft; -import org.lwjgl.opengl.GL11; - -public class GroupComponent extends Component { - public GroupSetting setting; - private ModuleComponent component; - public float o; - private float x; - private float y; - public boolean opened; - - public GroupComponent(GroupSetting setting, ModuleComponent moduleComponent, float o) { - this.setting = setting; - this.component = moduleComponent; - this.o = o; - this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); - this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; - } - - public void render() { - GL11.glPushMatrix(); - GL11.glScaled(0.5D, 0.5D, 0.5D); - float strX = (float) ((this.component.categoryComponent.getX() + 4) * 2) + 1; - float strY = (float) ((this.component.categoryComponent.getY() + this.o + 4) * 2); - if (this.opened) { - drawString("[", strX, strY); - - int firstBracketWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth("["); - int arrowWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth('>'); - int fontHeight = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT; - - GL11.glPushMatrix(); - GL11.glTranslatef(strX, strY, 0F); - - float arrowX = firstBracketWidth - 2; - GL11.glTranslatef(arrowX + (arrowWidth / 2F), (fontHeight / 2F), 0F); - GL11.glRotatef(90F, 0F, 0F, 1F); - GL11.glTranslatef(-(arrowWidth / 2F), -(fontHeight / 2F), 0F); - - drawString(">", 0, 0); - GL11.glPopMatrix(); - drawString("] " + this.setting.getName(), strX + firstBracketWidth + arrowWidth, strY); - } else { - drawString("[>] " + this.setting.getName(), strX, strY); - } - GL11.glPopMatrix(); - } - - public void updateHeight(float n) { - this.o = n; - } - - public void drawScreen(int x, int y) { - this.y = this.component.categoryComponent.getModuleY() + this.o; - this.x = this.component.categoryComponent.getX(); - } - - public boolean onClick(int x, int y, int b) { - if (this.i(x, y) && b == 1 && this.component.isOpened) { - this.opened = !this.opened; - for (CategoryComponent categoryComponent : Raven.clickGui.categories) { - if (categoryComponent.category == this.component.mod.moduleCategory()) { - for (ModuleComponent moduleComponent : categoryComponent.modules) { - if (moduleComponent.mod.getName().equals(this.component.mod.getName())) { - moduleComponent.updateSettingPositions(7); - break; - } - } - } - } - } - return false; - } - - public boolean i(int x, int y) { - return x > this.x && x < this.x + this.component.categoryComponent.getWidth() && y > this.y && y < this.y + 11; - } - - public void drawString(String text, float x, float y) { - Minecraft.getMinecraft().fontRendererObj.drawString(text, x, y, -1, false); - } +package keystrokesmod.clickgui.components.impl; + +import keystrokesmod.Raven; +import keystrokesmod.clickgui.components.Component; +import keystrokesmod.module.setting.impl.GroupSetting; +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL11; + +public class GroupComponent extends Component { + public GroupSetting setting; + private ModuleComponent component; + public float o; + private float x; + private float y; + public boolean opened; + + public GroupComponent(GroupSetting setting, ModuleComponent moduleComponent, float o) { + this.setting = setting; + this.component = moduleComponent; + this.o = o; + this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); + this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; + } + + public void render() { + GL11.glPushMatrix(); + GL11.glScaled(0.5D, 0.5D, 0.5D); + float strX = (float) ((this.component.categoryComponent.getX() + 4) * 2) + 1; + float strY = (float) ((this.component.categoryComponent.getY() + this.o + 4) * 2); + if (this.opened) { + drawString("[", strX, strY); + + int firstBracketWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth("["); + int arrowWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth('>'); + int fontHeight = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT; + + GL11.glPushMatrix(); + GL11.glTranslatef(strX, strY, 0F); + + float arrowX = firstBracketWidth - 2; + GL11.glTranslatef(arrowX + (arrowWidth / 2F), (fontHeight / 2F), 0F); + GL11.glRotatef(90F, 0F, 0F, 1F); + GL11.glTranslatef(-(arrowWidth / 2F), -(fontHeight / 2F), 0F); + + drawString(">", 0, 0); + GL11.glPopMatrix(); + drawString("] " + this.setting.getName(), strX + firstBracketWidth + arrowWidth, strY); + } else { + drawString("[>] " + this.setting.getName(), strX, strY); + } + GL11.glPopMatrix(); + } + + public void updateHeight(float n) { + this.o = n; + } + + public void drawScreen(int x, int y) { + this.y = this.component.categoryComponent.getModuleY() + this.o; + this.x = this.component.categoryComponent.getX(); + } + + public boolean onClick(int x, int y, int b) { + if (this.i(x, y) && b == 1 && this.component.isOpened) { + this.opened = !this.opened; + for (CategoryComponent categoryComponent : Raven.clickGui.categories) { + if (categoryComponent.category == this.component.mod.moduleCategory()) { + for (ModuleComponent moduleComponent : categoryComponent.modules) { + if (moduleComponent.mod.getName().equals(this.component.mod.getName())) { + moduleComponent.updateSettingPositions(7); + break; + } + } + } + } + } + return false; + } + + public boolean i(int x, int y) { + return x > this.x && x < this.x + this.component.categoryComponent.getWidth() && y > this.y && y < this.y + 11; + } + + public void drawString(String text, float x, float y) { + Minecraft.getMinecraft().fontRendererObj.drawString(text, x, y, -1, false); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java b/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java index acca7c5..d991c38 100644 --- a/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java +++ b/src/main/java/keystrokesmod/event/AntiCheatFlagEvent.java @@ -1,14 +1,14 @@ -package keystrokesmod.event; - -import net.minecraft.entity.Entity; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class AntiCheatFlagEvent extends Event { - public String flag; - public Entity entity; - - public AntiCheatFlagEvent(String flag, Entity entity) { - this.flag = flag; - this.entity = entity; - } -} +package keystrokesmod.event; + +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class AntiCheatFlagEvent extends Event { + public String flag; + public Entity entity; + + public AntiCheatFlagEvent(String flag, Entity entity) { + this.flag = flag; + this.entity = entity; + } +} diff --git a/src/main/java/keystrokesmod/event/AttackEvent.java b/src/main/java/keystrokesmod/event/AttackEvent.java index f463b5c..71ddd73 100644 --- a/src/main/java/keystrokesmod/event/AttackEvent.java +++ b/src/main/java/keystrokesmod/event/AttackEvent.java @@ -1,18 +1,18 @@ -package keystrokesmod.event; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class AttackEvent extends Event { - public Entity target; - public EntityPlayer attacker; - - public AttackEvent(Entity target, EntityPlayer attacker) { - this.target = target; - this.attacker = attacker; - } - -} +package keystrokesmod.event; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class AttackEvent extends Event { + public Entity target; + public EntityPlayer attacker; + + public AttackEvent(Entity target, EntityPlayer attacker) { + this.target = target; + this.attacker = attacker; + } + +} diff --git a/src/main/java/keystrokesmod/event/ClientLookEvent.java b/src/main/java/keystrokesmod/event/ClientLookEvent.java index 2076332..a3b4f29 100644 --- a/src/main/java/keystrokesmod/event/ClientLookEvent.java +++ b/src/main/java/keystrokesmod/event/ClientLookEvent.java @@ -1,13 +1,13 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class ClientLookEvent extends Event { - public float yaw; - public float pitch; - - public ClientLookEvent(float yaw, float pitch) { - this.yaw = yaw; - this.pitch = pitch; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class ClientLookEvent extends Event { + public float yaw; + public float pitch; + + public ClientLookEvent(float yaw, float pitch) { + this.yaw = yaw; + this.pitch = pitch; + } +} diff --git a/src/main/java/keystrokesmod/event/ClientRotationEvent.java b/src/main/java/keystrokesmod/event/ClientRotationEvent.java index 8c6d6b3..cf12bdf 100644 --- a/src/main/java/keystrokesmod/event/ClientRotationEvent.java +++ b/src/main/java/keystrokesmod/event/ClientRotationEvent.java @@ -1,40 +1,40 @@ -package keystrokesmod.event; - -import keystrokesmod.script.model.PlayerState; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class ClientRotationEvent extends Event { - public Float yaw; - public Float pitch; - private float tYaw, tPitch; - - public ClientRotationEvent(Float yaw, Float pitch) { - this.yaw = yaw; - this.pitch = pitch; - } - - public float getYaw() { - return tYaw; - } - - public float getPitch() { - return tPitch; - } - - public void setYaw(Float yaw) { - this.yaw = yaw; - } - - public void setPitch(Float pitch) { - this.pitch = pitch; - } - - public void setRotations(Float yaw, Float pitch) { - this.yaw = yaw; - this.pitch = pitch; - } - - public boolean isEquals(PlayerState e) { - return e.yaw == this.tYaw && e.pitch == this.tPitch; - } -} +package keystrokesmod.event; + +import keystrokesmod.script.model.PlayerState; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class ClientRotationEvent extends Event { + public Float yaw; + public Float pitch; + private float tYaw, tPitch; + + public ClientRotationEvent(Float yaw, Float pitch) { + this.yaw = yaw; + this.pitch = pitch; + } + + public float getYaw() { + return tYaw; + } + + public float getPitch() { + return tPitch; + } + + public void setYaw(Float yaw) { + this.yaw = yaw; + } + + public void setPitch(Float pitch) { + this.pitch = pitch; + } + + public void setRotations(Float yaw, Float pitch) { + this.yaw = yaw; + this.pitch = pitch; + } + + public boolean isEquals(PlayerState e) { + return e.yaw == this.tYaw && e.pitch == this.tPitch; + } +} diff --git a/src/main/java/keystrokesmod/event/CollisionEvent.java b/src/main/java/keystrokesmod/event/CollisionEvent.java index 1ba9914..fd8e22f 100644 --- a/src/main/java/keystrokesmod/event/CollisionEvent.java +++ b/src/main/java/keystrokesmod/event/CollisionEvent.java @@ -1,34 +1,34 @@ -package keystrokesmod.event; - -import net.minecraft.block.Block; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class CollisionEvent extends Event { - public final BlockPos blockPos; - public final Block block; - public AxisAlignedBB boundingBox; - - public CollisionEvent(BlockPos position, Block block, AxisAlignedBB boundingBox) { - this.blockPos = position; - this.block = block; - this.boundingBox = boundingBox; - } - - public BlockPos getBlockPos() { - return blockPos; - } - - public Block getBlock() { - return block; - } - - public AxisAlignedBB getBoundingBox() { - return boundingBox; - } - - public void setBoundingBox(AxisAlignedBB boundingBox) { - this.boundingBox = boundingBox; - } -} +package keystrokesmod.event; + +import net.minecraft.block.Block; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class CollisionEvent extends Event { + public final BlockPos blockPos; + public final Block block; + public AxisAlignedBB boundingBox; + + public CollisionEvent(BlockPos position, Block block, AxisAlignedBB boundingBox) { + this.blockPos = position; + this.block = block; + this.boundingBox = boundingBox; + } + + public BlockPos getBlockPos() { + return blockPos; + } + + public Block getBlock() { + return block; + } + + public AxisAlignedBB getBoundingBox() { + return boundingBox; + } + + public void setBoundingBox(AxisAlignedBB boundingBox) { + this.boundingBox = boundingBox; + } +} diff --git a/src/main/java/keystrokesmod/event/GameTickEvent.java b/src/main/java/keystrokesmod/event/GameTickEvent.java index df0ecdb..b4d06a2 100644 --- a/src/main/java/keystrokesmod/event/GameTickEvent.java +++ b/src/main/java/keystrokesmod/event/GameTickEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class GameTickEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class GameTickEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/GuiUpdateEvent.java b/src/main/java/keystrokesmod/event/GuiUpdateEvent.java index 9e6558d..0d18a40 100644 --- a/src/main/java/keystrokesmod/event/GuiUpdateEvent.java +++ b/src/main/java/keystrokesmod/event/GuiUpdateEvent.java @@ -1,14 +1,14 @@ -package keystrokesmod.event; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class GuiUpdateEvent extends Event { - public GuiScreen guiScreen; - public boolean opened; - - public GuiUpdateEvent(GuiScreen guiScreen, boolean opened) { - this.guiScreen = guiScreen; - this.opened = opened; - } -} +package keystrokesmod.event; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class GuiUpdateEvent extends Event { + public GuiScreen guiScreen; + public boolean opened; + + public GuiUpdateEvent(GuiScreen guiScreen, boolean opened) { + this.guiScreen = guiScreen; + this.opened = opened; + } +} diff --git a/src/main/java/keystrokesmod/event/JumpEvent.java b/src/main/java/keystrokesmod/event/JumpEvent.java index ad1e67c..74451bf 100644 --- a/src/main/java/keystrokesmod/event/JumpEvent.java +++ b/src/main/java/keystrokesmod/event/JumpEvent.java @@ -1,40 +1,40 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class JumpEvent extends Event { - private float motionY, yaw; - private boolean applySprint; - - public JumpEvent(float motionY, float yaw, boolean applySprint) { - this.motionY = motionY; - this.yaw = yaw; - this.applySprint = applySprint; - } - - public float getMotionY() { - return motionY; - } - - public void setMotionY(float motionY) { - this.motionY = motionY; - } - - public float getYaw() { - return yaw; - } - - public void setYaw(float yaw) { - this.yaw = yaw; - } - - public boolean applySprint() { - return applySprint; - } - - public void setSprint(boolean applySprint) { - this.applySprint = applySprint; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class JumpEvent extends Event { + private float motionY, yaw; + private boolean applySprint; + + public JumpEvent(float motionY, float yaw, boolean applySprint) { + this.motionY = motionY; + this.yaw = yaw; + this.applySprint = applySprint; + } + + public float getMotionY() { + return motionY; + } + + public void setMotionY(float motionY) { + this.motionY = motionY; + } + + public float getYaw() { + return yaw; + } + + public void setYaw(float yaw) { + this.yaw = yaw; + } + + public boolean applySprint() { + return applySprint; + } + + public void setSprint(boolean applySprint) { + this.applySprint = applySprint; + } +} diff --git a/src/main/java/keystrokesmod/event/KeyPressEvent.java b/src/main/java/keystrokesmod/event/KeyPressEvent.java index 0619268..29bcd85 100644 --- a/src/main/java/keystrokesmod/event/KeyPressEvent.java +++ b/src/main/java/keystrokesmod/event/KeyPressEvent.java @@ -1,15 +1,15 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class KeyPressEvent extends Event { - public char typedChar; - public int keyCode; - - public KeyPressEvent(char typedChar, int keyCode) { - this.typedChar = typedChar; - this.keyCode = keyCode; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class KeyPressEvent extends Event { + public char typedChar; + public int keyCode; + + public KeyPressEvent(char typedChar, int keyCode) { + this.typedChar = typedChar; + this.keyCode = keyCode; + } +} diff --git a/src/main/java/keystrokesmod/event/NoEventPacketEvent.java b/src/main/java/keystrokesmod/event/NoEventPacketEvent.java index 800487d..e592dc6 100644 --- a/src/main/java/keystrokesmod/event/NoEventPacketEvent.java +++ b/src/main/java/keystrokesmod/event/NoEventPacketEvent.java @@ -1,18 +1,16 @@ -package keystrokesmod.event; - -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class NoEventPacketEvent extends Event { - private Packet packet; - - public NoEventPacketEvent(Packet packet) { - this.packet = packet; - } - - public Packet getPacket() { - return packet; - } -} +package keystrokesmod.event; + +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class NoEventPacketEvent extends Event { + private Packet packet; + + public NoEventPacketEvent(Packet packet) { + this.packet = packet; + } + + public Packet getPacket() { + return packet; + } +} diff --git a/src/main/java/keystrokesmod/event/PlayerMoveEvent.java b/src/main/java/keystrokesmod/event/PlayerMoveEvent.java new file mode 100644 index 0000000..0bd7279 --- /dev/null +++ b/src/main/java/keystrokesmod/event/PlayerMoveEvent.java @@ -0,0 +1,16 @@ +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PlayerMoveEvent extends Event { + public double x; + public double y; + public double z; + + public PlayerMoveEvent(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/PostMotionEvent.java b/src/main/java/keystrokesmod/event/PostMotionEvent.java index fdb0584..181dae9 100644 --- a/src/main/java/keystrokesmod/event/PostMotionEvent.java +++ b/src/main/java/keystrokesmod/event/PostMotionEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostMotionEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PostMotionEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/PostPlayerInputEvent.java b/src/main/java/keystrokesmod/event/PostPlayerInputEvent.java index 8bf80fd..e62c315 100644 --- a/src/main/java/keystrokesmod/event/PostPlayerInputEvent.java +++ b/src/main/java/keystrokesmod/event/PostPlayerInputEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostPlayerInputEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PostPlayerInputEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/PostProfileLoadEvent.java b/src/main/java/keystrokesmod/event/PostProfileLoadEvent.java index 1eabdf6..294a646 100644 --- a/src/main/java/keystrokesmod/event/PostProfileLoadEvent.java +++ b/src/main/java/keystrokesmod/event/PostProfileLoadEvent.java @@ -1,11 +1,11 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostProfileLoadEvent extends Event { - public String profileName; - - public PostProfileLoadEvent(String profileName) { - this.profileName = profileName; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PostProfileLoadEvent extends Event { + public String profileName; + + public PostProfileLoadEvent(String profileName) { + this.profileName = profileName; + } +} diff --git a/src/main/java/keystrokesmod/event/PostSetSliderEvent.java b/src/main/java/keystrokesmod/event/PostSetSliderEvent.java index 8ade53a..7d0ec50 100644 --- a/src/main/java/keystrokesmod/event/PostSetSliderEvent.java +++ b/src/main/java/keystrokesmod/event/PostSetSliderEvent.java @@ -1,13 +1,13 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostSetSliderEvent extends Event { - public double previousVal; - public double newVal; - - public PostSetSliderEvent(double previousVal, double newVal) { - this.previousVal = previousVal; - this.newVal = newVal; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PostSetSliderEvent extends Event { + public double previousVal; + public double newVal; + + public PostSetSliderEvent(double previousVal, double newVal) { + this.previousVal = previousVal; + this.newVal = newVal; + } +} diff --git a/src/main/java/keystrokesmod/event/PostUpdateEvent.java b/src/main/java/keystrokesmod/event/PostUpdateEvent.java index a76b17f..952e891 100644 --- a/src/main/java/keystrokesmod/event/PostUpdateEvent.java +++ b/src/main/java/keystrokesmod/event/PostUpdateEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostUpdateEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PostUpdateEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/PreEntityVelocityEvent.java b/src/main/java/keystrokesmod/event/PreEntityVelocityEvent.java index 74c8d59..1003f8c 100644 --- a/src/main/java/keystrokesmod/event/PreEntityVelocityEvent.java +++ b/src/main/java/keystrokesmod/event/PreEntityVelocityEvent.java @@ -1,14 +1,14 @@ -package keystrokesmod.event; - -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class PreEntityVelocityEvent extends Event { - public S12PacketEntityVelocity packet; - - public PreEntityVelocityEvent(S12PacketEntityVelocity packet) { - this.packet = packet; - } +package keystrokesmod.event; + +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class PreEntityVelocityEvent extends Event { + public S12PacketEntityVelocity packet; + + public PreEntityVelocityEvent(S12PacketEntityVelocity packet) { + this.packet = packet; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/PreExplosionPacketEvent.java b/src/main/java/keystrokesmod/event/PreExplosionPacketEvent.java index 32febe6..7438360 100644 --- a/src/main/java/keystrokesmod/event/PreExplosionPacketEvent.java +++ b/src/main/java/keystrokesmod/event/PreExplosionPacketEvent.java @@ -1,15 +1,15 @@ -package keystrokesmod.event; - -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class PreExplosionPacketEvent extends Event { - public S27PacketExplosion packet; - - public PreExplosionPacketEvent(S27PacketExplosion packet) { - this.packet = packet; - } - +package keystrokesmod.event; + +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class PreExplosionPacketEvent extends Event { + public S27PacketExplosion packet; + + public PreExplosionPacketEvent(S27PacketExplosion packet) { + this.packet = packet; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/PreInputEvent.java b/src/main/java/keystrokesmod/event/PreInputEvent.java index 27a7bd4..02210fd 100644 --- a/src/main/java/keystrokesmod/event/PreInputEvent.java +++ b/src/main/java/keystrokesmod/event/PreInputEvent.java @@ -1,5 +1,5 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; -public class PreInputEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; +public class PreInputEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/PreMotionEvent.java b/src/main/java/keystrokesmod/event/PreMotionEvent.java index d404d73..f338f7a 100644 --- a/src/main/java/keystrokesmod/event/PreMotionEvent.java +++ b/src/main/java/keystrokesmod/event/PreMotionEvent.java @@ -1,117 +1,117 @@ -package keystrokesmod.event; - -import keystrokesmod.script.model.PlayerState; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PreMotionEvent extends Event { - private double posX; - public double posY; - private double posZ; - private float yaw; - private float pitch; - private boolean onGround; - private static boolean setRenderYaw; - private boolean isSprinting; - private boolean isSneaking; - public static boolean setRotations; - public static float preMotionYaw; - - public PreMotionEvent(double posX, double posY, double posZ, float yaw, float pitch, boolean onGround, boolean isSprinting, boolean isSneaking) { - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - this.yaw = yaw; - this.pitch = pitch; - this.onGround = onGround; - this.isSprinting = isSprinting; - this.isSneaking = isSneaking; - } - - public double getPosX() { - return posX; - } - - public double getPosY() { - return posY; - } - - public double getPosZ() { - return posZ; - } - - public float getYaw() { - return yaw; - } - - public float getPitch() { - return pitch; - } - - public boolean isOnGround() { - return onGround; - } - - public void setPosX(double posX) { - this.posX = posX; - } - - public void setPosY(double posY) { - this.posY = posY; - } - - public void setPosZ(double posZ) { - this.posZ = posZ; - } - - public void setYaw(float yaw) { - this.yaw = yaw; - this.setRenderYaw = true; - setRotations = true; - preMotionYaw = yaw; - } - - public void setRotations(float yaw, float pitch) { - this.yaw = yaw; - this.pitch = pitch; - this.setRenderYaw = true; - setRotations = true; - preMotionYaw = yaw; - } - - public void setPitch(float pitch) { - this.pitch = pitch; - setRotations = true; - } - - public void setOnGround(boolean onGround) { - this.onGround = onGround; - } - - public static boolean setRenderYaw() { - return setRenderYaw; - } - - public static void setRenderYaw(boolean setYaw) { - setRenderYaw = setYaw; - } - - public boolean isSprinting() { - return isSprinting; - } - - public void setSprinting(boolean sprinting) { - this.isSprinting = sprinting; - } - - public boolean isSneaking() { - return isSneaking; - } - - public void setSneaking(boolean sneaking) { - this.isSneaking = sneaking; - } - - public boolean isEquals(PlayerState e) { - return e.x == this.posX && e.y == this.posY && e.z == this.posZ && e.yaw == this.yaw && e.pitch == this.pitch && e.onGround == this.onGround && e.isSprinting == this.isSprinting && e.isSneaking == this.isSneaking; - } -} +package keystrokesmod.event; + +import keystrokesmod.script.model.PlayerState; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PreMotionEvent extends Event { + private double posX; + public double posY; + private double posZ; + private float yaw; + private float pitch; + private boolean onGround; + private static boolean setRenderYaw; + private boolean isSprinting; + private boolean isSneaking; + public static boolean setRotations; + public static float preMotionYaw; + + public PreMotionEvent(double posX, double posY, double posZ, float yaw, float pitch, boolean onGround, boolean isSprinting, boolean isSneaking) { + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.yaw = yaw; + this.pitch = pitch; + this.onGround = onGround; + this.isSprinting = isSprinting; + this.isSneaking = isSneaking; + } + + public double getPosX() { + return posX; + } + + public double getPosY() { + return posY; + } + + public double getPosZ() { + return posZ; + } + + public float getYaw() { + return yaw; + } + + public float getPitch() { + return pitch; + } + + public boolean isOnGround() { + return onGround; + } + + public void setPosX(double posX) { + this.posX = posX; + } + + public void setPosY(double posY) { + this.posY = posY; + } + + public void setPosZ(double posZ) { + this.posZ = posZ; + } + + public void setYaw(float yaw) { + this.yaw = yaw; + this.setRenderYaw = true; + setRotations = true; + preMotionYaw = yaw; + } + + public void setRotations(float yaw, float pitch) { + this.yaw = yaw; + this.pitch = pitch; + this.setRenderYaw = true; + setRotations = true; + preMotionYaw = yaw; + } + + public void setPitch(float pitch) { + this.pitch = pitch; + setRotations = true; + } + + public void setOnGround(boolean onGround) { + this.onGround = onGround; + } + + public static boolean setRenderYaw() { + return setRenderYaw; + } + + public static void setRenderYaw(boolean setYaw) { + setRenderYaw = setYaw; + } + + public boolean isSprinting() { + return isSprinting; + } + + public void setSprinting(boolean sprinting) { + this.isSprinting = sprinting; + } + + public boolean isSneaking() { + return isSneaking; + } + + public void setSneaking(boolean sneaking) { + this.isSneaking = sneaking; + } + + public boolean isEquals(PlayerState e) { + return e.x == this.posX && e.y == this.posY && e.z == this.posZ && e.yaw == this.yaw && e.pitch == this.pitch && e.onGround == this.onGround && e.isSprinting == this.isSprinting && e.isSneaking == this.isSneaking; + } +} diff --git a/src/main/java/keystrokesmod/event/PrePlayerInputEvent.java b/src/main/java/keystrokesmod/event/PrePlayerInputEvent.java index ccef1b0..1cbfb99 100644 --- a/src/main/java/keystrokesmod/event/PrePlayerInputEvent.java +++ b/src/main/java/keystrokesmod/event/PrePlayerInputEvent.java @@ -1,57 +1,62 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PrePlayerInputEvent extends Event { - private float forward, strafe; - private boolean jump, sneak; - private double sneakSlowDownMultiplier; - - public PrePlayerInputEvent(float forward, float strafe, boolean jump, boolean sneak, double sneakSlowDownMultiplier) { - this.forward = forward; - this.strafe = strafe; - this.jump = jump; - this.sneak = sneak; - this.sneakSlowDownMultiplier = sneakSlowDownMultiplier; - } - - public float getForward() { - return forward; - } - - public void setForward(float forward) { - this.forward = forward; - } - - public float getStrafe() { - return strafe; - } - - public void setStrafe(float strafe) { - this.strafe = strafe; - } - - public boolean isJump() { - return jump; - } - - public void setJump(boolean jump) { - this.jump = jump; - } - - public boolean isSneak() { - return sneak; - } - - public void setSneak(boolean sneak) { - this.sneak = sneak; - } - - public double getSneakSlowDownMultiplier() { - return sneakSlowDownMultiplier; - } - - public void setSneakSlowDownMultiplier(double sneakSlowDownMultiplier) { - this.sneakSlowDownMultiplier = sneakSlowDownMultiplier; - } +package keystrokesmod.event; + +import keystrokesmod.script.model.MovementInput; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PrePlayerInputEvent extends Event { + private float forward, strafe; + private boolean jump, sneak; + private double sneakSlowDownMultiplier; + + public PrePlayerInputEvent(float forward, float strafe, boolean jump, boolean sneak, double sneakSlowDownMultiplier) { + this.forward = forward; + this.strafe = strafe; + this.jump = jump; + this.sneak = sneak; + this.sneakSlowDownMultiplier = sneakSlowDownMultiplier; + } + + public float getForward() { + return forward; + } + + public void setForward(float forward) { + this.forward = forward; + } + + public float getStrafe() { + return strafe; + } + + public void setStrafe(float strafe) { + this.strafe = strafe; + } + + public boolean isJump() { + return jump; + } + + public void setJump(boolean jump) { + this.jump = jump; + } + + public boolean isSneak() { + return sneak; + } + + public void setSneak(boolean sneak) { + this.sneak = sneak; + } + + public double getSneakSlowDownMultiplier() { + return sneakSlowDownMultiplier; + } + + public void setSneakSlowDownMultiplier(double sneakSlowDownMultiplier) { + this.sneakSlowDownMultiplier = sneakSlowDownMultiplier; + } + + public boolean isEquals(MovementInput e) { + return e.sneak == this.sneak && e.jump == this.jump && e.forward == this.forward && e.strafe == this.strafe; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/PrePlayerMovementInputEvent.java b/src/main/java/keystrokesmod/event/PrePlayerMovementInputEvent.java new file mode 100644 index 0000000..1456f23 --- /dev/null +++ b/src/main/java/keystrokesmod/event/PrePlayerMovementInputEvent.java @@ -0,0 +1,13 @@ +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PrePlayerMovementInputEvent extends Event { + public float forward; + public float strafe; + + public PrePlayerMovementInputEvent(float forward, float strafe) { + this.forward = forward; + this.strafe = strafe; + } +} diff --git a/src/main/java/keystrokesmod/event/PreSlotScrollEvent.java b/src/main/java/keystrokesmod/event/PreSlotScrollEvent.java index e704b4c..a0ae099 100644 --- a/src/main/java/keystrokesmod/event/PreSlotScrollEvent.java +++ b/src/main/java/keystrokesmod/event/PreSlotScrollEvent.java @@ -1,15 +1,15 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class PreSlotScrollEvent extends Event { - public int slot; - public int previousSlot; - - public PreSlotScrollEvent(int slot, int previousSlot) { - this.slot = slot; - this.previousSlot = previousSlot; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class PreSlotScrollEvent extends Event { + public int slot; + public int previousSlot; + + public PreSlotScrollEvent(int slot, int previousSlot) { + this.slot = slot; + this.previousSlot = previousSlot; + } +} diff --git a/src/main/java/keystrokesmod/event/PreUpdateEvent.java b/src/main/java/keystrokesmod/event/PreUpdateEvent.java index 67787c4..1d2e7e8 100644 --- a/src/main/java/keystrokesmod/event/PreUpdateEvent.java +++ b/src/main/java/keystrokesmod/event/PreUpdateEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PreUpdateEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PreUpdateEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/ReceiveAllPacketsEvent.java b/src/main/java/keystrokesmod/event/ReceiveAllPacketsEvent.java index 2178eec..8b31d06 100644 --- a/src/main/java/keystrokesmod/event/ReceiveAllPacketsEvent.java +++ b/src/main/java/keystrokesmod/event/ReceiveAllPacketsEvent.java @@ -1,18 +1,18 @@ -package keystrokesmod.event; - -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class ReceiveAllPacketsEvent extends Event { - private Packet packet; - - public ReceiveAllPacketsEvent(Packet packet) { - this.packet = packet; - } - - public Packet getPacket() { - return packet; - } -} +package keystrokesmod.event; + +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class ReceiveAllPacketsEvent extends Event { + private Packet packet; + + public ReceiveAllPacketsEvent(Packet packet) { + this.packet = packet; + } + + public Packet getPacket() { + return packet; + } +} diff --git a/src/main/java/keystrokesmod/event/ReceivePacketEvent.java b/src/main/java/keystrokesmod/event/ReceivePacketEvent.java index 06d4cd5..5bda2dc 100644 --- a/src/main/java/keystrokesmod/event/ReceivePacketEvent.java +++ b/src/main/java/keystrokesmod/event/ReceivePacketEvent.java @@ -1,18 +1,18 @@ -package keystrokesmod.event; - -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class ReceivePacketEvent extends Event { - private Packet packet; - - public ReceivePacketEvent(Packet packet) { - this.packet = packet; - } - - public Packet getPacket() { - return packet; - } -} +package keystrokesmod.event; + +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class ReceivePacketEvent extends Event { + private Packet packet; + + public ReceivePacketEvent(Packet packet) { + this.packet = packet; + } + + public Packet getPacket() { + return packet; + } +} diff --git a/src/main/java/keystrokesmod/event/RunGameLoopEvent.java b/src/main/java/keystrokesmod/event/RunGameLoopEvent.java index 980d6d1..7b9b42a 100644 --- a/src/main/java/keystrokesmod/event/RunGameLoopEvent.java +++ b/src/main/java/keystrokesmod/event/RunGameLoopEvent.java @@ -1,6 +1,6 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class RunGameLoopEvent extends Event { -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class RunGameLoopEvent extends Event { +} diff --git a/src/main/java/keystrokesmod/event/SendAllPacketsEvent.java b/src/main/java/keystrokesmod/event/SendAllPacketsEvent.java index 1c97a69..d3e6218 100644 --- a/src/main/java/keystrokesmod/event/SendAllPacketsEvent.java +++ b/src/main/java/keystrokesmod/event/SendAllPacketsEvent.java @@ -1,18 +1,18 @@ -package keystrokesmod.event; - -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class SendAllPacketsEvent extends Event { - private Packet packet; - - public SendAllPacketsEvent(Packet packet) { - this.packet = packet; - } - - public Packet getPacket() { - return packet; - } -} +package keystrokesmod.event; + +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class SendAllPacketsEvent extends Event { + private Packet packet; + + public SendAllPacketsEvent(Packet packet) { + this.packet = packet; + } + + public Packet getPacket() { + return packet; + } +} diff --git a/src/main/java/keystrokesmod/event/SendPacketEvent.java b/src/main/java/keystrokesmod/event/SendPacketEvent.java index 37f1c9c..abba9a2 100644 --- a/src/main/java/keystrokesmod/event/SendPacketEvent.java +++ b/src/main/java/keystrokesmod/event/SendPacketEvent.java @@ -1,18 +1,18 @@ -package keystrokesmod.event; - -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class SendPacketEvent extends Event { - private Packet packet; - - public SendPacketEvent(Packet packet) { - this.packet = packet; - } - - public Packet getPacket() { - return packet; - } +package keystrokesmod.event; + +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class SendPacketEvent extends Event { + private Packet packet; + + public SendPacketEvent(Packet packet) { + this.packet = packet; + } + + public Packet getPacket() { + return packet; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/event/SlotUpdateEvent.java b/src/main/java/keystrokesmod/event/SlotUpdateEvent.java index 0e6c105..f6a4c79 100644 --- a/src/main/java/keystrokesmod/event/SlotUpdateEvent.java +++ b/src/main/java/keystrokesmod/event/SlotUpdateEvent.java @@ -1,13 +1,13 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class SlotUpdateEvent extends Event { - public int slot; - - public SlotUpdateEvent(int slot) { - this.slot = slot; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class SlotUpdateEvent extends Event { + public int slot; + + public SlotUpdateEvent(int slot) { + this.slot = slot; + } +} diff --git a/src/main/java/keystrokesmod/event/StepHeightEvent.java b/src/main/java/keystrokesmod/event/StepHeightEvent.java index a815a8f..b99c343 100644 --- a/src/main/java/keystrokesmod/event/StepHeightEvent.java +++ b/src/main/java/keystrokesmod/event/StepHeightEvent.java @@ -1,14 +1,14 @@ -package keystrokesmod.event; - -import net.minecraft.entity.Entity; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class StepHeightEvent extends Event { - public Entity entity; - public float stepHeight; - - public StepHeightEvent(Entity entity, float stepHeight) { - this.entity = entity; - this.stepHeight = stepHeight; - } -} +package keystrokesmod.event; + +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class StepHeightEvent extends Event { + public Entity entity; + public float stepHeight; + + public StepHeightEvent(Entity entity, float stepHeight) { + this.entity = entity; + this.stepHeight = stepHeight; + } +} diff --git a/src/main/java/keystrokesmod/event/StrafeEvent.java b/src/main/java/keystrokesmod/event/StrafeEvent.java index 98d6a23..82960e3 100644 --- a/src/main/java/keystrokesmod/event/StrafeEvent.java +++ b/src/main/java/keystrokesmod/event/StrafeEvent.java @@ -1,49 +1,49 @@ -package keystrokesmod.event; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class StrafeEvent extends Event { - private float forward; - private float strafe; - private float friction; - private float yaw; - - public StrafeEvent(float strafe, float forward, float friction, float yaw) { - this.strafe = strafe; - this.forward = forward; - this.friction = friction; - this.yaw = yaw; - } - - public float getStrafe() { - return strafe; - } - - public void setStrafe(float strafe) { - this.strafe = strafe; - } - - public float getForward() { - return forward; - } - - public void setForward(float forward) { - this.forward = forward; - } - - public float getFriction() { - return friction; - } - - public void setFriction(float friction) { - this.friction = friction; - } - - public float getYaw() { - return yaw; - } - - public void setYaw(float yaw) { - this.yaw = yaw; - } -} +package keystrokesmod.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class StrafeEvent extends Event { + private float forward; + private float strafe; + private float friction; + private float yaw; + + public StrafeEvent(float strafe, float forward, float friction, float yaw) { + this.strafe = strafe; + this.forward = forward; + this.friction = friction; + this.yaw = yaw; + } + + public float getStrafe() { + return strafe; + } + + public void setStrafe(float strafe) { + this.strafe = strafe; + } + + public float getForward() { + return forward; + } + + public void setForward(float forward) { + this.forward = forward; + } + + public float getFriction() { + return friction; + } + + public void setFriction(float friction) { + this.friction = friction; + } + + public float getYaw() { + return yaw; + } + + public void setYaw(float yaw) { + this.yaw = yaw; + } +} diff --git a/src/main/java/keystrokesmod/event/UseItemEvent.java b/src/main/java/keystrokesmod/event/UseItemEvent.java index 626c26d..a67fb6f 100644 --- a/src/main/java/keystrokesmod/event/UseItemEvent.java +++ b/src/main/java/keystrokesmod/event/UseItemEvent.java @@ -1,12 +1,12 @@ -package keystrokesmod.event; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.Event; - -public class UseItemEvent extends Event { - public ItemStack usedItemStack; - - public UseItemEvent(ItemStack usedItemStack) { - this.usedItemStack = usedItemStack; - } -} +package keystrokesmod.event; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class UseItemEvent extends Event { + public ItemStack usedItemStack; + + public UseItemEvent(ItemStack usedItemStack) { + this.usedItemStack = usedItemStack; + } +} diff --git a/src/main/java/keystrokesmod/helper/DebugHelper.java b/src/main/java/keystrokesmod/helper/DebugHelper.java index 2e70c9a..8598b67 100644 --- a/src/main/java/keystrokesmod/helper/DebugHelper.java +++ b/src/main/java/keystrokesmod/helper/DebugHelper.java @@ -1,31 +1,31 @@ -package keystrokesmod.helper; - -import keystrokesmod.Raven; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -public class DebugHelper { - private static Minecraft mc = Minecraft.getMinecraft(); - public static boolean MIXIN; // for debugging mixin related - public static boolean BACKGROUND; // background processes like cache clearing and such - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Raven.debug || ev.phase != TickEvent.Phase.END || !Utils.nullCheck()) { - return; - } - if (mc.currentScreen == null) { - RenderUtils.renderBPS(true, true); - } - } - - public static void debugMixin(Object obj, String message) { - if (!MIXIN) { - return; - } - Utils.sendMessage("&d" + obj.getClass().getSimpleName() + "&7: " + message); - } -} +package keystrokesmod.helper; + +import keystrokesmod.Raven; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class DebugHelper { + private static Minecraft mc = Minecraft.getMinecraft(); + public static boolean MIXIN; // for debugging mixin related + public static boolean BACKGROUND; // background processes like cache clearing and such + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Raven.debug || ev.phase != TickEvent.Phase.END || !Utils.nullCheck()) { + return; + } + if (mc.currentScreen == null) { + RenderUtils.renderBPS(true, true); + } + } + + public static void debugMixin(Object obj, String message) { + if (!MIXIN) { + return; + } + Utils.sendMessage("&d" + obj.getClass().getSimpleName() + "&7: " + message); + } +} diff --git a/src/main/java/keystrokesmod/helper/RotationHelper.java b/src/main/java/keystrokesmod/helper/RotationHelper.java index b2ef478..6cbd264 100644 --- a/src/main/java/keystrokesmod/helper/RotationHelper.java +++ b/src/main/java/keystrokesmod/helper/RotationHelper.java @@ -1,151 +1,151 @@ -package keystrokesmod.helper; - -import keystrokesmod.event.*; -import keystrokesmod.module.impl.client.Settings; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.util.MathHelper; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class RotationHelper { - - private static RotationHelper INSTANCE = new RotationHelper(); - - private Float serverYaw = null; - private Float serverPitch = null; - - private boolean setRotations = false; // When set to true will tell the client that it will need to apply rotation and fixes in the current tick - - public boolean forceMovementFix = false; - - private Minecraft mc = Minecraft.getMinecraft(); - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPreUpdate(PreUpdateEvent e) { - ClientRotationEvent event = new ClientRotationEvent(this.serverYaw, this.serverPitch); - - MinecraftForge.EVENT_BUS.post(event); - - if (event.yaw != null && !event.yaw.isNaN()) { - this.serverYaw = event.yaw; - this.setRotations = true; - } - if (event.pitch != null && !event.pitch.isNaN()) { - this.serverPitch = event.pitch; - this.setRotations = true; - } - } - - @SubscribeEvent - public void onPreMotion(PreMotionEvent e) { - if (!this.setRotations) { - return; - } - if (this.serverYaw != null && !this.serverYaw.isNaN()) e.setYaw(this.serverYaw); - if (this.serverPitch != null && !this.serverPitch.isNaN()) e.setPitch(this.serverPitch); - } - - @SubscribeEvent - public void onRunTick(GameTickEvent e) { - this.serverYaw = this.serverPitch = null; - this.setRotations = this.forceMovementFix = false; - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPostInput(PostPlayerInputEvent event) { - if (!fixMovement()) { - return; - } - - float sneakMultiplier = mc.thePlayer.movementInput.sneak ? 0.3F : 1F; - - float yaw = this.serverYaw; - float forward = mc.thePlayer.movementInput.moveForward; - float strafe = mc.thePlayer.movementInput.moveStrafe; - - if (forward == 0 && strafe == 0) { - return; - } - - double angle = MathHelper.wrapAngleTo180_double(Math.toDegrees(getDirection(mc.thePlayer.rotationYaw, forward, strafe))); - - float closestForward = 0, closestStrafe = 0, closestDifference = Float.MAX_VALUE; - - for (float pfRaw = -1F; pfRaw <= 1F; pfRaw += 1F) { - for (float psRaw = -1F; psRaw <= 1F; psRaw += 1F) { - if (pfRaw == 0 && psRaw == 0) { - continue; - } - - float predictedForward = pfRaw * sneakMultiplier; - float predictedStrafe = psRaw * sneakMultiplier; - - double predictedAngle = MathHelper.wrapAngleTo180_double(Math.toDegrees(getDirection(yaw, predictedForward, predictedStrafe))); - double difference = Math.abs(angle - predictedAngle); - - if (difference < closestDifference) { - closestDifference = (float) difference; - closestForward = predictedForward; - closestStrafe = predictedStrafe; - } - } - } - - mc.thePlayer.movementInput.moveForward = closestForward; - mc.thePlayer.movementInput.moveStrafe = closestStrafe; - } - - @SubscribeEvent - public void onStrafe(StrafeEvent e) { - if (fixMovement()) { - e.setYaw(this.serverYaw); - } - } - - @SubscribeEvent - public void onJump(JumpEvent e) { - if (fixMovement()) { - e.setYaw(this.serverYaw); - } - } - - private boolean fixMovement() { - return ((Settings.movementFix != null && Settings.movementFix.isToggled()) || this.forceMovementFix) && this.setRotations; - } - - public static double getDirection(float rotationYaw, double moveForward, double moveStrafing) { - if (moveForward < 0F) rotationYaw += 180F; - - float forward = 1F; - - if (moveForward < 0F) forward = -0.5F; - else if (moveForward > 0F) forward = 0.5F; - - if (moveStrafing > 0F) rotationYaw -= 90F * forward; - if (moveStrafing < 0F) rotationYaw += 90F * forward; - - return Math.toRadians(rotationYaw); - } - - public static RotationHelper get() { - return INSTANCE; - } - - public void setRotations(float yaw, float pitch) { - this.serverYaw = yaw; - this.serverPitch = pitch; - this.setRotations = true; - } - - public void setYaw(float yaw) { - this.serverYaw = yaw; - this.setRotations = true; - } - - public void setPitch(float pitch) { - this.serverPitch = pitch; - this.setRotations = true; - } +package keystrokesmod.helper; + +import keystrokesmod.event.*; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class RotationHelper { + + private static RotationHelper INSTANCE = new RotationHelper(); + + private Float serverYaw = null; + private Float serverPitch = null; + + private boolean setRotations = false; // When set to true will tell the client that it will need to apply rotation and fixes in the current tick + + public boolean forceMovementFix = false; + + private Minecraft mc = Minecraft.getMinecraft(); + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPreUpdate(PreUpdateEvent e) { + ClientRotationEvent event = new ClientRotationEvent(this.serverYaw, this.serverPitch); + + MinecraftForge.EVENT_BUS.post(event); + + if (event.yaw != null && !event.yaw.isNaN()) { + this.serverYaw = event.yaw; + this.setRotations = true; + } + if (event.pitch != null && !event.pitch.isNaN()) { + this.serverPitch = event.pitch; + this.setRotations = true; + } + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent e) { + if (!this.setRotations) { + return; + } + if (this.serverYaw != null && !this.serverYaw.isNaN()) e.setYaw(this.serverYaw); + if (this.serverPitch != null && !this.serverPitch.isNaN()) e.setPitch(this.serverPitch); + } + + @SubscribeEvent + public void onRunTick(GameTickEvent e) { + this.serverYaw = this.serverPitch = null; + this.setRotations = this.forceMovementFix = false; + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPostInput(PostPlayerInputEvent event) { + if (!fixMovement()) { + return; + } + + float sneakMultiplier = mc.thePlayer.movementInput.sneak ? 0.3F : 1F; + + float yaw = this.serverYaw; + float forward = mc.thePlayer.movementInput.moveForward; + float strafe = mc.thePlayer.movementInput.moveStrafe; + + if (forward == 0 && strafe == 0) { + return; + } + + double angle = MathHelper.wrapAngleTo180_double(Math.toDegrees(getDirection(mc.thePlayer.rotationYaw, forward, strafe))); + + float closestForward = 0, closestStrafe = 0, closestDifference = Float.MAX_VALUE; + + for (float pfRaw = -1F; pfRaw <= 1F; pfRaw += 1F) { + for (float psRaw = -1F; psRaw <= 1F; psRaw += 1F) { + if (pfRaw == 0 && psRaw == 0) { + continue; + } + + float predictedForward = pfRaw * sneakMultiplier; + float predictedStrafe = psRaw * sneakMultiplier; + + double predictedAngle = MathHelper.wrapAngleTo180_double(Math.toDegrees(getDirection(yaw, predictedForward, predictedStrafe))); + double difference = Math.abs(angle - predictedAngle); + + if (difference < closestDifference) { + closestDifference = (float) difference; + closestForward = predictedForward; + closestStrafe = predictedStrafe; + } + } + } + + mc.thePlayer.movementInput.moveForward = closestForward; + mc.thePlayer.movementInput.moveStrafe = closestStrafe; + } + + @SubscribeEvent + public void onStrafe(StrafeEvent e) { + if (fixMovement()) { + e.setYaw(this.serverYaw); + } + } + + @SubscribeEvent + public void onJump(JumpEvent e) { + if (fixMovement()) { + e.setYaw(this.serverYaw); + } + } + + private boolean fixMovement() { + return ((Settings.movementFix != null && Settings.movementFix.isToggled()) || this.forceMovementFix) && this.setRotations; + } + + public static double getDirection(float rotationYaw, double moveForward, double moveStrafing) { + if (moveForward < 0F) rotationYaw += 180F; + + float forward = 1F; + + if (moveForward < 0F) forward = -0.5F; + else if (moveForward > 0F) forward = 0.5F; + + if (moveStrafing > 0F) rotationYaw -= 90F * forward; + if (moveStrafing < 0F) rotationYaw += 90F * forward; + + return Math.toRadians(rotationYaw); + } + + public static RotationHelper get() { + return INSTANCE; + } + + public void setRotations(float yaw, float pitch) { + this.serverYaw = yaw; + this.serverPitch = pitch; + this.setRotations = true; + } + + public void setYaw(float yaw) { + this.serverYaw = yaw; + this.setRotations = true; + } + + public void setPitch(float pitch) { + this.serverPitch = pitch; + this.setRotations = true; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/helper/ScaffoldBlockCountHelper.java b/src/main/java/keystrokesmod/helper/ScaffoldBlockCountHelper.java index 24bd977..1022f73 100644 --- a/src/main/java/keystrokesmod/helper/ScaffoldBlockCountHelper.java +++ b/src/main/java/keystrokesmod/helper/ScaffoldBlockCountHelper.java @@ -1,81 +1,81 @@ -package keystrokesmod.helper; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.Timer; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -public class ScaffoldBlockCountHelper { - private final Minecraft mc; - private Timer fadeTimer; - private Timer fadeInTimer; - private float previousAlpha; - - public ScaffoldBlockCountHelper(Minecraft mc) { - this.mc = mc; - this.fadeTimer = null; - (this.fadeInTimer = new Timer(150)).start(); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (previousAlpha <= 10 && fadeInTimer == null) { - onDisable(); - return; - } - if (!Utils.nullCheck() || !ModuleManager.scaffold.showBlockCount.isToggled()) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int blocks = ModuleManager.scaffold.totalBlocks(); - String color = "§"; - if (blocks <= 5) { - color += "c"; - } - else if (blocks <= 15) { - color += "6"; - } - else if (blocks <= 25) { - color += "e"; - } - else { - color = ""; - } - float alpha = fadeTimer == null ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); - if (fadeInTimer != null) { - alpha = fadeInTimer.getValueFloat(10, 255, 1); - if (alpha == 255) { - fadeInTimer = null; - } - } - previousAlpha = alpha; - int colorAlpha = Utils.mergeAlpha(-1, (int) previousAlpha); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRendererObj.drawStringWithShadow(color + blocks + " §rblock" + (blocks == 1 ? "" : "s"), scaledResolution.getScaledWidth()/2 + 8, scaledResolution.getScaledHeight()/2 + 4, colorAlpha); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - } - - public void beginFade() { - (this.fadeTimer = new Timer(150)).start(); - this.fadeInTimer = null; - } - - public void onDisable() { - MinecraftForge.EVENT_BUS.unregister(this); - fadeInTimer = null; - fadeTimer = null; - } -} +package keystrokesmod.helper; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.Timer; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +public class ScaffoldBlockCountHelper { + private final Minecraft mc; + private Timer fadeTimer; + private Timer fadeInTimer; + private float previousAlpha; + + public ScaffoldBlockCountHelper(Minecraft mc) { + this.mc = mc; + this.fadeTimer = null; + (this.fadeInTimer = new Timer(150)).start(); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (previousAlpha <= 10 && fadeInTimer == null) { + onDisable(); + return; + } + if (!Utils.nullCheck() || !ModuleManager.scaffold.showBlockCount.isToggled()) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int blocks = ModuleManager.scaffold.totalBlocks(); + String color = "§"; + if (blocks <= 5) { + color += "c"; + } + else if (blocks <= 15) { + color += "6"; + } + else if (blocks <= 25) { + color += "e"; + } + else { + color = ""; + } + float alpha = fadeTimer == null ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); + if (fadeInTimer != null) { + alpha = fadeInTimer.getValueFloat(10, 255, 1); + if (alpha == 255) { + fadeInTimer = null; + } + } + previousAlpha = alpha; + int colorAlpha = Utils.mergeAlpha(-1, (int) previousAlpha); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRendererObj.drawStringWithShadow(color + blocks + " §rblock" + (blocks == 1 ? "" : "s"), scaledResolution.getScaledWidth()/2 + 8, scaledResolution.getScaledHeight()/2 + 4, colorAlpha); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + + public void beginFade() { + (this.fadeTimer = new Timer(150)).start(); + this.fadeInTimer = null; + } + + public void onDisable() { + MinecraftForge.EVENT_BUS.unregister(this); + fadeInTimer = null; + fadeTimer = null; + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntity.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntity.java new file mode 100644 index 0000000..02fbe7d --- /dev/null +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntity.java @@ -0,0 +1,17 @@ +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Entity.class) +public interface IAccessorEntity { + @Accessor("fire") + int getFire(); + + @Accessor("nextStepDistance") + int getNextStepDistance(); + + @Accessor("isInWeb") + boolean getIsInWeb(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityArrow.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityArrow.java index 139de3e..e1bb029 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityArrow.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityArrow.java @@ -1,11 +1,11 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.entity.projectile.EntityArrow; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(EntityArrow.class) -public interface IAccessorEntityArrow { - @Accessor("inGround") - boolean getInGround(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.entity.projectile.EntityArrow; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(EntityArrow.class) +public interface IAccessorEntityArrow { + @Accessor("inGround") + boolean getInGround(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.java index 89e0c63..468496e 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityLivingBase.java @@ -1,14 +1,14 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@SideOnly(Side.CLIENT) -@Mixin(EntityLivingBase.class) -public interface IAccessorEntityLivingBase { - @Accessor("jumpTicks") - void setJumpTicks(int ticks); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.entity.EntityLivingBase; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(EntityLivingBase.class) +public interface IAccessorEntityLivingBase { + @Accessor("jumpTicks") + void setJumpTicks(int ticks); + + @Accessor("jumpTicks") + int getJumpTicks(); +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayer.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayer.java index ad2463b..526ced5 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayer.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayer.java @@ -1,14 +1,14 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@SideOnly(Side.CLIENT) -@Mixin(EntityPlayer.class) -public interface IAccessorEntityPlayer { - @Accessor("itemInUseCount") - void setItemInUseCount(int count); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@SideOnly(Side.CLIENT) +@Mixin(EntityPlayer.class) +public interface IAccessorEntityPlayer { + @Accessor("itemInUseCount") + void setItemInUseCount(int count); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP.java index a1530b8..7c328d3 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityPlayerSP.java @@ -1,25 +1,25 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraftforge.fml.relauncher.*; -import org.spongepowered.asm.mixin.*; -import net.minecraft.client.entity.*; -import org.spongepowered.asm.mixin.gen.*; - -@SideOnly(Side.CLIENT) -@Mixin(EntityPlayerSP.class) -public interface IAccessorEntityPlayerSP { - @Accessor("lastReportedPosX") - double getLastReportedPosX(); - - @Accessor("lastReportedPosY") - double getLastReportedPosY(); - - @Accessor("lastReportedPosZ") - double getLastReportedPosZ(); - - @Accessor("lastReportedYaw") - float getLastReportedYaw(); - - @Accessor("lastReportedPitch") - float getLastReportedPitch(); +package keystrokesmod.mixin.impl.accessor; + +import net.minecraftforge.fml.relauncher.*; +import org.spongepowered.asm.mixin.*; +import net.minecraft.client.entity.*; +import org.spongepowered.asm.mixin.gen.*; + +@SideOnly(Side.CLIENT) +@Mixin(EntityPlayerSP.class) +public interface IAccessorEntityPlayerSP { + @Accessor("lastReportedPosX") + double getLastReportedPosX(); + + @Accessor("lastReportedPosY") + double getLastReportedPosY(); + + @Accessor("lastReportedPosZ") + double getLastReportedPosZ(); + + @Accessor("lastReportedYaw") + float getLastReportedYaw(); + + @Accessor("lastReportedPitch") + float getLastReportedPitch(); } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer.java index 6291ceb..42ded67 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorEntityRenderer.java @@ -1,37 +1,37 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@SideOnly(Side.CLIENT) -@Mixin(EntityRenderer.class) -public interface IAccessorEntityRenderer { - @Invoker("setupCameraTransform") - void callSetupCameraTransform(float partialTicks, int pass); - - @Invoker("loadShader") - void callLoadShader(ResourceLocation resourceLocationIn); - - @Accessor("shaderResourceLocations") - ResourceLocation[] getShaderResourceLocations(); - - @Accessor("useShader") - boolean getUseShader(); - - @Accessor("useShader") - void setUseShader(boolean useShader); - - @Accessor("shaderIndex") - int getShaderIndex(); - - @Accessor("shaderIndex") - void setShaderIndex(int index); - - @Accessor("thirdPersonDistance") - void setThirdPersonDistance(float distance); +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@SideOnly(Side.CLIENT) +@Mixin(EntityRenderer.class) +public interface IAccessorEntityRenderer { + @Invoker("setupCameraTransform") + void callSetupCameraTransform(float partialTicks, int pass); + + @Invoker("loadShader") + void callLoadShader(ResourceLocation resourceLocationIn); + + @Accessor("shaderResourceLocations") + ResourceLocation[] getShaderResourceLocations(); + + @Accessor("useShader") + boolean getUseShader(); + + @Accessor("useShader") + void setUseShader(boolean useShader); + + @Accessor("shaderIndex") + int getShaderIndex(); + + @Accessor("shaderIndex") + void setShaderIndex(int index); + + @Accessor("thirdPersonDistance") + void setThirdPersonDistance(float distance); } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiIngame.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiIngame.java index 39961c7..c0dae68 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiIngame.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiIngame.java @@ -1,20 +1,20 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.gui.GuiIngame; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@SideOnly(Side.CLIENT) -@Mixin(GuiIngame.class) -public interface IAccessorGuiIngame { - @Accessor("recordPlaying") - String getRecordPlaying(); - - @Accessor("displayedTitle") - String getDisplayedTitle(); - - @Accessor("displayedSubTitle") - String getDisplayedSubTitle(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.gui.GuiIngame; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@SideOnly(Side.CLIENT) +@Mixin(GuiIngame.class) +public interface IAccessorGuiIngame { + @Accessor("recordPlaying") + String getRecordPlaying(); + + @Accessor("displayedTitle") + String getDisplayedTitle(); + + @Accessor("displayedSubTitle") + String getDisplayedSubTitle(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiPlayerTabOverlay.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiPlayerTabOverlay.java index e45721e..3f8812b 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiPlayerTabOverlay.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiPlayerTabOverlay.java @@ -1,18 +1,18 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.gui.GuiPlayerTabOverlay; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@SideOnly(Side.CLIENT) -@Mixin(GuiPlayerTabOverlay.class) -public interface IAccessorGuiPlayerTabOverlay { - @Accessor("header") - IChatComponent getHeader(); - - @Accessor("footer") - IChatComponent getFooter(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.gui.GuiPlayerTabOverlay; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@SideOnly(Side.CLIENT) +@Mixin(GuiPlayerTabOverlay.class) +public interface IAccessorGuiPlayerTabOverlay { + @Accessor("header") + IChatComponent getHeader(); + + @Accessor("footer") + IChatComponent getFooter(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java index 03e126b..841ed2f 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreen.java @@ -1,14 +1,14 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@SideOnly(Side.CLIENT) -@Mixin(GuiScreen.class) -public interface IAccessorGuiScreen { - @Invoker("mouseClicked") - void callMouseClicked(int mouseX, int mouseY, int mouseButton); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@SideOnly(Side.CLIENT) +@Mixin(GuiScreen.class) +public interface IAccessorGuiScreen { + @Invoker("mouseClicked") + void callMouseClicked(int mouseX, int mouseY, int mouseButton); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreenBook.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreenBook.java index ff6c30d..fe410ad 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreenBook.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorGuiScreenBook.java @@ -1,14 +1,14 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.gui.GuiScreenBook; -import net.minecraft.util.IChatComponent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(GuiScreenBook.class) -public interface IAccessorGuiScreenBook { - @Accessor("field_175386_A") - List getBookContents(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.gui.GuiScreenBook; +import net.minecraft.util.IChatComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.List; + +@Mixin(GuiScreenBook.class) +public interface IAccessorGuiScreenBook { + @Accessor("field_175386_A") + List getBookContents(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemFood.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemFood.java index 729b839..5fe1995 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemFood.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemFood.java @@ -1,14 +1,14 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.item.ItemFood; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@SideOnly(Side.CLIENT) -@Mixin(ItemFood.class) -public interface IAccessorItemFood { - @Accessor("alwaysEdible") - boolean getAlwaysEdible(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.item.ItemFood; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@SideOnly(Side.CLIENT) +@Mixin(ItemFood.class) +public interface IAccessorItemFood { + @Accessor("alwaysEdible") + boolean getAlwaysEdible(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemRenderer.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemRenderer.java index 59a07db..fffeb21 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemRenderer.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorItemRenderer.java @@ -1,11 +1,11 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.renderer.ItemRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ItemRenderer.class) -public interface IAccessorItemRenderer { - @Accessor("equippedProgress") - float getEquippedProgress(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.renderer.ItemRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ItemRenderer.class) +public interface IAccessorItemRenderer { + @Accessor("equippedProgress") + float getEquippedProgress(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorMinecraft.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorMinecraft.java index b6e1f85..04aab78 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorMinecraft.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorMinecraft.java @@ -1,35 +1,35 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.Minecraft; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.Timer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@SideOnly(Side.CLIENT) -@Mixin(Minecraft.class) -public interface IAccessorMinecraft { - @Accessor("timer") - Timer getTimer(); - - @Accessor("myNetworkManager") - NetworkManager getMyNetworkManager(); - - @Accessor("rightClickDelayTimer") - int getRightClickDelayTimer(); - - @Accessor("rightClickDelayTimer") - void setRightClickDelayTimer(int delay); - - @Accessor("leftClickCounter") - void setLeftClickCounter(int delay); - - @Invoker("rightClickMouse") - void callRightClickMouse(); - - @Invoker("clickMouse") - void callClickMouse(); +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.Minecraft; +import net.minecraft.network.NetworkManager; +import net.minecraft.util.Timer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@SideOnly(Side.CLIENT) +@Mixin(Minecraft.class) +public interface IAccessorMinecraft { + @Accessor("timer") + Timer getTimer(); + + @Accessor("myNetworkManager") + NetworkManager getMyNetworkManager(); + + @Accessor("rightClickDelayTimer") + int getRightClickDelayTimer(); + + @Accessor("rightClickDelayTimer") + void setRightClickDelayTimer(int delay); + + @Accessor("leftClickCounter") + void setLeftClickCounter(int delay); + + @Invoker("rightClickMouse") + void callRightClickMouse(); + + @Invoker("clickMouse") + void callClickMouse(); } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorNetworkManager.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorNetworkManager.java index 49a7648..88b6e5d 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorNetworkManager.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorNetworkManager.java @@ -1,12 +1,12 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.NetworkManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(NetworkManager.class) -public interface IAccessorNetworkManager { - @Accessor("packetListener") - INetHandler getPacketListener(); +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetworkManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(NetworkManager.class) +public interface IAccessorNetworkManager { + @Accessor("packetListener") + INetHandler getPacketListener(); } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorPlayerControllerMP.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorPlayerControllerMP.java index 845de18..07f4a5e 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorPlayerControllerMP.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorPlayerControllerMP.java @@ -1,25 +1,25 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraftforge.fml.relauncher.*; -import org.spongepowered.asm.mixin.*; -import net.minecraft.client.multiplayer.*; -import org.spongepowered.asm.mixin.gen.*; - -@SideOnly(Side.CLIENT) -@Mixin(PlayerControllerMP.class) -public interface IAccessorPlayerControllerMP { - @Accessor - float getCurBlockDamageMP(); - - @Accessor - void setCurBlockDamageMP(float damage); - - @Accessor - int getBlockHitDelay(); - - @Accessor - void setBlockHitDelay(int delay); - - @Invoker("syncCurrentPlayItem") - void syncCurrentPlayItem(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraftforge.fml.relauncher.*; +import org.spongepowered.asm.mixin.*; +import net.minecraft.client.multiplayer.*; +import org.spongepowered.asm.mixin.gen.*; + +@SideOnly(Side.CLIENT) +@Mixin(PlayerControllerMP.class) +public interface IAccessorPlayerControllerMP { + @Accessor + float getCurBlockDamageMP(); + + @Accessor + void setCurBlockDamageMP(float damage); + + @Accessor + int getBlockHitDelay(); + + @Accessor + void setBlockHitDelay(int delay); + + @Invoker("syncCurrentPlayItem") + void syncCurrentPlayItem(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorRenderManager.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorRenderManager.java index 45edaab..af4d814 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorRenderManager.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorRenderManager.java @@ -1,17 +1,17 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.client.renderer.entity.RenderManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(RenderManager.class) -public interface IAccessorRenderManager { - @Accessor("renderPosX") - double getRenderPosX(); - - @Accessor("renderPosY") - double getRenderPosY(); - - @Accessor("renderPosZ") - double getRenderPosZ(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.client.renderer.entity.RenderManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(RenderManager.class) +public interface IAccessorRenderManager { + @Accessor("renderPosX") + double getRenderPosX(); + + @Accessor("renderPosY") + double getRenderPosY(); + + @Accessor("renderPosZ") + double getRenderPosZ(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java index cb8f623..ed8fd19 100644 --- a/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java +++ b/src/main/java/keystrokesmod/mixin/impl/accessor/IAccessorS14PacketEntity.java @@ -1,11 +1,11 @@ -package keystrokesmod.mixin.impl.accessor; - -import net.minecraft.network.play.server.S14PacketEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(S14PacketEntity.class) -public interface IAccessorS14PacketEntity { - @Accessor("entityId") - int getEntityId(); -} +package keystrokesmod.mixin.impl.accessor; + +import net.minecraft.network.play.server.S14PacketEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(S14PacketEntity.class) +public interface IAccessorS14PacketEntity { + @Accessor("entityId") + int getEntityId(); +} diff --git a/src/main/java/keystrokesmod/mixin/impl/client/MixinGameSettings.java b/src/main/java/keystrokesmod/mixin/impl/client/MixinGameSettings.java index 01032b6..7f3c554 100644 --- a/src/main/java/keystrokesmod/mixin/impl/client/MixinGameSettings.java +++ b/src/main/java/keystrokesmod/mixin/impl/client/MixinGameSettings.java @@ -1,28 +1,23 @@ -package keystrokesmod.mixin.impl.client; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.player.Safewalk; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(GameSettings.class) -public class MixinGameSettings { - - @Overwrite - public static boolean isKeyDown(KeyBinding key) { - if (key == Minecraft.getMinecraft().gameSettings.keyBindSneak && ModuleManager.safeWalk != null) { - Safewalk safewalk = ModuleManager.safeWalk; - if (safewalk.isEnabled() && safewalk.isSneaking) { - return true; - } - } - return key.getKeyCode() == 0 ? false : (key.getKeyCode() < 0 ? Mouse.isButtonDown(key.getKeyCode() + 100) : Keyboard.isKeyDown(key.getKeyCode())); - } +package keystrokesmod.mixin.impl.client; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(GameSettings.class) +public class MixinGameSettings { + + @Overwrite + public static boolean isKeyDown(KeyBinding key) { + if (key == Minecraft.getMinecraft().gameSettings.keyBindSneak) { + if (Utils.sneakState) { + return true; + } + } + return key.getKeyCode() == 0 ? false : (key.getKeyCode() < 0 ? Mouse.isButtonDown(key.getKeyCode() + 100) : Keyboard.isKeyDown(key.getKeyCode())); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/client/MixinMinecraft.java b/src/main/java/keystrokesmod/mixin/impl/client/MixinMinecraft.java index 93004c9..95d3b33 100644 --- a/src/main/java/keystrokesmod/mixin/impl/client/MixinMinecraft.java +++ b/src/main/java/keystrokesmod/mixin/impl/client/MixinMinecraft.java @@ -1,69 +1,69 @@ -package keystrokesmod.mixin.impl.client; - -import keystrokesmod.event.*; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.objectweb.asm.Opcodes; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraftforge.common.MinecraftForge; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@SideOnly(Side.CLIENT) -@Mixin(Minecraft.class) -public class MixinMinecraft { - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", ordinal = 2)) - private void onRunTick(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new PreInputEvent()); - } - - @Inject(method = "runGameLoop", at = @At("HEAD")) - public void onRunGameLoop(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new RunGameLoopEvent()); - } - - @Inject(method = "runTick", at = @At("HEAD")) - public void onRunTickStart(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new GameTickEvent()); - } - - @Inject(method = "displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V", at = @At("HEAD")) - public void onDisplayGuiScreen(GuiScreen guiScreen, CallbackInfo ci) { - Minecraft mc = (Minecraft) (Object) this; - GuiScreen previousGui = mc.currentScreen; - GuiScreen setGui = guiScreen; - boolean opened = setGui != null; - if (!opened) { - setGui = previousGui; - } - - GuiUpdateEvent event = new GuiUpdateEvent(setGui, opened); - MinecraftForge.EVENT_BUS.post(event); - } - - @Redirect(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;changeCurrentItem(I)V")) - public void changeCurrentItem(InventoryPlayer inventoryPlayer, int slot) { - PreSlotScrollEvent event = new PreSlotScrollEvent(slot, inventoryPlayer.currentItem); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) { - return; - } - inventoryPlayer.changeCurrentItem(slot); - } - - @Redirect(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/InventoryPlayer;currentItem:I", opcode = Opcodes.PUTFIELD)) - private void onSetCurrentItem(InventoryPlayer inventoryPlayer, int slot) { - SlotUpdateEvent e = new SlotUpdateEvent(slot); - MinecraftForge.EVENT_BUS.post(e); - if (e.isCanceled()) { - return; - } - inventoryPlayer.currentItem = slot; - } -} +package keystrokesmod.mixin.impl.client; + +import keystrokesmod.event.*; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.objectweb.asm.Opcodes; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraftforge.common.MinecraftForge; +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@SideOnly(Side.CLIENT) +@Mixin(Minecraft.class) +public class MixinMinecraft { + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", ordinal = 2)) + private void onRunTick(CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new PreInputEvent()); + } + + @Inject(method = "runGameLoop", at = @At("HEAD")) + public void onRunGameLoop(CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new RunGameLoopEvent()); + } + + @Inject(method = "runTick", at = @At("HEAD")) + public void onRunTickStart(CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new GameTickEvent()); + } + + @Inject(method = "displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V", at = @At("HEAD")) + public void onDisplayGuiScreen(GuiScreen guiScreen, CallbackInfo ci) { + Minecraft mc = (Minecraft) (Object) this; + GuiScreen previousGui = mc.currentScreen; + GuiScreen setGui = guiScreen; + boolean opened = setGui != null; + if (!opened) { + setGui = previousGui; + } + + GuiUpdateEvent event = new GuiUpdateEvent(setGui, opened); + MinecraftForge.EVENT_BUS.post(event); + } + + @Redirect(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;changeCurrentItem(I)V")) + public void changeCurrentItem(InventoryPlayer inventoryPlayer, int slot) { + PreSlotScrollEvent event = new PreSlotScrollEvent(slot, inventoryPlayer.currentItem); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { + return; + } + inventoryPlayer.changeCurrentItem(slot); + } + + @Redirect(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/InventoryPlayer;currentItem:I", opcode = Opcodes.PUTFIELD)) + private void onSetCurrentItem(InventoryPlayer inventoryPlayer, int slot) { + SlotUpdateEvent e = new SlotUpdateEvent(slot); + MinecraftForge.EVENT_BUS.post(e); + if (e.isCanceled()) { + return; + } + inventoryPlayer.currentItem = slot; + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.java b/src/main/java/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.java index d90f68e..c3c32b6 100644 --- a/src/main/java/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.java +++ b/src/main/java/keystrokesmod/mixin/impl/client/MixinMovementInputFromOptions.java @@ -1,70 +1,71 @@ -package keystrokesmod.mixin.impl.client; - -import keystrokesmod.event.PostPlayerInputEvent; -import keystrokesmod.event.PrePlayerInputEvent; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.util.MovementInput; -import net.minecraft.util.MovementInputFromOptions; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@SideOnly(Side.CLIENT) -@Mixin(MovementInputFromOptions.class) -public class MixinMovementInputFromOptions extends MovementInput { - @Shadow - @Final - private GameSettings gameSettings; - - @Overwrite - public void updatePlayerMoveState() { - this.moveStrafe = 0.0F; - this.moveForward = 0.0F; - - if (this.gameSettings.keyBindForward.isKeyDown()) { - ++this.moveForward; - } - - if (this.gameSettings.keyBindBack.isKeyDown()) { - --this.moveForward; - } - - if (this.gameSettings.keyBindLeft.isKeyDown()) { - ++this.moveStrafe; - } - - if (this.gameSettings.keyBindRight.isKeyDown()) { - --this.moveStrafe; - } - - this.jump = this.gameSettings.keyBindJump.isKeyDown(); - this.sneak = this.gameSettings.keyBindSneak.isKeyDown(); - - PrePlayerInputEvent moveInputEvent = new PrePlayerInputEvent(moveForward, moveStrafe, jump, sneak, 0.3D); - - MinecraftForge.EVENT_BUS.post(moveInputEvent); - - double sneakMultiplier = moveInputEvent.getSneakSlowDownMultiplier(); - this.moveForward = moveInputEvent.getForward(); - this.moveStrafe = moveInputEvent.getStrafe(); - this.jump = moveInputEvent.isJump(); - this.sneak = moveInputEvent.isSneak(); - - if (this.sneak) { - this.moveStrafe = (float) ((double) this.moveStrafe * sneakMultiplier); - this.moveForward = (float) ((double) this.moveForward * sneakMultiplier); - } - } - - @Inject(method = "updatePlayerMoveState", at = @At("RETURN")) - private void onUpdatePlayerMoveState(CallbackInfo ci) { - MinecraftForge.EVENT_BUS.post(new PostPlayerInputEvent()); - } +package keystrokesmod.mixin.impl.client; + +import keystrokesmod.event.PostPlayerInputEvent; +import keystrokesmod.event.PrePlayerInputEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.MovementInput; +import net.minecraft.util.MovementInputFromOptions; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@SideOnly(Side.CLIENT) +@Mixin(MovementInputFromOptions.class) +public class MixinMovementInputFromOptions extends MovementInput { + @Shadow + @Final + private GameSettings gameSettings; + + @Overwrite + public void updatePlayerMoveState() { + this.moveStrafe = 0.0F; + this.moveForward = 0.0F; + + if (this.gameSettings.keyBindForward.isKeyDown()) { + ++this.moveForward; + } + + if (this.gameSettings.keyBindBack.isKeyDown()) { + --this.moveForward; + } + + if (this.gameSettings.keyBindLeft.isKeyDown()) { + ++this.moveStrafe; + } + + if (this.gameSettings.keyBindRight.isKeyDown()) { + --this.moveStrafe; + } + + this.jump = this.gameSettings.keyBindJump.isKeyDown(); + this.sneak = this.gameSettings.keyBindSneak.isKeyDown(); + + PrePlayerInputEvent moveInputEvent = new PrePlayerInputEvent(moveForward, moveStrafe, jump, sneak, 0.3D); + + MinecraftForge.EVENT_BUS.post(moveInputEvent); + + double sneakMultiplier = moveInputEvent.getSneakSlowDownMultiplier(); + this.moveForward = moveInputEvent.getForward(); + this.moveStrafe = moveInputEvent.getStrafe(); + this.jump = moveInputEvent.isJump(); + this.sneak = moveInputEvent.isSneak(); + + if (this.sneak) { + this.moveStrafe = (float) ((double) this.moveStrafe * sneakMultiplier); + this.moveForward = (float) ((double) this.moveForward * sneakMultiplier); + } + } + + @Inject(method = "updatePlayerMoveState", at = @At("RETURN")) + private void onUpdatePlayerMoveState(CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new PostPlayerInputEvent()); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/client/MixinPlayerControllerMP.java b/src/main/java/keystrokesmod/mixin/impl/client/MixinPlayerControllerMP.java index cbc088d..b76d089 100644 --- a/src/main/java/keystrokesmod/mixin/impl/client/MixinPlayerControllerMP.java +++ b/src/main/java/keystrokesmod/mixin/impl/client/MixinPlayerControllerMP.java @@ -1,36 +1,36 @@ -package keystrokesmod.mixin.impl.client; - -import keystrokesmod.event.AttackEvent; -import keystrokesmod.event.UseItemEvent; -import net.minecraft.client.multiplayer.PlayerControllerMP; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(PlayerControllerMP.class) -public class MixinPlayerControllerMP { - - @Inject(method = "sendUseItem(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD")) - public void injectUseItemEvent(EntityPlayer p_sendUseItem_1_, World p_sendUseItem_2_, ItemStack p_sendUseItem_3_, CallbackInfoReturnable ci) { - MinecraftForge.EVENT_BUS.post(new UseItemEvent(p_sendUseItem_3_)); - } - - @Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true) - private void injectAttackEntity(EntityPlayer playerIn, Entity targetEntity, CallbackInfo callbackInfo) { - AttackEvent event = new AttackEvent(targetEntity, playerIn); - - MinecraftForge.EVENT_BUS.post(event); - - if (event.isCanceled()) { - callbackInfo.cancel(); - } - } - -} +package keystrokesmod.mixin.impl.client; + +import keystrokesmod.event.AttackEvent; +import keystrokesmod.event.UseItemEvent; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +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; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerControllerMP.class) +public class MixinPlayerControllerMP { + + @Inject(method = "sendUseItem(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD")) + public void injectUseItemEvent(EntityPlayer p_sendUseItem_1_, World p_sendUseItem_2_, ItemStack p_sendUseItem_3_, CallbackInfoReturnable ci) { + MinecraftForge.EVENT_BUS.post(new UseItemEvent(p_sendUseItem_3_)); + } + + @Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true) + private void injectAttackEntity(EntityPlayer playerIn, Entity targetEntity, CallbackInfo callbackInfo) { + AttackEvent event = new AttackEvent(targetEntity, playerIn); + + MinecraftForge.EVENT_BUS.post(event); + + if (event.isCanceled()) { + callbackInfo.cancel(); + } + } + +} diff --git a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntity.java b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntity.java index 0159c8b..ad60ba5 100644 --- a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntity.java +++ b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntity.java @@ -1,97 +1,108 @@ -package keystrokesmod.mixin.impl.entity; - -import keystrokesmod.event.ClientLookEvent; -import keystrokesmod.event.StepHeightEvent; -import keystrokesmod.event.StrafeEvent; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.player.Safewalk; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; -import net.minecraftforge.common.MinecraftForge; -import org.spongepowered.asm.lib.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Entity.class) -public abstract class MixinEntity { - @Shadow - public double motionX; - @Shadow - public double motionZ; - @Shadow - public float rotationYaw; - - @ModifyVariable(method = "moveEntity", at = @At(value = "STORE", ordinal = 0), name = "flag") - private boolean injectSafeWalk(boolean flag) { - Entity entity = (Entity) (Object) this; - Minecraft mc = Minecraft.getMinecraft(); - - if (entity != null && entity == mc.thePlayer && entity.onGround) { - if (Safewalk.canSafeWalk() || (ModuleManager.scaffold != null && ModuleManager.scaffold.canSafewalk())) { - return true; - } - } - return flag; - } - - @Overwrite - public void moveFlying(float strafe, float forward, float friction) { - StrafeEvent strafeEvent = new StrafeEvent(strafe, forward, friction, this.rotationYaw); - if((Object) this == Minecraft.getMinecraft().thePlayer) { - MinecraftForge.EVENT_BUS.post(strafeEvent); - } - - strafe = strafeEvent.getStrafe(); - forward = strafeEvent.getForward(); - friction = strafeEvent.getFriction(); - float yaw = strafeEvent.getYaw(); - - float f = (strafe * strafe) + (forward * forward); - - if (f >= 1.0E-4F) { - f = MathHelper.sqrt_float(f); - if (f < 1.0F) { - f = 1.0F; - } - - f = friction / f; - strafe *= f; - forward *= f; - float f1 = MathHelper.sin(yaw * (float)Math.PI / 180.0F); - float f2 = MathHelper.cos(yaw * (float)Math.PI / 180.0F); - this.motionX += strafe * f2 - forward * f1; - this.motionZ += forward * f2 + strafe * f1; - } - } - - @Redirect(method = "moveEntity", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;stepHeight:F", opcode = Opcodes.GETFIELD, ordinal = 0)) - private float redirectStepHeight(Entity instance) { - StepHeightEvent stepHeightEvent = new StepHeightEvent(instance, instance.stepHeight); - MinecraftForge.EVENT_BUS.post(stepHeightEvent); - return stepHeightEvent.stepHeight; - } - - @Overwrite - protected final Vec3 getVectorForRotation(float pitch, float yaw) { - - ClientLookEvent event = new ClientLookEvent(yaw, pitch); - - MinecraftForge.EVENT_BUS.post(event); - - pitch = event.pitch; - yaw = event.yaw; - - float f = MathHelper.cos(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); - float f1 = MathHelper.sin(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); - float f2 = -MathHelper.cos(-pitch * ((float)Math.PI / 180F)); - float f3 = MathHelper.sin(-pitch * ((float)Math.PI / 180F)); - - return new Vec3(f1 * f2, f3, f * f2); - } +package keystrokesmod.mixin.impl.entity; + +import keystrokesmod.event.ClientLookEvent; +import keystrokesmod.event.PlayerMoveEvent; +import keystrokesmod.event.StepHeightEvent; +import keystrokesmod.event.StrafeEvent; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.player.Safewalk; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraftforge.common.MinecraftForge; +import org.spongepowered.asm.lib.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Entity.class) +public abstract class MixinEntity { + @Shadow + public double motionX; + @Shadow + public double motionZ; + @Shadow + public float rotationYaw; + + @ModifyVariable(method = "moveEntity", at = @At(value = "STORE", ordinal = 0), name = "flag") + private boolean injectSafeWalk(boolean flag) { + Entity entity = (Entity) (Object) this; + Minecraft mc = Minecraft.getMinecraft(); + + if (entity != null && entity == mc.thePlayer && entity.onGround) { + if (Safewalk.canSafeWalk() || (ModuleManager.scaffold != null && ModuleManager.scaffold.canSafewalk())) { + return true; + } + } + return flag; + } + + @Overwrite + public void moveFlying(float strafe, float forward, float friction) { + StrafeEvent strafeEvent = new StrafeEvent(strafe, forward, friction, this.rotationYaw); + if((Object) this == Minecraft.getMinecraft().thePlayer) { + MinecraftForge.EVENT_BUS.post(strafeEvent); + } + + strafe = strafeEvent.getStrafe(); + forward = strafeEvent.getForward(); + friction = strafeEvent.getFriction(); + float yaw = strafeEvent.getYaw(); + + float f = (strafe * strafe) + (forward * forward); + + if (f >= 1.0E-4F) { + f = MathHelper.sqrt_float(f); + if (f < 1.0F) { + f = 1.0F; + } + + f = friction / f; + strafe *= f; + forward *= f; + float f1 = MathHelper.sin(yaw * (float)Math.PI / 180.0F); + float f2 = MathHelper.cos(yaw * (float)Math.PI / 180.0F); + this.motionX += strafe * f2 - forward * f1; + this.motionZ += forward * f2 + strafe * f1; + } + } + + @Redirect(method = "moveEntity", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;stepHeight:F", opcode = Opcodes.GETFIELD, ordinal = 0)) + private float redirectStepHeight(Entity instance) { + StepHeightEvent stepHeightEvent = new StepHeightEvent(instance, instance.stepHeight); + MinecraftForge.EVENT_BUS.post(stepHeightEvent); + return stepHeightEvent.stepHeight; + } + + @Overwrite + protected final Vec3 getVectorForRotation(float pitch, float yaw) { + + ClientLookEvent event = new ClientLookEvent(yaw, pitch); + + MinecraftForge.EVENT_BUS.post(event); + + pitch = event.pitch; + yaw = event.yaw; + + float f = MathHelper.cos(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); + float f1 = MathHelper.sin(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); + float f2 = -MathHelper.cos(-pitch * ((float)Math.PI / 180F)); + float f3 = MathHelper.sin(-pitch * ((float)Math.PI / 180F)); + + return new Vec3(f1 * f2, f3, f * f2); + } + + @Inject(method = "moveEntity", at = @At("HEAD")) + private void injectPlayerMoveEvent(double x, double y, double z, CallbackInfo ci) { + if (((Object) this) instanceof EntityPlayerSP) { + MinecraftForge.EVENT_BUS.post(new PlayerMoveEvent(x, y, z)); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.java b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.java index 8d5dc30..c313c72 100644 --- a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.java +++ b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityLivingBase.java @@ -1,127 +1,144 @@ -package keystrokesmod.mixin.impl.entity; - -import com.google.common.collect.Maps; -import keystrokesmod.event.JumpEvent; -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.client.Settings; -import keystrokesmod.utility.RotationUtils; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -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.Map; - -@Mixin(EntityLivingBase.class) -public abstract class MixinEntityLivingBase extends Entity { - public MixinEntityLivingBase(World worldIn) { - super(worldIn); - } - - private final Map activePotionsMap = Maps.newHashMap(); - - @Shadow - public PotionEffect getActivePotionEffect(Potion potionIn) { - return this.activePotionsMap.get(Integer.valueOf(potionIn.id)); - } - - @Shadow - public boolean isPotionActive(Potion potionIn) { - return this.activePotionsMap.containsKey(Integer.valueOf(potionIn.id)); - } - - @Shadow - public float rotationYawHead; - - @Shadow - public float renderYawOffset; - - @Shadow - public float swingProgress; - - @Inject(method = { "updateDistance", "func_110146_f" }, at = @At("HEAD"), cancellable = true) - protected void injectUpdateDistance(float p_110146_1_, float p_110146_2_, CallbackInfoReturnable cir) { - float rotationYaw = this.rotationYaw; - if (Settings.fullBody != null && Settings.rotateBody != null && !Settings.fullBody.isToggled() && Settings.rotateBody.isToggled() && (EntityLivingBase) (Object) this instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { - if (this.swingProgress > 0F) { - p_110146_1_ = RotationUtils.renderYaw; - } - rotationYaw = RotationUtils.renderYaw; - rotationYawHead = RotationUtils.renderYaw; - } - - float f = MathHelper.wrapAngleTo180_float(p_110146_1_ - this.renderYawOffset); - this.renderYawOffset += f * 0.3F; - float f1 = MathHelper.wrapAngleTo180_float(rotationYaw - this.renderYawOffset); - boolean flag = f1 < 90.0F || f1 >= 90.0F; - - if (f1 < -75.0F) { - f1 = -75.0F; - } - - if (f1 >= 75.0F) { - f1 = 75.0F; - } - - this.renderYawOffset = rotationYaw - f1; - - if (f1 * f1 > 2500.0F) { - this.renderYawOffset += f1 * 0.2F; - } - - if (flag) { - p_110146_2_ *= -1.0F; - } - - cir.setReturnValue(p_110146_2_); - } - - @Shadow - protected float getJumpUpwardsMotion() { - return 0.42F; - } - - @Overwrite - protected void jump() { - JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion(), this.rotationYaw, this.isSprinting()); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(jumpEvent); - if (jumpEvent.isCanceled()) { - return; - } - - this.motionY = jumpEvent.getMotionY(); - - if (this.isPotionActive(Potion.jump)) { - this.motionY += (float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; - } - - if (jumpEvent.applySprint()) { - float f = jumpEvent.getYaw() * 0.017453292F; - this.motionX -= MathHelper.sin(f) * 0.2F; - this.motionZ += MathHelper.cos(f) * 0.2F; - } - - this.isAirBorne = true; - ForgeHooks.onLivingJump(((EntityLivingBase) (Object) this)); - } - - @Inject(method = "isPotionActive(Lnet/minecraft/potion/Potion;)Z", at = @At("HEAD"), cancellable = true) - private void isPotionActive(Potion p_isPotionActive_1_, final CallbackInfoReturnable callbackInfoReturnable) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.isEnabled() && ((p_isPotionActive_1_ == Potion.confusion && ModuleManager.antiDebuff.removeNausea.isToggled()) || (p_isPotionActive_1_ == Potion.blindness && ModuleManager.antiDebuff.removeBlindness.isToggled()))) { - if (ModuleManager.antiDebuff.removeSideEffects.isToggled()) { - callbackInfoReturnable.setReturnValue(false); - } - } - } +package keystrokesmod.mixin.impl.entity; + +import com.google.common.collect.Maps; +import keystrokesmod.event.JumpEvent; +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PrePlayerMovementInputEvent; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.utility.RotationUtils; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Map; + +@Mixin(EntityLivingBase.class) +public abstract class MixinEntityLivingBase extends Entity { + public MixinEntityLivingBase(World worldIn) { + super(worldIn); + } + + private final Map activePotionsMap = Maps.newHashMap(); + + @Shadow + public PotionEffect getActivePotionEffect(Potion potionIn) { + return this.activePotionsMap.get(Integer.valueOf(potionIn.id)); + } + + @Shadow + public boolean isPotionActive(Potion potionIn) { + return this.activePotionsMap.containsKey(Integer.valueOf(potionIn.id)); + } + + @Shadow + public float rotationYawHead; + + @Shadow + public float renderYawOffset; + + @Shadow + public float swingProgress; + + @Inject(method = { "updateDistance", "func_110146_f" }, at = @At("HEAD"), cancellable = true) + protected void injectUpdateDistance(float p_110146_1_, float p_110146_2_, CallbackInfoReturnable cir) { + float rotationYaw = this.rotationYaw; + if (Settings.fullBody != null && Settings.rotateBody != null && !Settings.fullBody.isToggled() && Settings.rotateBody.isToggled() && (EntityLivingBase) (Object) this instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { + if (this.swingProgress > 0F) { + p_110146_1_ = RotationUtils.renderYaw; + } + rotationYaw = RotationUtils.renderYaw; + rotationYawHead = RotationUtils.renderYaw; + } + + float f = MathHelper.wrapAngleTo180_float(p_110146_1_ - this.renderYawOffset); + this.renderYawOffset += f * 0.3F; + float f1 = MathHelper.wrapAngleTo180_float(rotationYaw - this.renderYawOffset); + boolean flag = f1 < 90.0F || f1 >= 90.0F; + + if (f1 < -75.0F) { + f1 = -75.0F; + } + + if (f1 >= 75.0F) { + f1 = 75.0F; + } + + this.renderYawOffset = rotationYaw - f1; + + if (f1 * f1 > 2500.0F) { + this.renderYawOffset += f1 * 0.2F; + } + + if (flag) { + p_110146_2_ *= -1.0F; + } + + cir.setReturnValue(p_110146_2_); + } + + @Shadow + protected float getJumpUpwardsMotion() { + return 0.42F; + } + + @Overwrite + protected void jump() { + JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion(), this.rotationYaw, this.isSprinting()); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(jumpEvent); + if (jumpEvent.isCanceled()) { + return; + } + + this.motionY = jumpEvent.getMotionY(); + + if (this.isPotionActive(Potion.jump)) { + this.motionY += (float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; + } + + if (jumpEvent.applySprint()) { + float f = jumpEvent.getYaw() * 0.017453292F; + this.motionX -= MathHelper.sin(f) * 0.2F; + this.motionZ += MathHelper.cos(f) * 0.2F; + } + + this.isAirBorne = true; + ForgeHooks.onLivingJump(((EntityLivingBase) (Object) this)); + } + + @Inject(method = "isPotionActive(Lnet/minecraft/potion/Potion;)Z", at = @At("HEAD"), cancellable = true) + private void isPotionActive(Potion p_isPotionActive_1_, final CallbackInfoReturnable callbackInfoReturnable) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.isEnabled() && ((p_isPotionActive_1_ == Potion.confusion && ModuleManager.antiDebuff.removeNausea.isToggled()) || (p_isPotionActive_1_ == Potion.blindness && ModuleManager.antiDebuff.removeBlindness.isToggled()))) { + if (ModuleManager.antiDebuff.removeSideEffects.isToggled()) { + callbackInfoReturnable.setReturnValue(false); + } + } + } + + @Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;moveEntityWithHeading(FF)V")) + private void onMoveEntityWithHeadingRedirect(EntityLivingBase self, float originalStrafing, float originalForward) { + if (self instanceof EntityPlayerSP) { + PrePlayerMovementInputEvent event = new PrePlayerMovementInputEvent(originalForward, originalStrafing); + + MinecraftForge.EVENT_BUS.post(event); + + self.moveEntityWithHeading(event.strafe, event.forward); + } + else { + self.moveEntityWithHeading(originalStrafing, originalForward); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.java b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.java index 38444c2..c46be03 100644 --- a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.java +++ b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayer.java @@ -1,184 +1,177 @@ -package keystrokesmod.mixin.impl.entity; - -import keystrokesmod.event.StepHeightEvent; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.Reduce; -import keystrokesmod.module.impl.movement.KeepSprint; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.*; -import net.minecraft.entity.boss.EntityDragonPart; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.potion.Potion; -import net.minecraft.stats.AchievementList; -import net.minecraft.stats.StatBase; -import net.minecraft.stats.StatList; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; -import org.spongepowered.asm.lib.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(EntityPlayer.class) -public abstract class MixinEntityPlayer extends EntityLivingBase { - public MixinEntityPlayer(World p_i1594_1_) { - super(p_i1594_1_); - } - - @Shadow - public abstract ItemStack getHeldItem(); - - @Shadow - public abstract void onCriticalHit(Entity p_onCriticalHit_1_); - - @Shadow - public abstract void onEnchantmentCritical(Entity p_onEnchantmentCritical_1_); - - @Shadow - public abstract void triggerAchievement(StatBase p_triggerAchievement_1_); - - @Shadow - public abstract ItemStack getCurrentEquippedItem(); - - @Shadow - public abstract void destroyCurrentEquippedItem(); - - @Shadow - public abstract void addStat(StatBase p_addStat_1_, int p_addStat_2_); - - @Shadow - public abstract void addExhaustion(float p_addExhaustion_1_); - - @Overwrite - public void attackTargetEntityWithCurrentItem(Entity targetEntity) { - if (ForgeHooks.onPlayerAttackTarget(((EntityPlayer) (Object) this), targetEntity)) { - if (targetEntity.canAttackWithItem() && !targetEntity.hitByEntity(this)) { - float f = (float) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - int i = 0; - float f1 = 0.0F; - if (targetEntity instanceof EntityLivingBase) { - f1 = EnchantmentHelper.getModifierForCreature(this.getHeldItem(), ((EntityLivingBase) targetEntity).getCreatureAttribute()); - } else { - f1 = EnchantmentHelper.getModifierForCreature(this.getHeldItem(), EnumCreatureAttribute.UNDEFINED); - } - - i += EnchantmentHelper.getKnockbackModifier(this); - if (this.isSprinting()) { - ++i; - } - - if (f > 0.0F || f1 > 0.0F) { - boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && targetEntity instanceof EntityLivingBase; - if (flag && f > 0.0F) { - f *= 1.5F; - } - - f += f1; - boolean flag1 = false; - int j = EnchantmentHelper.getFireAspectModifier(this); - if (targetEntity instanceof EntityLivingBase && j > 0 && !targetEntity.isBurning()) { - flag1 = true; - targetEntity.setFire(1); - } - - double d0 = targetEntity.motionX; - double d1 = targetEntity.motionY; - double d2 = targetEntity.motionZ; - boolean flag2 = targetEntity.attackEntityFrom(DamageSource.causePlayerDamage(((EntityPlayer) (Object) this)), f); - if (flag2) { - if (i > 0) { - targetEntity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1, (double) (MathHelper.cos(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); - if (ModuleManager.reduce != null && ModuleManager.reduce.isEnabled()) { - Reduce.reduce(targetEntity); - } - else if (ModuleManager.keepSprint != null && ModuleManager.keepSprint.isEnabled()) { - KeepSprint.keepSprint(targetEntity); - } - else { - this.motionX *= 0.6D; - this.motionZ *= 0.6D; - this.setSprinting(false); - } - } - - if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) { - ((EntityPlayerMP) targetEntity).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(targetEntity)); - targetEntity.velocityChanged = false; - targetEntity.motionX = d0; - targetEntity.motionY = d1; - targetEntity.motionZ = d2; - } - - if (flag) { - this.onCriticalHit(targetEntity); - } - - if (f1 > 0.0F) { - this.onEnchantmentCritical(targetEntity); - } - - if (f >= 18.0F) { - this.triggerAchievement(AchievementList.overkill); - } - - this.setLastAttacker(targetEntity); - if (targetEntity instanceof EntityLivingBase) { - EnchantmentHelper.applyThornEnchantments((EntityLivingBase) targetEntity, this); - } - - EnchantmentHelper.applyArthropodEnchantments(this, targetEntity); - ItemStack itemstack = this.getCurrentEquippedItem(); - Entity entity = targetEntity; - if (targetEntity instanceof EntityDragonPart) { - IEntityMultiPart ientitymultipart = ((EntityDragonPart) targetEntity).entityDragonObj; - if (ientitymultipart instanceof EntityLivingBase) { - entity = (EntityLivingBase) ientitymultipart; - } - } - - if (itemstack != null && entity instanceof EntityLivingBase) { - itemstack.hitEntity((EntityLivingBase) entity, ((EntityPlayer) (Object) this)); - if (itemstack.stackSize <= 0) { - this.destroyCurrentEquippedItem(); - } - } - - if (targetEntity instanceof EntityLivingBase) { - this.addStat(StatList.damageDealtStat, Math.round(f * 10.0F)); - if (j > 0) { - targetEntity.setFire(j * 4); - } - } - - this.addExhaustion(0.3F); - } else if (flag1) { - targetEntity.extinguish(); - } - } - } - - } - } - - @Inject(method = "isBlocking", at = @At("RETURN"), cancellable = true) - private void isBlocking(CallbackInfoReturnable cir) { - if (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingClient && ((Object) this) == Minecraft.getMinecraft().thePlayer) { - cir.setReturnValue(true); - } - cir.setReturnValue(cir.getReturnValue()); - } +package keystrokesmod.mixin.impl.entity; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.Reduce; +import keystrokesmod.module.impl.movement.KeepSprint; +import net.minecraft.client.Minecraft; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.*; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(EntityPlayer.class) +public abstract class MixinEntityPlayer extends EntityLivingBase { + public MixinEntityPlayer(World p_i1594_1_) { + super(p_i1594_1_); + } + + @Shadow + public abstract ItemStack getHeldItem(); + + @Shadow + public abstract void onCriticalHit(Entity p_onCriticalHit_1_); + + @Shadow + public abstract void onEnchantmentCritical(Entity p_onEnchantmentCritical_1_); + + @Shadow + public abstract void triggerAchievement(StatBase p_triggerAchievement_1_); + + @Shadow + public abstract ItemStack getCurrentEquippedItem(); + + @Shadow + public abstract void destroyCurrentEquippedItem(); + + @Shadow + public abstract void addStat(StatBase p_addStat_1_, int p_addStat_2_); + + @Shadow + public abstract void addExhaustion(float p_addExhaustion_1_); + + @Overwrite + public void attackTargetEntityWithCurrentItem(Entity targetEntity) { + if (ForgeHooks.onPlayerAttackTarget(((EntityPlayer) (Object) this), targetEntity)) { + if (targetEntity.canAttackWithItem() && !targetEntity.hitByEntity(this)) { + float f = (float) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + int i = 0; + float f1 = 0.0F; + if (targetEntity instanceof EntityLivingBase) { + f1 = EnchantmentHelper.getModifierForCreature(this.getHeldItem(), ((EntityLivingBase) targetEntity).getCreatureAttribute()); + } else { + f1 = EnchantmentHelper.getModifierForCreature(this.getHeldItem(), EnumCreatureAttribute.UNDEFINED); + } + + i += EnchantmentHelper.getKnockbackModifier(this); + if (this.isSprinting()) { + ++i; + } + + if (f > 0.0F || f1 > 0.0F) { + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && targetEntity instanceof EntityLivingBase; + if (flag && f > 0.0F) { + f *= 1.5F; + } + + f += f1; + boolean flag1 = false; + int j = EnchantmentHelper.getFireAspectModifier(this); + if (targetEntity instanceof EntityLivingBase && j > 0 && !targetEntity.isBurning()) { + flag1 = true; + targetEntity.setFire(1); + } + + double d0 = targetEntity.motionX; + double d1 = targetEntity.motionY; + double d2 = targetEntity.motionZ; + boolean flag2 = targetEntity.attackEntityFrom(DamageSource.causePlayerDamage(((EntityPlayer) (Object) this)), f); + if (flag2) { + if (i > 0) { + targetEntity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1, (double) (MathHelper.cos(this.rotationYaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); + if (ModuleManager.reduce != null && ModuleManager.reduce.isEnabled()) { + Reduce.reduce(targetEntity); + } + else if (ModuleManager.keepSprint != null && ModuleManager.keepSprint.isEnabled()) { + KeepSprint.keepSprint(targetEntity); + } + else { + this.motionX *= 0.6D; + this.motionZ *= 0.6D; + this.setSprinting(false); + } + } + + if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) { + ((EntityPlayerMP) targetEntity).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(targetEntity)); + targetEntity.velocityChanged = false; + targetEntity.motionX = d0; + targetEntity.motionY = d1; + targetEntity.motionZ = d2; + } + + if (flag) { + this.onCriticalHit(targetEntity); + } + + if (f1 > 0.0F) { + this.onEnchantmentCritical(targetEntity); + } + + if (f >= 18.0F) { + this.triggerAchievement(AchievementList.overkill); + } + + this.setLastAttacker(targetEntity); + if (targetEntity instanceof EntityLivingBase) { + EnchantmentHelper.applyThornEnchantments((EntityLivingBase) targetEntity, this); + } + + EnchantmentHelper.applyArthropodEnchantments(this, targetEntity); + ItemStack itemstack = this.getCurrentEquippedItem(); + Entity entity = targetEntity; + if (targetEntity instanceof EntityDragonPart) { + IEntityMultiPart ientitymultipart = ((EntityDragonPart) targetEntity).entityDragonObj; + if (ientitymultipart instanceof EntityLivingBase) { + entity = (EntityLivingBase) ientitymultipart; + } + } + + if (itemstack != null && entity instanceof EntityLivingBase) { + itemstack.hitEntity((EntityLivingBase) entity, ((EntityPlayer) (Object) this)); + if (itemstack.stackSize <= 0) { + this.destroyCurrentEquippedItem(); + } + } + + if (targetEntity instanceof EntityLivingBase) { + this.addStat(StatList.damageDealtStat, Math.round(f * 10.0F)); + if (j > 0) { + targetEntity.setFire(j * 4); + } + } + + this.addExhaustion(0.3F); + } else if (flag1) { + targetEntity.extinguish(); + } + } + } + + } + } + + @Inject(method = "isBlocking", at = @At("RETURN"), cancellable = true) + private void isBlocking(CallbackInfoReturnable cir) { + if ((ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingClient || ModuleManager.noSlow != null && ModuleManager.noSlow.isEnabled() && ModuleManager.noSlow.blockingClient) && ((Object) this) == Minecraft.getMinecraft().thePlayer) { + cir.setReturnValue(true); + } + cir.setReturnValue(cir.getReturnValue()); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.java b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.java index f30e7f4..4beff43 100644 --- a/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.java +++ b/src/main/java/keystrokesmod/mixin/impl/entity/MixinEntityPlayerSP.java @@ -1,352 +1,352 @@ -package keystrokesmod.mixin.impl.entity; - -import com.mojang.authlib.GameProfile; -import keystrokesmod.event.PostMotionEvent; -import keystrokesmod.event.PostUpdateEvent; -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.WTap; -import keystrokesmod.module.impl.movement.NoSlow; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.RotationUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.network.play.client.C0BPacketEntityAction; -import net.minecraft.potion.Potion; -import net.minecraft.util.*; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(EntityPlayerSP.class) -public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { - @Shadow - public int sprintingTicksLeft; - - public MixinEntityPlayerSP(World p_i45074_1_, GameProfile p_i45074_2_) { - super(p_i45074_1_, p_i45074_2_); - } - - @Override - @Shadow - public abstract void setSprinting(boolean p_setSprinting_1_); - @Shadow - protected int sprintToggleTimer; - @Shadow - public float prevTimeInPortal; - @Shadow - public float timeInPortal; - @Shadow - protected Minecraft mc; - @Shadow - public MovementInput movementInput; - @Override - @Shadow - public abstract void sendPlayerAbilities(); - @Shadow - protected abstract boolean isCurrentViewEntity(); - @Shadow - public abstract boolean isRidingHorse(); - @Shadow - private int horseJumpPowerCounter; - @Shadow - private float horseJumpPower; - @Shadow - protected abstract void sendHorseJump(); - @Shadow - private boolean serverSprintState; - @Shadow - @Final - public NetHandlerPlayClient sendQueue; - @Override - @Shadow - public abstract boolean isSneaking(); - @Shadow - private boolean serverSneakState; - @Shadow - private double lastReportedPosX; - @Shadow - private double lastReportedPosY; - @Shadow - private double lastReportedPosZ; - @Shadow - private float lastReportedYaw; - @Shadow - private float lastReportedPitch; - @Shadow - private int positionUpdateTicks; - - @Inject(method = "onUpdate", at = @At("HEAD")) - private void onUpdatePre(CallbackInfo c) { - if (this.worldObj.isBlockLoaded(new BlockPos(this.posX, 0.0, this.posZ))) { - RotationUtils.prevRenderPitch = RotationUtils.renderPitch; - RotationUtils.prevRenderYaw = RotationUtils.renderYaw; - - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PreUpdateEvent()); - } - } - - @Inject(method = "onUpdate", at = @At("RETURN")) - private void onUpdatePost(CallbackInfo c) { - if (this.worldObj.isBlockLoaded(new BlockPos(this.posX, 0.0, this.posZ))) { - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PostUpdateEvent()); - } - } - - @Overwrite - public void onUpdateWalkingPlayer() { - PreMotionEvent.setRotations = false; - PreMotionEvent.setRenderYaw(false); - RotationUtils.setFakeRotations = false; - PreMotionEvent preMotionEvent = new PreMotionEvent( - this.posX, - this.getEntityBoundingBox().minY, - this.posZ, - this.rotationYaw, - this.rotationPitch, - this.onGround, - this.isSprinting(), - this.isSneaking() - ); - - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(preMotionEvent); - - RotationUtils.serverRotations = new float[] { preMotionEvent.getYaw(), preMotionEvent.getPitch() }; - - boolean flag = preMotionEvent.isSprinting(); - if (flag != this.serverSprintState) { - if (flag) { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SPRINTING)); - } else { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SPRINTING)); - } - - this.serverSprintState = flag; - } - - boolean flag1 = preMotionEvent.isSneaking(); - if (flag1 != this.serverSneakState) { - if (flag1) { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SNEAKING)); - } else { - this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SNEAKING)); - } - - this.serverSneakState = flag1; - } - - if (this.isCurrentViewEntity()) { - if (PreMotionEvent.setRenderYaw()) { - RotationUtils.setRenderYaw(preMotionEvent.getYaw()); - } - - RotationUtils.renderPitch = preMotionEvent.getPitch(); - RotationUtils.renderYaw = preMotionEvent.getYaw(); - - if (RotationUtils.setFakeRotations) { - RotationUtils.renderPitch = RotationUtils.fakeRotations[1]; - RotationUtils.renderYaw = RotationUtils.fakeRotations[0]; - RotationUtils.setRenderYaw(RotationUtils.renderYaw); - } - RotationUtils.setFakeRotations = false; - - double d0 = preMotionEvent.getPosX() - this.lastReportedPosX; - double d1 = preMotionEvent.getPosY() - this.lastReportedPosY; - double d2 = preMotionEvent.getPosZ() - this.lastReportedPosZ; - double d3 = preMotionEvent.getYaw() - this.lastReportedYaw; - double d4 = preMotionEvent.getPitch() - this.lastReportedPitch; - boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4 || this.positionUpdateTicks >= 20; - boolean flag3 = d3 != 0.0 || d4 != 0.0; - if (this.ridingEntity == null) { - if (flag2 && flag3) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(preMotionEvent.getPosX(), preMotionEvent.getPosY(), preMotionEvent.getPosZ(), preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); - } else if (flag2) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(preMotionEvent.getPosX(), preMotionEvent.getPosY(), preMotionEvent.getPosZ(), preMotionEvent.isOnGround())); - } else if (flag3) { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); - } else { - this.sendQueue.addToSendQueue(new C03PacketPlayer(preMotionEvent.isOnGround())); - } - } else { - this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, this.motionZ, preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); - flag2 = false; - } - - ++this.positionUpdateTicks; - - if (flag2) { - this.lastReportedPosX = preMotionEvent.getPosX(); - this.lastReportedPosY = preMotionEvent.getPosY(); - this.lastReportedPosZ = preMotionEvent.getPosZ(); - this.positionUpdateTicks = 0; - } - - if (flag3) { - this.lastReportedYaw = preMotionEvent.getYaw(); - this.lastReportedPitch = preMotionEvent.getPitch(); - } - } - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PostMotionEvent()); - } - - @Overwrite - public void onLivingUpdate() { - if (this.sprintingTicksLeft > 0) { - --this.sprintingTicksLeft; - if (this.sprintingTicksLeft == 0) { - this.setSprinting(false); - } - } - - if (this.sprintToggleTimer > 0) { - --this.sprintToggleTimer; - } - - this.prevTimeInPortal = this.timeInPortal; - if (this.inPortal) { - if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) { - this.mc.displayGuiScreen(null); - } - - if (this.timeInPortal == 0.0F) { - this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F)); - } - - this.timeInPortal += 0.0125F; - if (this.timeInPortal >= 1.0F) { - this.timeInPortal = 1.0F; - } - - this.inPortal = false; - } - else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) { - if (ModuleManager.antiDebuff == null || !ModuleManager.antiDebuff.canRemoveNausea(Potion.confusion)) { - this.timeInPortal += 0.006666667F; - if (this.timeInPortal > 1.0F) { - this.timeInPortal = 1.0F; - } - } - } - else { - if (this.timeInPortal > 0.0F) { - this.timeInPortal -= 0.05F; - } - - if (this.timeInPortal < 0.0F) { - this.timeInPortal = 0.0F; - } - } - - if (this.timeUntilPortal > 0) { - --this.timeUntilPortal; - } - - boolean flag = this.movementInput.jump; - boolean flag1 = this.movementInput.sneak; - float f = 0.8F; - boolean flag2 = this.movementInput.moveForward >= f; - this.movementInput.updatePlayerMoveState(); - boolean stopSprint = ModuleManager.noSlow == null || !ModuleManager.noSlow.isEnabled() || NoSlow.slowed.getInput() == 80; - if ((this.isUsingItem() || (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingClient)) && !this.isRiding()) { - MovementInput var10000 = this.movementInput; - float slowed = NoSlow.getSlowed(); - var10000.moveStrafe *= slowed; - var10000 = this.movementInput; - var10000.moveForward *= slowed; - if (stopSprint) { - this.sprintToggleTimer = 0; - } - } - - this.pushOutOfBlocks(this.posX - (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double) this.width * 0.35); - this.pushOutOfBlocks(this.posX - (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double) this.width * 0.35); - this.pushOutOfBlocks(this.posX + (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double) this.width * 0.35); - this.pushOutOfBlocks(this.posX + (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double) this.width * 0.35); - boolean flag3 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying; - if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= f && !this.isSprinting() && flag3 && (!this.isUsingItem() || !stopSprint) && !this.isPotionActive(Potion.blindness)) { - if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) { - this.sprintToggleTimer = 7; - } else { - this.setSprinting(true); - } - } - - if (!this.isSprinting() && this.mc.gameSettings.keyBindSprint.isKeyDown() && (this.movementInput.moveForward != 0 || this.movementInput.moveStrafe != 0) && (ModuleManager.sprint.omniSprint() || ModuleManager.scaffold.sprint() || this.movementInput.moveForward >= f && flag3) && (!(this.isUsingItem() || mc.thePlayer.isBlocking()) || !stopSprint) && !this.isPotionActive(Potion.blindness)) { - this.setSprinting(true); - } - - if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !ModuleManager.scaffold.sprint() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || ModuleManager.sprint.disableBackwards() || ModuleUtils.setSlow || ModuleManager.noSlow != null && NoSlow.disableSprintInAir.isToggled() && ModuleManager.noSlow.fn && !mc.thePlayer.onGround || (this.movementInput.moveForward == 0 && this.movementInput.moveStrafe == 0) || this.mc.gameSettings.keyBindSneak.isKeyDown() || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && !ModuleManager.scaffold.sprint()) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint) || ModuleManager.sprint.isEnabled() && ModuleManager.sprint.omniDirectional.getInput() > 0 && !ModuleManager.sprint.omniSprint()) { - this.setSprinting(false); - WTap.stopSprint = false; - } - - if (this.capabilities.allowFlying) { - if (this.mc.playerController.isSpectatorMode()) { - if (!this.capabilities.isFlying) { - this.capabilities.isFlying = true; - this.sendPlayerAbilities(); - } - } else if (!flag && this.movementInput.jump) { - if (this.flyToggleTimer == 0) { - this.flyToggleTimer = 7; - } else { - this.capabilities.isFlying = !this.capabilities.isFlying; - this.sendPlayerAbilities(); - this.flyToggleTimer = 0; - } - } - } - - if (this.capabilities.isFlying && this.isCurrentViewEntity()) { - if (this.movementInput.sneak) { - this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F); - } - - if (this.movementInput.jump) { - this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F); - } - } - - if (this.isRidingHorse()) { - if (this.horseJumpPowerCounter < 0) { - ++this.horseJumpPowerCounter; - if (this.horseJumpPowerCounter == 0) { - this.horseJumpPower = 0.0F; - } - } - - if (flag && !this.movementInput.jump) { - this.horseJumpPowerCounter = -10; - this.sendHorseJump(); - } else if (!flag && this.movementInput.jump) { - this.horseJumpPowerCounter = 0; - this.horseJumpPower = 0.0F; - } else if (flag) { - ++this.horseJumpPowerCounter; - if (this.horseJumpPowerCounter < 10) { - this.horseJumpPower = (float) this.horseJumpPowerCounter * 0.1F; - } else { - this.horseJumpPower = 0.8F + 2.0F / (float) (this.horseJumpPowerCounter - 9) * 0.1F; - } - } - } else { - this.horseJumpPower = 0.0F; - } - - super.onLivingUpdate(); - if (this.onGround && this.capabilities.isFlying && !this.mc.playerController.isSpectatorMode()) { - this.capabilities.isFlying = false; - this.sendPlayerAbilities(); - } - } +package keystrokesmod.mixin.impl.entity; + +import com.mojang.authlib.GameProfile; +import keystrokesmod.event.PostMotionEvent; +import keystrokesmod.event.PostUpdateEvent; +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.WTap; +import keystrokesmod.module.impl.movement.NoSlow; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.RotationUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.potion.Potion; +import net.minecraft.util.*; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EntityPlayerSP.class) +public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { + @Shadow + public int sprintingTicksLeft; + + public MixinEntityPlayerSP(World p_i45074_1_, GameProfile p_i45074_2_) { + super(p_i45074_1_, p_i45074_2_); + } + + @Override + @Shadow + public abstract void setSprinting(boolean p_setSprinting_1_); + @Shadow + protected int sprintToggleTimer; + @Shadow + public float prevTimeInPortal; + @Shadow + public float timeInPortal; + @Shadow + protected Minecraft mc; + @Shadow + public MovementInput movementInput; + @Override + @Shadow + public abstract void sendPlayerAbilities(); + @Shadow + protected abstract boolean isCurrentViewEntity(); + @Shadow + public abstract boolean isRidingHorse(); + @Shadow + private int horseJumpPowerCounter; + @Shadow + private float horseJumpPower; + @Shadow + protected abstract void sendHorseJump(); + @Shadow + private boolean serverSprintState; + @Shadow + @Final + public NetHandlerPlayClient sendQueue; + @Override + @Shadow + public abstract boolean isSneaking(); + @Shadow + private boolean serverSneakState; + @Shadow + private double lastReportedPosX; + @Shadow + private double lastReportedPosY; + @Shadow + private double lastReportedPosZ; + @Shadow + private float lastReportedYaw; + @Shadow + private float lastReportedPitch; + @Shadow + private int positionUpdateTicks; + + @Inject(method = "onUpdate", at = @At("HEAD")) + private void onUpdatePre(CallbackInfo c) { + if (this.worldObj.isBlockLoaded(new BlockPos(this.posX, 0.0, this.posZ))) { + RotationUtils.prevRenderPitch = RotationUtils.renderPitch; + RotationUtils.prevRenderYaw = RotationUtils.renderYaw; + + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PreUpdateEvent()); + } + } + + @Inject(method = "onUpdate", at = @At("RETURN")) + private void onUpdatePost(CallbackInfo c) { + if (this.worldObj.isBlockLoaded(new BlockPos(this.posX, 0.0, this.posZ))) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PostUpdateEvent()); + } + } + + @Overwrite + public void onUpdateWalkingPlayer() { + PreMotionEvent.setRotations = false; + PreMotionEvent.setRenderYaw(false); + RotationUtils.setFakeRotations = false; + PreMotionEvent preMotionEvent = new PreMotionEvent( + this.posX, + this.getEntityBoundingBox().minY, + this.posZ, + this.rotationYaw, + this.rotationPitch, + this.onGround, + this.isSprinting(), + this.isSneaking() + ); + + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(preMotionEvent); + + RotationUtils.serverRotations = new float[] { preMotionEvent.getYaw(), preMotionEvent.getPitch() }; + + boolean flag = preMotionEvent.isSprinting(); + if (flag != this.serverSprintState) { + if (flag) { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SPRINTING)); + } else { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SPRINTING)); + } + + this.serverSprintState = flag; + } + + boolean flag1 = preMotionEvent.isSneaking(); + if (flag1 != this.serverSneakState) { + if (flag1) { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SNEAKING)); + } else { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SNEAKING)); + } + + this.serverSneakState = flag1; + } + + if (this.isCurrentViewEntity()) { + if (PreMotionEvent.setRenderYaw()) { + RotationUtils.setRenderYaw(preMotionEvent.getYaw()); + } + + RotationUtils.renderPitch = preMotionEvent.getPitch(); + RotationUtils.renderYaw = preMotionEvent.getYaw(); + + if (RotationUtils.setFakeRotations) { + RotationUtils.renderPitch = RotationUtils.fakeRotations[1]; + RotationUtils.renderYaw = RotationUtils.fakeRotations[0]; + RotationUtils.setRenderYaw(RotationUtils.renderYaw); + } + RotationUtils.setFakeRotations = false; + + double d0 = preMotionEvent.getPosX() - this.lastReportedPosX; + double d1 = preMotionEvent.getPosY() - this.lastReportedPosY; + double d2 = preMotionEvent.getPosZ() - this.lastReportedPosZ; + double d3 = preMotionEvent.getYaw() - this.lastReportedYaw; + double d4 = preMotionEvent.getPitch() - this.lastReportedPitch; + boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4 || this.positionUpdateTicks >= 20; + boolean flag3 = d3 != 0.0 || d4 != 0.0; + if (this.ridingEntity == null) { + if (flag2 && flag3) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(preMotionEvent.getPosX(), preMotionEvent.getPosY(), preMotionEvent.getPosZ(), preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); + } else if (flag2) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(preMotionEvent.getPosX(), preMotionEvent.getPosY(), preMotionEvent.getPosZ(), preMotionEvent.isOnGround())); + } else if (flag3) { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); + } else { + this.sendQueue.addToSendQueue(new C03PacketPlayer(preMotionEvent.isOnGround())); + } + } else { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, this.motionZ, preMotionEvent.getYaw(), preMotionEvent.getPitch(), preMotionEvent.isOnGround())); + flag2 = false; + } + + ++this.positionUpdateTicks; + + if (flag2) { + this.lastReportedPosX = preMotionEvent.getPosX(); + this.lastReportedPosY = preMotionEvent.getPosY(); + this.lastReportedPosZ = preMotionEvent.getPosZ(); + this.positionUpdateTicks = 0; + } + + if (flag3) { + this.lastReportedYaw = preMotionEvent.getYaw(); + this.lastReportedPitch = preMotionEvent.getPitch(); + } + } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new PostMotionEvent()); + } + + @Overwrite + public void onLivingUpdate() { + if (this.sprintingTicksLeft > 0) { + --this.sprintingTicksLeft; + if (this.sprintingTicksLeft == 0) { + this.setSprinting(false); + } + } + + if (this.sprintToggleTimer > 0) { + --this.sprintToggleTimer; + } + + this.prevTimeInPortal = this.timeInPortal; + if (this.inPortal) { + if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) { + this.mc.displayGuiScreen(null); + } + + if (this.timeInPortal == 0.0F) { + this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F)); + } + + this.timeInPortal += 0.0125F; + if (this.timeInPortal >= 1.0F) { + this.timeInPortal = 1.0F; + } + + this.inPortal = false; + } + else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) { + if (ModuleManager.antiDebuff == null || !ModuleManager.antiDebuff.canRemoveNausea(Potion.confusion)) { + this.timeInPortal += 0.006666667F; + if (this.timeInPortal > 1.0F) { + this.timeInPortal = 1.0F; + } + } + } + else { + if (this.timeInPortal > 0.0F) { + this.timeInPortal -= 0.05F; + } + + if (this.timeInPortal < 0.0F) { + this.timeInPortal = 0.0F; + } + } + + if (this.timeUntilPortal > 0) { + --this.timeUntilPortal; + } + + boolean flag = this.movementInput.jump; + boolean flag1 = this.movementInput.sneak; + float f = 0.8F; + boolean flag2 = this.movementInput.moveForward >= f; + this.movementInput.updatePlayerMoveState(); + boolean stopSprint = ModuleManager.noSlow == null || !ModuleManager.noSlow.isEnabled() || NoSlow.slowed.getInput() == 80; + if ((this.isUsingItem() || (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingClient || ModuleManager.noSlow != null && ModuleManager.noSlow.isEnabled() && ModuleManager.noSlow.blockingClient)) && !this.isRiding()) { + MovementInput var10000 = this.movementInput; + float slowed = NoSlow.getSlowed(); + var10000.moveStrafe *= slowed; + var10000 = this.movementInput; + var10000.moveForward *= slowed; + if (stopSprint) { + this.sprintToggleTimer = 0; + } + } + + this.pushOutOfBlocks(this.posX - (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double) this.width * 0.35); + this.pushOutOfBlocks(this.posX - (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double) this.width * 0.35); + this.pushOutOfBlocks(this.posX + (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double) this.width * 0.35); + this.pushOutOfBlocks(this.posX + (double) this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double) this.width * 0.35); + boolean flag3 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying; + if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= f && !this.isSprinting() && flag3 && (!this.isUsingItem() || !stopSprint) && !this.isPotionActive(Potion.blindness)) { + if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) { + this.sprintToggleTimer = 7; + } else { + this.setSprinting(true); + } + } + + if (!this.isSprinting() && this.mc.gameSettings.keyBindSprint.isKeyDown() && (this.movementInput.moveForward != 0 || this.movementInput.moveStrafe != 0) && (ModuleManager.sprint.omniSprint() || ModuleManager.scaffold.sprint() || this.movementInput.moveForward >= f && flag3) && (!(this.isUsingItem() || mc.thePlayer.isBlocking()) || !stopSprint) && !this.isPotionActive(Potion.blindness)) { + this.setSprinting(true); + } + + if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !ModuleManager.scaffold.sprint() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || ModuleManager.sprint.disableBackwards() || ModuleUtils.setSlow || (this.movementInput.moveForward == 0 && this.movementInput.moveStrafe == 0) || this.mc.gameSettings.keyBindSneak.isKeyDown() || ModuleManager.tower.towerMove.getInput() == 0 && ModuleManager.tower.canTower() || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && !ModuleManager.scaffold.sprint()) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint) || ModuleManager.sprint.isEnabled() && ModuleManager.sprint.omniDirectional.getInput() > 0 && !ModuleManager.sprint.omniSprint()) { + this.setSprinting(false); + WTap.stopSprint = false; + } + + if (this.capabilities.allowFlying) { + if (this.mc.playerController.isSpectatorMode()) { + if (!this.capabilities.isFlying) { + this.capabilities.isFlying = true; + this.sendPlayerAbilities(); + } + } else if (!flag && this.movementInput.jump) { + if (this.flyToggleTimer == 0) { + this.flyToggleTimer = 7; + } else { + this.capabilities.isFlying = !this.capabilities.isFlying; + this.sendPlayerAbilities(); + this.flyToggleTimer = 0; + } + } + } + + if (this.capabilities.isFlying && this.isCurrentViewEntity()) { + if (this.movementInput.sneak) { + this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F); + } + + if (this.movementInput.jump) { + this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F); + } + } + + if (this.isRidingHorse()) { + if (this.horseJumpPowerCounter < 0) { + ++this.horseJumpPowerCounter; + if (this.horseJumpPowerCounter == 0) { + this.horseJumpPower = 0.0F; + } + } + + if (flag && !this.movementInput.jump) { + this.horseJumpPowerCounter = -10; + this.sendHorseJump(); + } else if (!flag && this.movementInput.jump) { + this.horseJumpPowerCounter = 0; + this.horseJumpPower = 0.0F; + } else if (flag) { + ++this.horseJumpPowerCounter; + if (this.horseJumpPowerCounter < 10) { + this.horseJumpPower = (float) this.horseJumpPowerCounter * 0.1F; + } else { + this.horseJumpPower = 0.8F + 2.0F / (float) (this.horseJumpPowerCounter - 9) * 0.1F; + } + } + } else { + this.horseJumpPower = 0.0F; + } + + super.onLivingUpdate(); + if (this.onGround && this.capabilities.isFlying && !this.mc.playerController.isSpectatorMode()) { + this.capabilities.isFlying = false; + this.sendPlayerAbilities(); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/network/MixinModList.java b/src/main/java/keystrokesmod/mixin/impl/network/MixinModList.java index d9c6285..a3be9ad 100644 --- a/src/main/java/keystrokesmod/mixin/impl/network/MixinModList.java +++ b/src/main/java/keystrokesmod/mixin/impl/network/MixinModList.java @@ -1,44 +1,44 @@ -package keystrokesmod.mixin.impl.network; - -import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.network.ByteBufUtils; -import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -@Mixin(FMLHandshakeMessage.ModList.class) -public abstract class MixinModList { - private static final List exemptMods = Arrays.asList("FML", "mcp", "Forge"); - @Shadow(remap = false) - private Map modTags; - - @Inject(method = "toBytes", at = @At(value = "HEAD"), cancellable = true, remap = false) - public void toBytes(ByteBuf buffer, CallbackInfo callbackInfo) { - if (Minecraft.getMinecraft().isSingleplayer()) return; - - callbackInfo.cancel(); - - ArrayList> shownTags = new ArrayList<>(); - for (Map.Entry modTag : this.modTags.entrySet()) { - if (exemptMods.contains(modTag.getKey())) { - shownTags.add(modTag); - } - } - - ByteBufUtils.writeVarInt(buffer, shownTags.size(), 2); - - for (Map.Entry modTag : shownTags) { - ByteBufUtils.writeUTF8String(buffer, modTag.getKey()); - ByteBufUtils.writeUTF8String(buffer, modTag.getValue()); - } - } +package keystrokesmod.mixin.impl.network; + +import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +@Mixin(FMLHandshakeMessage.ModList.class) +public abstract class MixinModList { + private static final List exemptMods = Arrays.asList("FML", "mcp", "Forge"); + @Shadow(remap = false) + private Map modTags; + + @Inject(method = "toBytes", at = @At(value = "HEAD"), cancellable = true, remap = false) + public void toBytes(ByteBuf buffer, CallbackInfo callbackInfo) { + if (Minecraft.getMinecraft().isSingleplayer()) return; + + callbackInfo.cancel(); + + ArrayList> shownTags = new ArrayList<>(); + for (Map.Entry modTag : this.modTags.entrySet()) { + if (exemptMods.contains(modTag.getKey())) { + shownTags.add(modTag); + } + } + + ByteBufUtils.writeVarInt(buffer, shownTags.size(), 2); + + for (Map.Entry modTag : shownTags) { + ByteBufUtils.writeUTF8String(buffer, modTag.getKey()); + ByteBufUtils.writeUTF8String(buffer, modTag.getValue()); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/network/MixinNetHandlerPlayClient.java b/src/main/java/keystrokesmod/mixin/impl/network/MixinNetHandlerPlayClient.java index 1b5d650..7a96760 100644 --- a/src/main/java/keystrokesmod/mixin/impl/network/MixinNetHandlerPlayClient.java +++ b/src/main/java/keystrokesmod/mixin/impl/network/MixinNetHandlerPlayClient.java @@ -1,46 +1,46 @@ -package keystrokesmod.mixin.impl.network; - -import keystrokesmod.event.PreEntityVelocityEvent; -import keystrokesmod.event.PreExplosionPacketEvent; -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraftforge.common.MinecraftForge; -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(NetHandlerPlayClient.class) -public class MixinNetHandlerPlayClient { - - @Inject(method = "handlePlayerPosLook", at = @At("HEAD")) - public void handlePlayerPosLookPre(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { - ModuleManager.noRotate.handlePlayerPosLookPre(); - } - - @Inject(method = "handlePlayerPosLook", at = @At("RETURN")) - public void handlePlayerPosLook(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { - ModuleManager.noRotate.handlePlayerPosLook(packetIn); - } - - @Inject(method = "handleEntityVelocity", at = @At("HEAD"), cancellable = true) - public void handleEntityVelocityInjection(S12PacketEntityVelocity packet, CallbackInfo ci) { - PreEntityVelocityEvent preEntityVelocityEvent = new PreEntityVelocityEvent(packet); - MinecraftForge.EVENT_BUS.post(preEntityVelocityEvent); - if (preEntityVelocityEvent.isCanceled()) { - ci.cancel(); - } - } - - @Inject(method = "handleExplosion", at = @At("HEAD"), cancellable = true) - public void handleExplosionInjection(S27PacketExplosion packet, CallbackInfo ci) { - PreExplosionPacketEvent event = new PreExplosionPacketEvent(packet); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) { - ci.cancel(); - } - } - } +package keystrokesmod.mixin.impl.network; + +import keystrokesmod.event.PreEntityVelocityEvent; +import keystrokesmod.event.PreExplosionPacketEvent; +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraftforge.common.MinecraftForge; +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(NetHandlerPlayClient.class) +public class MixinNetHandlerPlayClient { + + @Inject(method = "handlePlayerPosLook", at = @At("HEAD")) + public void handlePlayerPosLookPre(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { + ModuleManager.noRotate.handlePlayerPosLookPre(); + } + + @Inject(method = "handlePlayerPosLook", at = @At("RETURN")) + public void handlePlayerPosLook(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { + ModuleManager.noRotate.handlePlayerPosLook(packetIn); + } + + @Inject(method = "handleEntityVelocity", at = @At("HEAD"), cancellable = true) + public void handleEntityVelocityInjection(S12PacketEntityVelocity packet, CallbackInfo ci) { + PreEntityVelocityEvent preEntityVelocityEvent = new PreEntityVelocityEvent(packet); + MinecraftForge.EVENT_BUS.post(preEntityVelocityEvent); + if (preEntityVelocityEvent.isCanceled()) { + ci.cancel(); + } + } + + @Inject(method = "handleExplosion", at = @At("HEAD"), cancellable = true) + public void handleExplosionInjection(S27PacketExplosion packet, CallbackInfo ci) { + PreExplosionPacketEvent event = new PreExplosionPacketEvent(packet); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { + ci.cancel(); + } + } + } diff --git a/src/main/java/keystrokesmod/mixin/impl/network/MixinNetworkManager.java b/src/main/java/keystrokesmod/mixin/impl/network/MixinNetworkManager.java index f3b157f..74ae425 100644 --- a/src/main/java/keystrokesmod/mixin/impl/network/MixinNetworkManager.java +++ b/src/main/java/keystrokesmod/mixin/impl/network/MixinNetworkManager.java @@ -1,54 +1,54 @@ -package keystrokesmod.mixin.impl.network; - -import io.netty.channel.ChannelHandlerContext; -import keystrokesmod.event.*; -import keystrokesmod.utility.PacketUtils; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -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(NetworkManager.class) -public class MixinNetworkManager { - @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) - public void sendPacket(Packet p_sendPacket_1_, CallbackInfo ci) { - SendAllPacketsEvent sendAllPacketsEvent = new SendAllPacketsEvent(p_sendPacket_1_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(sendAllPacketsEvent); - if (sendAllPacketsEvent.isCanceled()) { - ci.cancel(); - } - if (PacketUtils.skipSendEvent.contains(p_sendPacket_1_)) { - PacketUtils.skipSendEvent.remove(p_sendPacket_1_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new NoEventPacketEvent(p_sendPacket_1_)); - return; - } - - SendPacketEvent sendPacketEvent = new SendPacketEvent(p_sendPacket_1_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(sendPacketEvent); - - if (sendPacketEvent.isCanceled()) { - ci.cancel(); - } - } - - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) - public void receivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { - ReceiveAllPacketsEvent receiveAllPacketsEvent = new ReceiveAllPacketsEvent(p_channelRead0_2_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(receiveAllPacketsEvent); - if (receiveAllPacketsEvent.isCanceled()) { - ci.cancel(); - } - if (PacketUtils.skipReceiveEvent.contains(p_channelRead0_2_)) { - PacketUtils.skipReceiveEvent.remove(p_channelRead0_2_); - return; - } - ReceivePacketEvent receivePacketEvent = new ReceivePacketEvent(p_channelRead0_2_); - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(receivePacketEvent); - - if (receivePacketEvent.isCanceled()) { - ci.cancel(); - } - } -} +package keystrokesmod.mixin.impl.network; + +import io.netty.channel.ChannelHandlerContext; +import keystrokesmod.event.*; +import keystrokesmod.utility.PacketUtils; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +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(NetworkManager.class) +public class MixinNetworkManager { + @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + public void sendPacket(Packet p_sendPacket_1_, CallbackInfo ci) { + SendAllPacketsEvent sendAllPacketsEvent = new SendAllPacketsEvent(p_sendPacket_1_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(sendAllPacketsEvent); + if (sendAllPacketsEvent.isCanceled()) { + ci.cancel(); + } + if (PacketUtils.skipSendEvent.contains(p_sendPacket_1_)) { + PacketUtils.skipSendEvent.remove(p_sendPacket_1_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new NoEventPacketEvent(p_sendPacket_1_)); + return; + } + + SendPacketEvent sendPacketEvent = new SendPacketEvent(p_sendPacket_1_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(sendPacketEvent); + + if (sendPacketEvent.isCanceled()) { + ci.cancel(); + } + } + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + public void receivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { + ReceiveAllPacketsEvent receiveAllPacketsEvent = new ReceiveAllPacketsEvent(p_channelRead0_2_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(receiveAllPacketsEvent); + if (receiveAllPacketsEvent.isCanceled()) { + ci.cancel(); + } + if (PacketUtils.skipReceiveEvent.contains(p_channelRead0_2_)) { + PacketUtils.skipReceiveEvent.remove(p_channelRead0_2_); + return; + } + ReceivePacketEvent receivePacketEvent = new ReceivePacketEvent(p_channelRead0_2_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(receivePacketEvent); + + if (receivePacketEvent.isCanceled()) { + ci.cancel(); + } + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinCustomSky.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinCustomSky.java index 1aafb64..664ddcd 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinCustomSky.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinCustomSky.java @@ -1,22 +1,22 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.util.MathHelper; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Pseudo -@Mixin(targets = "net.optifine.CustomSky", remap = false) -public abstract class MixinCustomSky { - @Dynamic - @ModifyVariable(method = "renderSky", at = @At("STORE")) - private static long changeWorldTime(long time) { - if (ModuleManager.weather != null && ModuleManager.weather.isEnabled()) { - return (long) MathHelper.clamp_double((ModuleManager.weather.time.getInput() * 1000), 0, 23999); - } - return time; - } +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.util.MathHelper; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Pseudo +@Mixin(targets = "net.optifine.CustomSky", remap = false) +public abstract class MixinCustomSky { + @Dynamic + @ModifyVariable(method = "renderSky", at = @At("STORE")) + private static long changeWorldTime(long time) { + if (ModuleManager.weather != null && ModuleManager.weather.isEnabled()) { + return (long) MathHelper.clamp_double((ModuleManager.weather.time.getInput() * 1000), 0, 23999); + } + return time; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinEntityRenderer.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinEntityRenderer.java index 506730d..88cfa36 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinEntityRenderer.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinEntityRenderer.java @@ -1,58 +1,58 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.potion.Potion; -import net.minecraft.util.Vec3; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@SideOnly(Side.CLIENT) -@Mixin(EntityRenderer.class) -public class MixinEntityRenderer { - - @Redirect(method = "hurtCameraEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V")) - public void injectNoHurtCam(float angle, float x, float y, float z) { - if (ModuleManager.noHurtCam != null && ModuleManager.noHurtCam.isEnabled()) { - angle = (float) (angle / 14 * ModuleManager.noHurtCam.multiplier.getInput()); - } - GlStateManager.rotate(angle, x, y, z); - } - - @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Vec3;distanceTo(Lnet/minecraft/util/Vec3;)D")) - public double injectNoCameraClip(Vec3 raytrace, Vec3 original) { - if (ModuleManager.noCameraClip != null && ModuleManager.noCameraClip.isEnabled()) { - return ModuleManager.extendCamera != null && ModuleManager.extendCamera.isEnabled() ? ModuleManager.extendCamera.distance.getInput() : 4; - } - return raytrace.distanceTo(original); - } - - @Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) - private boolean redirectSetupFog(EntityLivingBase entity, Potion potion) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveBlindness(potion)) { - return false; - } - return entity.isPotionActive(potion); - } - - @Redirect(method = "updateFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) - private boolean redirectFogColor(EntityLivingBase entity, Potion potion) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveBlindness(potion)) { - return false; - } - return entity.isPotionActive(potion); - } - - @Redirect(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) - private boolean redirectSetupCameraTransform(EntityLivingBase entity, Potion potion) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { - return false; - } - return entity.isPotionActive(potion); - } +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.Potion; +import net.minecraft.util.Vec3; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@SideOnly(Side.CLIENT) +@Mixin(EntityRenderer.class) +public class MixinEntityRenderer { + + @Redirect(method = "hurtCameraEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V")) + public void injectNoHurtCam(float angle, float x, float y, float z) { + if (ModuleManager.noHurtCam != null && ModuleManager.noHurtCam.isEnabled()) { + angle = (float) (angle / 14 * ModuleManager.noHurtCam.multiplier.getInput()); + } + GlStateManager.rotate(angle, x, y, z); + } + + @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Vec3;distanceTo(Lnet/minecraft/util/Vec3;)D")) + public double injectNoCameraClip(Vec3 raytrace, Vec3 original) { + if (ModuleManager.noCameraClip != null && ModuleManager.noCameraClip.isEnabled()) { + return ModuleManager.extendCamera != null && ModuleManager.extendCamera.isEnabled() ? ModuleManager.extendCamera.distance.getInput() : 4; + } + return raytrace.distanceTo(original); + } + + @Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) + private boolean redirectSetupFog(EntityLivingBase entity, Potion potion) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveBlindness(potion)) { + return false; + } + return entity.isPotionActive(potion); + } + + @Redirect(method = "updateFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) + private boolean redirectFogColor(EntityLivingBase entity, Potion potion) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveBlindness(potion)) { + return false; + } + return entity.isPotionActive(potion); + } + + @Redirect(method = "setupCameraTransform", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) + private boolean redirectSetupCameraTransform(EntityLivingBase entity, Potion potion) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { + return false; + } + return entity.isPotionActive(potion); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinFontRenderer.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinFontRenderer.java index aff8d72..c103336 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinFontRenderer.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinFontRenderer.java @@ -1,43 +1,43 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.other.NameHider; -import keystrokesmod.module.impl.render.AntiShuffle; -import net.minecraft.client.gui.FontRenderer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@SideOnly(Side.CLIENT) -@Mixin(FontRenderer.class) -public class MixinFontRenderer { - @ModifyVariable(method = "renderString", at = @At("HEAD"), require = 1, ordinal = 0, argsOnly = true) - private String renderString(String string) { - if (string == null) - return null; - if ((ModuleManager.nameHider != null) && ModuleManager.nameHider.isEnabled()) { - string = NameHider.getFakeName(string); - } - if ((ModuleManager.antiShuffle != null) && ModuleManager.antiShuffle.isEnabled()) { - string = AntiShuffle.removeObfuscation(string); - } - - return string; - } - - @ModifyVariable(method = "getStringWidth", at = @At("HEAD"), require = 1, ordinal = 0, argsOnly = true) - private String getStringWidth(String string) { - if (string == null) - return null; - if ((ModuleManager.nameHider != null) && ModuleManager.nameHider.isEnabled()) { - string = NameHider.getFakeName(string); - } - if ((ModuleManager.antiShuffle != null) && ModuleManager.antiShuffle.isEnabled()) { - string = AntiShuffle.removeObfuscation(string); - } - - return string; - } -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.other.NameHider; +import keystrokesmod.module.impl.render.AntiShuffle; +import net.minecraft.client.gui.FontRenderer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@SideOnly(Side.CLIENT) +@Mixin(FontRenderer.class) +public class MixinFontRenderer { + @ModifyVariable(method = "renderString", at = @At("HEAD"), require = 1, ordinal = 0, argsOnly = true) + private String renderString(String string) { + if (string == null) + return null; + if ((ModuleManager.nameHider != null) && ModuleManager.nameHider.isEnabled()) { + string = NameHider.getFakeName(string); + } + if ((ModuleManager.antiShuffle != null) && ModuleManager.antiShuffle.isEnabled()) { + string = AntiShuffle.removeObfuscation(string); + } + + return string; + } + + @ModifyVariable(method = "getStringWidth", at = @At("HEAD"), require = 1, ordinal = 0, argsOnly = true) + private String getStringWidth(String string) { + if (string == null) + return null; + if ((ModuleManager.nameHider != null) && ModuleManager.nameHider.isEnabled()) { + string = NameHider.getFakeName(string); + } + if ((ModuleManager.antiShuffle != null) && ModuleManager.antiShuffle.isEnabled()) { + string = AntiShuffle.removeObfuscation(string); + } + + return string; + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiChat.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiChat.java index 16ef6ea..f771c6a 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiChat.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiChat.java @@ -1,58 +1,58 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.Raven; -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.GuiTextField; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@SideOnly(Side.CLIENT) -@Mixin(GuiChat.class) -public abstract class MixinGuiChat extends MixinGuiScreen -{ - @Shadow - protected GuiTextField inputField; - - @Shadow - private List foundPlayerNames; - @Shadow - private boolean waitingOnAutocomplete; - - @Shadow - public abstract void onAutocompleteResponse(String[] p_onAutocompleteResponse_1_); - - @Inject(method = "keyTyped", at = @At("RETURN")) - private void updateLength(CallbackInfo callbackInfo) { - if (inputField.getText().startsWith((".")) && ModuleManager.canExecuteChatCommand()) { - Raven.commandManager.autoComplete(inputField.getText()); - } - else { - inputField.setMaxStringLength(100); - } - } - - @Inject(method = "sendAutocompleteRequest", at = @At("HEAD"), cancellable = true) - private void handleClientCommandCompletion(String full, final String ignored, CallbackInfo callbackInfo) { - if (Raven.commandManager.autoComplete(full) && ModuleManager.canExecuteChatCommand()) { - waitingOnAutocomplete = true; - - String[] latestAutoComplete = Raven.commandManager.latestAutoComplete; - - if (full.toLowerCase().endsWith(latestAutoComplete[latestAutoComplete.length - 1].toLowerCase())) { - return; - } - - this.onAutocompleteResponse(latestAutoComplete); - - callbackInfo.cancel(); - } - } -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.Raven; +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiTextField; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; + +@SideOnly(Side.CLIENT) +@Mixin(GuiChat.class) +public abstract class MixinGuiChat extends MixinGuiScreen +{ + @Shadow + protected GuiTextField inputField; + + @Shadow + private List foundPlayerNames; + @Shadow + private boolean waitingOnAutocomplete; + + @Shadow + public abstract void onAutocompleteResponse(String[] p_onAutocompleteResponse_1_); + + @Inject(method = "keyTyped", at = @At("RETURN")) + private void updateLength(CallbackInfo callbackInfo) { + if (inputField.getText().startsWith((".")) && ModuleManager.canExecuteChatCommand()) { + Raven.commandManager.autoComplete(inputField.getText()); + } + else { + inputField.setMaxStringLength(100); + } + } + + @Inject(method = "sendAutocompleteRequest", at = @At("HEAD"), cancellable = true) + private void handleClientCommandCompletion(String full, final String ignored, CallbackInfo callbackInfo) { + if (Raven.commandManager.autoComplete(full) && ModuleManager.canExecuteChatCommand()) { + waitingOnAutocomplete = true; + + String[] latestAutoComplete = Raven.commandManager.latestAutoComplete; + + if (full.toLowerCase().endsWith(latestAutoComplete[latestAutoComplete.length - 1].toLowerCase())) { + return; + } + + this.onAutocompleteResponse(latestAutoComplete); + + callbackInfo.cancel(); + } + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngame.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngame.java index bc4eb05..75ea01c 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngame.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngame.java @@ -1,22 +1,22 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.potion.Potion; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(GuiIngame.class) -public class MixinGuiIngame { - - @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) - private boolean redirectRenderGameOverlay(GuiIngame gui, Potion potion) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { - return false; - } - return Minecraft.getMinecraft().thePlayer.isPotionActive(potion); - } - -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.potion.Potion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(GuiIngame.class) +public class MixinGuiIngame { + + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) + private boolean redirectRenderGameOverlay(GuiIngame gui, Potion potion) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { + return false; + } + return Minecraft.getMinecraft().thePlayer.isPotionActive(potion); + } + +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngameForge.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngameForge.java index c28d588..ddfc056 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngameForge.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiIngameForge.java @@ -1,22 +1,22 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.potion.Potion; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(targets = "net.minecraftforge.client.GuiIngameForge", remap = false) -public class MixinGuiIngameForge { - - @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) - private boolean redirectRenderGameOverlay(GuiIngame gui, Potion potion) { - if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { - return false; - } - return Minecraft.getMinecraft().thePlayer.isPotionActive(potion); - } - -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.potion.Potion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(targets = "net.minecraftforge.client.GuiIngameForge", remap = false) +public class MixinGuiIngameForge { + + @Redirect(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;isPotionActive(Lnet/minecraft/potion/Potion;)Z")) + private boolean redirectRenderGameOverlay(GuiIngame gui, Potion potion) { + if (ModuleManager.antiDebuff != null && ModuleManager.antiDebuff.canRemoveNausea(potion)) { + return false; + } + return Minecraft.getMinecraft().thePlayer.isPotionActive(potion); + } + +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiScreen.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiScreen.java index 23060e6..7420574 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiScreen.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinGuiScreen.java @@ -1,43 +1,43 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.Raven; -import keystrokesmod.event.KeyPressEvent; -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.MinecraftForge; -import org.lwjgl.input.Keyboard; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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 abstract class MixinGuiScreen -{ - @Shadow - public Minecraft mc; - - @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true) - private void messageSend(String msg, boolean addToChat, final CallbackInfo callbackInfo) { - if (msg.startsWith(".") && addToChat && ModuleManager.canExecuteChatCommand()) { - this.mc.ingameGUI.getChatGUI().addToSentMessages(msg); - - Raven.commandManager.executeCommand(msg); - callbackInfo.cancel(); - } - } - - @Inject(method = "handleKeyboardInput", at = @At("HEAD"), cancellable = true) - private void injectHandleKeyboardInput(CallbackInfo callbackInfo) { - KeyPressEvent event = new KeyPressEvent(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - - MinecraftForge.EVENT_BUS.post(event); - - if (event.isCanceled()) { - callbackInfo.cancel(); - } - } - +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.Raven; +import keystrokesmod.event.KeyPressEvent; +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.MinecraftForge; +import org.lwjgl.input.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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 abstract class MixinGuiScreen +{ + @Shadow + public Minecraft mc; + + @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true) + private void messageSend(String msg, boolean addToChat, final CallbackInfo callbackInfo) { + if (msg.startsWith(".") && addToChat && ModuleManager.canExecuteChatCommand()) { + this.mc.ingameGUI.getChatGUI().addToSentMessages(msg); + + Raven.commandManager.executeCommand(msg); + callbackInfo.cancel(); + } + } + + @Inject(method = "handleKeyboardInput", at = @At("HEAD"), cancellable = true) + private void injectHandleKeyboardInput(CallbackInfo callbackInfo) { + KeyPressEvent event = new KeyPressEvent(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + + MinecraftForge.EVENT_BUS.post(event); + + if (event.isCanceled()) { + callbackInfo.cancel(); + } + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinItemRenderer.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinItemRenderer.java index 6483edd..ee839e4 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinItemRenderer.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinItemRenderer.java @@ -1,75 +1,75 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.mixin.interfaces.IMixinItemRenderer; -import keystrokesmod.utility.Utils; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ItemRenderer.class) -public class MixinItemRenderer implements IMixinItemRenderer { - private ItemStack originalItemToRender; - @Shadow - private ItemStack itemToRender; - public boolean cancelUpdate = false; - public boolean cancelReset = false; - @Shadow - private float equippedProgress; - @Shadow - private float prevEquippedProgress; - - @Inject(method = "renderItemInFirstPerson", at = @At("HEAD")) - private void modifyRenderItemPre(float p_renderItemInFirstPerson_1_, CallbackInfo info) { - originalItemToRender = itemToRender; - itemToRender = Utils.getSpoofedItem(originalItemToRender); - } - - @Inject(method = "renderItemInFirstPerson", at = @At("RETURN")) - private void modifyRenderItemPost(float p_renderItemInFirstPerson_1_, CallbackInfo info) { - itemToRender = originalItemToRender; - } - - @Inject(method = "updateEquippedItem", at = @At("HEAD"), cancellable = true) - private void onUpdateEquippedItem(CallbackInfo ci) { - if (cancelUpdate) { - cancelUpdate = false; - equippedProgress = 1.0F; - prevEquippedProgress = 1.0f; - ci.cancel(); - } - } - - @Inject(method = "resetEquippedProgress", at = @At("HEAD"), cancellable = true) - public void injectResetEquippedProgress(CallbackInfo ci) { - if (cancelReset) { - cancelReset = false; - equippedProgress = 1.0F; - prevEquippedProgress = 1.0f; - ci.cancel(); - } - } - - @Inject(method = "resetEquippedProgress2", at = @At("HEAD"), cancellable = true) - public void injectResetEquippedProgress2(CallbackInfo ci) { - if (cancelReset) { - cancelReset = false; - equippedProgress = 1.0F; - prevEquippedProgress = 1.0f; - ci.cancel(); - } - } - - @Override - public void setCancelUpdate(boolean cancel) { - this.cancelUpdate = cancel; - } - - @Override - public void setCancelReset(boolean reset) { - this.cancelReset = reset; - } -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.mixin.interfaces.IMixinItemRenderer; +import keystrokesmod.utility.Utils; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ItemRenderer.class) +public class MixinItemRenderer implements IMixinItemRenderer { + private ItemStack originalItemToRender; + @Shadow + private ItemStack itemToRender; + public boolean cancelUpdate = false; + public boolean cancelReset = false; + @Shadow + private float equippedProgress; + @Shadow + private float prevEquippedProgress; + + @Inject(method = "renderItemInFirstPerson", at = @At("HEAD")) + private void modifyRenderItemPre(float p_renderItemInFirstPerson_1_, CallbackInfo info) { + originalItemToRender = itemToRender; + itemToRender = Utils.getSpoofedItem(originalItemToRender); + } + + @Inject(method = "renderItemInFirstPerson", at = @At("RETURN")) + private void modifyRenderItemPost(float p_renderItemInFirstPerson_1_, CallbackInfo info) { + itemToRender = originalItemToRender; + } + + @Inject(method = "updateEquippedItem", at = @At("HEAD"), cancellable = true) + private void onUpdateEquippedItem(CallbackInfo ci) { + if (cancelUpdate) { + cancelUpdate = false; + equippedProgress = 1.0F; + prevEquippedProgress = 1.0f; + ci.cancel(); + } + } + + @Inject(method = "resetEquippedProgress", at = @At("HEAD"), cancellable = true) + public void injectResetEquippedProgress(CallbackInfo ci) { + if (cancelReset) { + cancelReset = false; + equippedProgress = 1.0F; + prevEquippedProgress = 1.0f; + ci.cancel(); + } + } + + @Inject(method = "resetEquippedProgress2", at = @At("HEAD"), cancellable = true) + public void injectResetEquippedProgress2(CallbackInfo ci) { + if (cancelReset) { + cancelReset = false; + equippedProgress = 1.0F; + prevEquippedProgress = 1.0f; + ci.cancel(); + } + } + + @Override + public void setCancelUpdate(boolean cancel) { + this.cancelUpdate = cancel; + } + + @Override + public void setCancelReset(boolean reset) { + this.cancelReset = reset; + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinLayerCape.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinLayerCape.java index d89d66b..49c1a50 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinLayerCape.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinLayerCape.java @@ -1,42 +1,42 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.impl.client.Settings; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.layers.LayerCape; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@SideOnly(Side.CLIENT) -@Mixin(LayerCape.class) -public class MixinLayerCape { - @Shadow - private final RenderPlayer playerRenderer; - - public MixinLayerCape(RenderPlayer playerRendererIn) { - this.playerRenderer = playerRendererIn; - } - - @Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;isWearing(Lnet/minecraft/entity/player/EnumPlayerModelParts;)Z")) - private boolean modifyIsWearing(AbstractClientPlayer player, EnumPlayerModelParts part) { - if (player.equals(Minecraft.getMinecraft().thePlayer) && Settings.customCapes.getInput() > 0) { - return true; - } - return player.isWearing(part); - } - - @Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getLocationCape()Lnet/minecraft/util/ResourceLocation;")) - private ResourceLocation modifyGetLocationCape(AbstractClientPlayer player) { - if (player.equals(Minecraft.getMinecraft().thePlayer) && Settings.customCapes.getInput() > 0) { - return Settings.loadedCapes.get((int) (Settings.customCapes.getInput() - 1)); - } - return player.getLocationCape(); - } +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.impl.client.Settings; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.entity.layers.LayerCape; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@SideOnly(Side.CLIENT) +@Mixin(LayerCape.class) +public class MixinLayerCape { + @Shadow + private final RenderPlayer playerRenderer; + + public MixinLayerCape(RenderPlayer playerRendererIn) { + this.playerRenderer = playerRendererIn; + } + + @Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;isWearing(Lnet/minecraft/entity/player/EnumPlayerModelParts;)Z")) + private boolean modifyIsWearing(AbstractClientPlayer player, EnumPlayerModelParts part) { + if (player.equals(Minecraft.getMinecraft().thePlayer) && Settings.customCapes.getInput() > 0) { + return true; + } + return player.isWearing(part); + } + + @Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getLocationCape()Lnet/minecraft/util/ResourceLocation;")) + private ResourceLocation modifyGetLocationCape(AbstractClientPlayer player) { + if (player.equals(Minecraft.getMinecraft().thePlayer) && Settings.customCapes.getInput() > 0) { + return Settings.loadedCapes.get((int) (Settings.customCapes.getInput() - 1)); + } + return player.getLocationCape(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderGlobal.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderGlobal.java index c814bf0..a7d0ef6 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderGlobal.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderGlobal.java @@ -1,33 +1,33 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.world.AntiBot; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@SideOnly(Side.CLIENT) -@Mixin(RenderGlobal.class) -public class MixinRenderGlobal { // credit: pablolnmak - @Shadow - @Final - private Minecraft mc; - - @Unique - private boolean shouldRender() { - return ModuleManager.playerESP != null && ModuleManager.playerESP.isEnabled() && ModuleManager.playerESP.outline.isToggled(); - } +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.world.AntiBot; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@SideOnly(Side.CLIENT) +@Mixin(RenderGlobal.class) +public class MixinRenderGlobal { // credit: pablolnmak + @Shadow + @Final + private Minecraft mc; + + @Unique + private boolean shouldRender() { + return ModuleManager.playerESP != null && ModuleManager.playerESP.isEnabled() && ModuleManager.playerESP.outline.isToggled(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderManager.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderManager.java index de8fca6..61e770e 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderManager.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderManager.java @@ -1,43 +1,43 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.utility.RotationUtils; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@SideOnly(Side.CLIENT) -@Mixin(RenderManager.class) -public class MixinRenderManager { - @Unique - private float cachedPrevRotationPitch; - @Unique - private float cachedRotationPitch; - - @Inject(method = "renderEntityStatic", at = @At("HEAD")) - public void renderEntityStaticPre(final Entity entity, final float n, final boolean b, final CallbackInfoReturnable callbackInfoReturnable) { - if (entity instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { - final EntityPlayerSP player = (EntityPlayerSP)entity; - cachedRotationPitch = player.rotationPitch; - cachedPrevRotationPitch = player.prevRotationPitch; - player.prevRotationPitch = RotationUtils.prevRenderPitch; - player.rotationPitch = RotationUtils.renderPitch; - } - } - - @Inject(method = "renderEntityStatic", at = @At("RETURN")) - public void renderEntityStaticPost(final Entity entity, final float n, final boolean b, final CallbackInfoReturnable callbackInfoReturnable) { - if (entity instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { - final EntityPlayerSP player = (EntityPlayerSP)entity; - player.prevRotationPitch = this.cachedPrevRotationPitch; - player.rotationPitch = this.cachedRotationPitch; - } - } -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.utility.RotationUtils; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@SideOnly(Side.CLIENT) +@Mixin(RenderManager.class) +public class MixinRenderManager { + @Unique + private float cachedPrevRotationPitch; + @Unique + private float cachedRotationPitch; + + @Inject(method = "renderEntityStatic", at = @At("HEAD")) + public void renderEntityStaticPre(final Entity entity, final float n, final boolean b, final CallbackInfoReturnable callbackInfoReturnable) { + if (entity instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { + final EntityPlayerSP player = (EntityPlayerSP)entity; + cachedRotationPitch = player.rotationPitch; + cachedPrevRotationPitch = player.prevRotationPitch; + player.prevRotationPitch = RotationUtils.prevRenderPitch; + player.rotationPitch = RotationUtils.renderPitch; + } + } + + @Inject(method = "renderEntityStatic", at = @At("RETURN")) + public void renderEntityStaticPost(final Entity entity, final float n, final boolean b, final CallbackInfoReturnable callbackInfoReturnable) { + if (entity instanceof EntityPlayerSP && PreMotionEvent.setRenderYaw()) { + final EntityPlayerSP player = (EntityPlayerSP)entity; + player.prevRotationPitch = this.cachedPrevRotationPitch; + player.rotationPitch = this.cachedRotationPitch; + } + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderPlayer.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderPlayer.java index 74e815b..6b34e2c 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderPlayer.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinRenderPlayer.java @@ -1,23 +1,23 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import net.minecraft.client.renderer.entity.RenderPlayer; - -@Mixin(RenderPlayer.class) -public class MixinRenderPlayer { - @Redirect(method = "setModelVisibilities(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;")) - private ItemStack redirectGetCurrentItem(InventoryPlayer inventory) { - if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0 && inventory.player == Minecraft.getMinecraft().thePlayer) { - return Utils.getSpoofedItem(inventory.getCurrentItem()); - } - else { - return inventory.getCurrentItem(); - } - } -} +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import net.minecraft.client.renderer.entity.RenderPlayer; + +@Mixin(RenderPlayer.class) +public class MixinRenderPlayer { + @Redirect(method = "setModelVisibilities(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;")) + private ItemStack redirectGetCurrentItem(InventoryPlayer inventory) { + if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0 && inventory.player == Minecraft.getMinecraft().thePlayer) { + return Utils.getSpoofedItem(inventory.getCurrentItem()); + } + else { + return inventory.getCurrentItem(); + } + } +} diff --git a/src/main/java/keystrokesmod/mixin/impl/render/MixinRendererLivingEntity.java b/src/main/java/keystrokesmod/mixin/impl/render/MixinRendererLivingEntity.java index 1fa6095..e2153ec 100644 --- a/src/main/java/keystrokesmod/mixin/impl/render/MixinRendererLivingEntity.java +++ b/src/main/java/keystrokesmod/mixin/impl/render/MixinRendererLivingEntity.java @@ -1,92 +1,92 @@ -package keystrokesmod.mixin.impl.render; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RendererLivingEntity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.awt.*; - -@SideOnly(Side.CLIENT) -@Mixin(RendererLivingEntity.class) -public abstract class MixinRendererLivingEntity extends Render { // credit: pablolnmak - @Shadow - protected boolean renderOutlines; - - protected MixinRendererLivingEntity(RenderManager renderManager) { - super(renderManager); - } - - @Unique - private boolean shouldRender() { - return ModuleManager.playerESP != null && ModuleManager.playerESP.isEnabled() && ModuleManager.playerESP.outline.isToggled(); - } - - @Redirect(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RendererLivingEntity;setScoreTeamColor(Lnet/minecraft/entity/EntityLivingBase;)Z")) - private boolean setOutlineColor(RendererLivingEntity instance, T entityLivingBaseIn) { - int i = 16777215; - boolean drawOutline = shouldRender() && ((entityLivingBaseIn != Minecraft.getMinecraft().thePlayer && !AntiBot.isBot(entityLivingBaseIn)) || (entityLivingBaseIn == Minecraft.getMinecraft().thePlayer && ModuleManager.playerESP.renderSelf.isToggled())); - - if (!drawOutline || ModuleManager.playerESP.teamColor.isToggled()) - { - if (entityLivingBaseIn instanceof EntityPlayer) - { - ScorePlayerTeam scoreplayerteam = (ScorePlayerTeam)entityLivingBaseIn.getTeam(); - - if (scoreplayerteam != null) - { - String s = FontRenderer.getFormatFromString(scoreplayerteam.getColorPrefix()); - - if (s.length() >= 2) - { - i = this.getFontRendererFromRenderManager().getColorCode(s.charAt(1)); - } - } - } - } - else if (ModuleManager.playerESP.rainbow.isToggled()) { - i = Utils.getChroma(2L, 0L); - } - else { - i = (new Color((int) ModuleManager.playerESP.red.getInput(), (int) ModuleManager.playerESP.green.getInput(), (int) ModuleManager.playerESP.blue.getInput())).getRGB(); - } - - if (drawOutline && ModuleManager.playerESP.redOnDamage.isToggled() && entityLivingBaseIn.hurtTime != 0) { - i = Color.RED.getRGB(); - } - - float f1 = (float)(i >> 16 & 255) / 255.0F; - float f2 = (float)(i >> 8 & 255) / 255.0F; - float f = (float)(i & 255) / 255.0F; - GlStateManager.disableLighting(); - GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); - GlStateManager.color(f1, f2, f, 1.0F); - GlStateManager.disableTexture2D(); - GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GlStateManager.disableTexture2D(); - GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); - return true; - } - - @ModifyVariable(method = "renderModel", at = @At(value = "STORE"), ordinal = 0) - private boolean modifyInvisibleFlag(boolean flag) { - return flag || (this.renderOutlines && shouldRender() && ModuleManager.playerESP.showInvis.isToggled()); - } +package keystrokesmod.mixin.impl.render; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.awt.*; + +@SideOnly(Side.CLIENT) +@Mixin(RendererLivingEntity.class) +public abstract class MixinRendererLivingEntity extends Render { // credit: pablolnmak + @Shadow + protected boolean renderOutlines; + + protected MixinRendererLivingEntity(RenderManager renderManager) { + super(renderManager); + } + + @Unique + private boolean shouldRender() { + return ModuleManager.playerESP != null && ModuleManager.playerESP.isEnabled() && ModuleManager.playerESP.outline.isToggled(); + } + + @Redirect(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RendererLivingEntity;setScoreTeamColor(Lnet/minecraft/entity/EntityLivingBase;)Z")) + private boolean setOutlineColor(RendererLivingEntity instance, T entityLivingBaseIn) { + int i = 16777215; + boolean drawOutline = shouldRender() && ((entityLivingBaseIn != Minecraft.getMinecraft().thePlayer && !AntiBot.isBot(entityLivingBaseIn)) || (entityLivingBaseIn == Minecraft.getMinecraft().thePlayer && ModuleManager.playerESP.renderSelf.isToggled())); + + if (!drawOutline || ModuleManager.playerESP.teamColor.isToggled()) + { + if (entityLivingBaseIn instanceof EntityPlayer) + { + ScorePlayerTeam scoreplayerteam = (ScorePlayerTeam)entityLivingBaseIn.getTeam(); + + if (scoreplayerteam != null) + { + String s = FontRenderer.getFormatFromString(scoreplayerteam.getColorPrefix()); + + if (s.length() >= 2) + { + i = this.getFontRendererFromRenderManager().getColorCode(s.charAt(1)); + } + } + } + } + else if (ModuleManager.playerESP.rainbow.isToggled()) { + i = Utils.getChroma(2L, 0L); + } + else { + i = (new Color((int) ModuleManager.playerESP.red.getInput(), (int) ModuleManager.playerESP.green.getInput(), (int) ModuleManager.playerESP.blue.getInput())).getRGB(); + } + + if (drawOutline && ModuleManager.playerESP.redOnDamage.isToggled() && entityLivingBaseIn.hurtTime != 0) { + i = Color.RED.getRGB(); + } + + float f1 = (float)(i >> 16 & 255) / 255.0F; + float f2 = (float)(i >> 8 & 255) / 255.0F; + float f = (float)(i & 255) / 255.0F; + GlStateManager.disableLighting(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + GlStateManager.color(f1, f2, f, 1.0F); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + return true; + } + + @ModifyVariable(method = "renderModel", at = @At(value = "STORE"), ordinal = 0) + private boolean modifyInvisibleFlag(boolean flag) { + return flag || (this.renderOutlines && shouldRender() && ModuleManager.playerESP.showInvis.isToggled()); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/world/MixinBlock.java b/src/main/java/keystrokesmod/mixin/impl/world/MixinBlock.java index 8c374a7..ed455be 100644 --- a/src/main/java/keystrokesmod/mixin/impl/world/MixinBlock.java +++ b/src/main/java/keystrokesmod/mixin/impl/world/MixinBlock.java @@ -1,34 +1,34 @@ -package keystrokesmod.mixin.impl.world; - -import java.util.List; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -import keystrokesmod.event.CollisionEvent; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; - -@Mixin(Block.class) -public abstract class MixinBlock { - @Shadow - public abstract AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state); - - @Overwrite - public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { - AxisAlignedBB axisalignedbb = this.getCollisionBoundingBox(worldIn, pos, state); - CollisionEvent event = new CollisionEvent(pos, (Block)(Object)this, axisalignedbb); - MinecraftForge.EVENT_BUS.post(event); - axisalignedbb = event.boundingBox; - if (axisalignedbb != null && mask.intersectsWith(axisalignedbb)) { - list.add(axisalignedbb); - } - } -} - +package keystrokesmod.mixin.impl.world; + +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import keystrokesmod.event.CollisionEvent; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +@Mixin(Block.class) +public abstract class MixinBlock { + @Shadow + public abstract AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state); + + @Overwrite + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { + AxisAlignedBB axisalignedbb = this.getCollisionBoundingBox(worldIn, pos, state); + CollisionEvent event = new CollisionEvent(pos, (Block)(Object)this, axisalignedbb); + MinecraftForge.EVENT_BUS.post(event); + axisalignedbb = event.boundingBox; + if (axisalignedbb != null && mask.intersectsWith(axisalignedbb)) { + list.add(axisalignedbb); + } + } +} + diff --git a/src/main/java/keystrokesmod/mixin/impl/world/MixinWorld.java b/src/main/java/keystrokesmod/mixin/impl/world/MixinWorld.java index 9d7f99a..413b877 100644 --- a/src/main/java/keystrokesmod/mixin/impl/world/MixinWorld.java +++ b/src/main/java/keystrokesmod/mixin/impl/world/MixinWorld.java @@ -1,45 +1,45 @@ -package keystrokesmod.mixin.impl.world; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.storage.WorldInfo; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@SideOnly(Side.CLIENT) -@Mixin(World.class) -public class MixinWorld { - @Shadow - @Final - public boolean isRemote; - - @Inject(method = "getThunderStrength", at = @At("RETURN"), cancellable = true) - public void setThunderStrength(CallbackInfoReturnable clr) { - if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.lightning.getInput() > 0) { - clr.setReturnValue((float) ModuleManager.weather.lightning.getInput()); - } - } - - @Inject(method = "getRainStrength", at = @At("RETURN"), cancellable = true) - public void setPrecipitationStrength(CallbackInfoReturnable clr) { - if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.rain.isToggled()) { - clr.setReturnValue(1F); - } - } - - @Redirect(method = {"getMoonPhase", "getCelestialAngle"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;getWorldTime()J")) - private long setTimeForMoonPhase(WorldInfo worldInfo) { - if (ModuleManager.weather != null && ModuleManager.weather.isEnabled()) { - return (long) MathHelper.clamp_double((ModuleManager.weather.time.getInput() * 1000), 0, 23999); - } - return worldInfo.getWorldTime(); - } +package keystrokesmod.mixin.impl.world; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@SideOnly(Side.CLIENT) +@Mixin(World.class) +public class MixinWorld { + @Shadow + @Final + public boolean isRemote; + + @Inject(method = "getThunderStrength", at = @At("RETURN"), cancellable = true) + public void setThunderStrength(CallbackInfoReturnable clr) { + if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.lightning.getInput() > 0) { + clr.setReturnValue((float) ModuleManager.weather.lightning.getInput()); + } + } + + @Inject(method = "getRainStrength", at = @At("RETURN"), cancellable = true) + public void setPrecipitationStrength(CallbackInfoReturnable clr) { + if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.rain.isToggled()) { + clr.setReturnValue(1F); + } + } + + @Redirect(method = {"getMoonPhase", "getCelestialAngle"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;getWorldTime()J")) + private long setTimeForMoonPhase(WorldInfo worldInfo) { + if (ModuleManager.weather != null && ModuleManager.weather.isEnabled()) { + return (long) MathHelper.clamp_double((ModuleManager.weather.time.getInput() * 1000), 0, 23999); + } + return worldInfo.getWorldTime(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/impl/world/MixinWorldInfo.java b/src/main/java/keystrokesmod/mixin/impl/world/MixinWorldInfo.java index e0fdcc0..8dd8068 100644 --- a/src/main/java/keystrokesmod/mixin/impl/world/MixinWorldInfo.java +++ b/src/main/java/keystrokesmod/mixin/impl/world/MixinWorldInfo.java @@ -1,22 +1,22 @@ -package keystrokesmod.mixin.impl.world; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.world.storage.WorldInfo; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -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; - -@SideOnly(Side.CLIENT) -@Mixin(WorldInfo.class) -public abstract class MixinWorldInfo { - - @Inject(method = "isRaining", at = @At("RETURN"), cancellable = true) - private void setPrecipitation(CallbackInfoReturnable clr) { - if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.rain.isToggled()) { - clr.setReturnValue(true); - } - } +package keystrokesmod.mixin.impl.world; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +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; + +@SideOnly(Side.CLIENT) +@Mixin(WorldInfo.class) +public abstract class MixinWorldInfo { + + @Inject(method = "isRaining", at = @At("RETURN"), cancellable = true) + private void setPrecipitation(CallbackInfoReturnable clr) { + if (ModuleManager.weather != null && ModuleManager.weather.isEnabled() && ModuleManager.weather.rain.isToggled()) { + clr.setReturnValue(true); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/mixin/interfaces/IMixinItemRenderer.java b/src/main/java/keystrokesmod/mixin/interfaces/IMixinItemRenderer.java index 0eb5f74..7545663 100644 --- a/src/main/java/keystrokesmod/mixin/interfaces/IMixinItemRenderer.java +++ b/src/main/java/keystrokesmod/mixin/interfaces/IMixinItemRenderer.java @@ -1,7 +1,7 @@ -package keystrokesmod.mixin.interfaces; - -public interface IMixinItemRenderer { - void setCancelUpdate(boolean cancel); - - void setCancelReset(boolean reset); +package keystrokesmod.mixin.interfaces; + +public interface IMixinItemRenderer { + void setCancelUpdate(boolean cancel); + + void setCancelReset(boolean reset); } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/Module.java b/src/main/java/keystrokesmod/module/Module.java index 8585c6a..78d7fc7 100644 --- a/src/main/java/keystrokesmod/module/Module.java +++ b/src/main/java/keystrokesmod/module/Module.java @@ -1,7 +1,6 @@ package keystrokesmod.module; import keystrokesmod.Raven; -import keystrokesmod.module.impl.combat.AntiKnockback; import keystrokesmod.module.setting.Setting; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; @@ -188,9 +187,6 @@ public class Module { } public String getNameInHud() { - if (this instanceof AntiKnockback) { - return "Velocity"; - } return this.moduleName; } diff --git a/src/main/java/keystrokesmod/module/ModuleManager.java b/src/main/java/keystrokesmod/module/ModuleManager.java index 146ee74..6581599 100644 --- a/src/main/java/keystrokesmod/module/ModuleManager.java +++ b/src/main/java/keystrokesmod/module/ModuleManager.java @@ -46,7 +46,7 @@ public class ModuleManager { public static Module timer; public static Fly fly; public static Module wTap; - public static TargetHUD targetHUD; + public static TargetInfo targetInfo; public static NoFall noFall; public static Disabler disabler; public static NoRotate noRotate; @@ -77,6 +77,8 @@ public class ModuleManager { public static AntiVoid antiVoid; public static Spammer spammer; public static AntiDebuff antiDebuff; + public static Timers timers; + public static LagRange lagRange; public void register() { this.addModule(autoClicker = new AutoClicker()); @@ -141,7 +143,7 @@ public class ModuleManager { this.addModule(wTap = new WTap()); this.addModule(new Xray()); this.addModule(new BridgeInfo()); - this.addModule(targetHUD = new TargetHUD()); + this.addModule(targetInfo = new TargetInfo()); this.addModule(new DuelsStats()); this.addModule(antiFireball = new AntiFireball()); this.addModule(bedESP = new BedESP()); @@ -165,7 +167,6 @@ public class ModuleManager { this.addModule(bedwars = new BedWars()); this.addModule(fastMine = new FastMine()); this.addModule(arrows = new Arrows()); - this.addModule(new JumpReset()); this.addModule(new Manager()); this.addModule(new ViewPackets()); this.addModule(new AutoWho()); @@ -177,6 +178,8 @@ public class ModuleManager { this.addModule(antiVoid = new AntiVoid()); this.addModule(spammer = new Spammer()); this.addModule(antiDebuff = new AntiDebuff()); + this.addModule(timers = new Timers()); + this.addModule(lagRange = new LagRange()); antiBot.enable(); Collections.sort(this.modules, Comparator.comparing(Module::getName)); } diff --git a/src/main/java/keystrokesmod/module/impl/client/ChatCommands.java b/src/main/java/keystrokesmod/module/impl/client/ChatCommands.java index 7591a0a..c1c2284 100644 --- a/src/main/java/keystrokesmod/module/impl/client/ChatCommands.java +++ b/src/main/java/keystrokesmod/module/impl/client/ChatCommands.java @@ -1,18 +1,18 @@ -package keystrokesmod.module.impl.client; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; - -public class ChatCommands extends Module { - public ButtonSetting lowercase; - public ChatCommands() { - super("Chat Commands", category.client); - this.registerSetting(new DescriptionSetting("Use §o§e.help§r for help.")); - this.registerSetting(lowercase = new ButtonSetting("Lowercase", false)); - } - - public boolean lowercase() { - return this.lowercase != null && this.lowercase.isToggled(); - } -} +package keystrokesmod.module.impl.client; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; + +public class ChatCommands extends Module { + public ButtonSetting lowercase; + public ChatCommands() { + super("Chat Commands", category.client); + this.registerSetting(new DescriptionSetting("Use §o§e.help§r for help.")); + this.registerSetting(lowercase = new ButtonSetting("Lowercase", false)); + } + + public boolean lowercase() { + return this.lowercase != null && this.lowercase.isToggled(); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/client/Settings.java b/src/main/java/keystrokesmod/module/impl/client/Settings.java index a40f0b1..65ad087 100644 --- a/src/main/java/keystrokesmod/module/impl/client/Settings.java +++ b/src/main/java/keystrokesmod/module/impl/client/Settings.java @@ -1,95 +1,95 @@ -package keystrokesmod.module.impl.client; - -import keystrokesmod.Raven; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.util.ResourceLocation; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Settings extends Module { - public static SliderSetting customCapes; - public static ButtonSetting weaponAxe; - public static ButtonSetting weaponRod; - public static ButtonSetting weaponStick; - public static ButtonSetting middleClickFriends; - public static ButtonSetting setChatAsInventory; - - public static ButtonSetting rotateBody; - public static ButtonSetting fullBody; - public static ButtonSetting movementFix; - public static SliderSetting randomYawFactor; - - public static ButtonSetting loadGuiPositions; - public static ButtonSetting sendMessage; - - public static SliderSetting offset; - public static SliderSetting timeMultiplier; - - private String[] capes = new String[] { "None", "Anime", "Aqua", "Green", "Purple", "Red", "White", "Yellow" }; - - public static List loadedCapes = new ArrayList<>(); - - public Settings() { - super("Settings", category.client, 0); - this.registerSetting(new DescriptionSetting("General")); - this.registerSetting(customCapes = new SliderSetting("Custom cape", 0, capes)); - this.registerSetting(weaponAxe = new ButtonSetting("Set axe as weapon", false)); - this.registerSetting(weaponRod = new ButtonSetting("Set rod as weapon", false)); - this.registerSetting(weaponStick = new ButtonSetting("Set stick as weapon", false)); - this.registerSetting(middleClickFriends = new ButtonSetting("Middle click friends", false)); - this.registerSetting(setChatAsInventory = new ButtonSetting("Set chat as inventory", false)); - this.registerSetting(new DescriptionSetting("Rotations")); - this.registerSetting(rotateBody = new ButtonSetting("Rotate body", true)); - this.registerSetting(fullBody = new ButtonSetting("Full body", false)); - this.registerSetting(movementFix = new ButtonSetting("Movement fix", false)); - this.registerSetting(randomYawFactor = new SliderSetting("Random yaw factor", 1.0, 0.0, 10.0, 1.0)); - this.registerSetting(new DescriptionSetting("Profiles")); - this.registerSetting(loadGuiPositions = new ButtonSetting("Load gui state", false)); - this.registerSetting(sendMessage = new ButtonSetting("Send message on enable", true)); - this.registerSetting(new DescriptionSetting("Theme colors")); - this.registerSetting(offset = new SliderSetting("Offset", 0.5, -3.0, 3.0, 0.1)); - this.registerSetting(timeMultiplier = new SliderSetting("Time multiplier", 0.5, 0.1, 4.0, 0.1)); - this.canBeEnabled = false; - loadCapes(); - } - - public void loadCapes() { - try { - for (int i = 1; i < capes.length; i++) { - String name = capes[i].toLowerCase(); - if (i > 1) { - name = "rvn_" + name; - } - InputStream stream = Raven.class.getResourceAsStream("/assets/keystrokesmod/textures/capes/" + name + ".png"); - if (stream == null) { - continue; - } - BufferedImage bufferedImage = ImageIO.read(stream); - loadedCapes.add(mc.renderEngine.getDynamicTextureLocation(name, new DynamicTexture(bufferedImage))); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - - public static boolean inInventory() { - if (mc.currentScreen instanceof GuiInventory) { - return true; - } - if (mc.currentScreen instanceof GuiChat && setChatAsInventory.isToggled()) { - return true; - } - return false; - } -} +package keystrokesmod.module.impl.client; + +import keystrokesmod.Raven; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.ResourceLocation; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class Settings extends Module { + public static SliderSetting customCapes; + public static ButtonSetting weaponAxe; + public static ButtonSetting weaponRod; + public static ButtonSetting weaponStick; + public static ButtonSetting middleClickFriends; + public static ButtonSetting setChatAsInventory; + + public static ButtonSetting rotateBody; + public static ButtonSetting fullBody; + public static ButtonSetting movementFix; + public static SliderSetting randomYawFactor; + + public static ButtonSetting loadGuiPositions; + public static ButtonSetting sendMessage; + + public static SliderSetting offset; + public static SliderSetting timeMultiplier; + + private String[] capes = new String[] { "None", "Anime", "Aqua", "Green", "Purple", "Red", "White", "Yellow" }; + + public static List loadedCapes = new ArrayList<>(); + + public Settings() { + super("Settings", category.client, 0); + this.registerSetting(new DescriptionSetting("General")); + this.registerSetting(customCapes = new SliderSetting("Custom cape", 0, capes)); + this.registerSetting(weaponAxe = new ButtonSetting("Set axe as weapon", false)); + this.registerSetting(weaponRod = new ButtonSetting("Set rod as weapon", false)); + this.registerSetting(weaponStick = new ButtonSetting("Set stick as weapon", false)); + this.registerSetting(middleClickFriends = new ButtonSetting("Middle click friends", false)); + this.registerSetting(setChatAsInventory = new ButtonSetting("Set chat as inventory", false)); + this.registerSetting(new DescriptionSetting("Rotations")); + this.registerSetting(rotateBody = new ButtonSetting("Rotate body", true)); + this.registerSetting(fullBody = new ButtonSetting("Full body", false)); + this.registerSetting(movementFix = new ButtonSetting("Movement fix", false)); + this.registerSetting(randomYawFactor = new SliderSetting("Random yaw factor", 1.0, 0.0, 10.0, 1.0)); + this.registerSetting(new DescriptionSetting("Profiles")); + this.registerSetting(loadGuiPositions = new ButtonSetting("Load gui state", false)); + this.registerSetting(sendMessage = new ButtonSetting("Send message on enable", true)); + this.registerSetting(new DescriptionSetting("Theme colors")); + this.registerSetting(offset = new SliderSetting("Offset", 0.5, -3.0, 3.0, 0.1)); + this.registerSetting(timeMultiplier = new SliderSetting("Time multiplier", 0.5, 0.1, 4.0, 0.1)); + this.canBeEnabled = false; + loadCapes(); + } + + public void loadCapes() { + try { + for (int i = 1; i < capes.length; i++) { + String name = capes[i].toLowerCase(); + if (i > 1) { + name = "rvn_" + name; + } + InputStream stream = Raven.class.getResourceAsStream("/assets/keystrokesmod/textures/capes/" + name + ".png"); + if (stream == null) { + continue; + } + BufferedImage bufferedImage = ImageIO.read(stream); + loadedCapes.add(mc.renderEngine.getDynamicTextureLocation(name, new DynamicTexture(bufferedImage))); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + public static boolean inInventory() { + if (mc.currentScreen instanceof GuiInventory) { + return true; + } + if (mc.currentScreen instanceof GuiChat && setChatAsInventory.isToggled()) { + return true; + } + return false; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/combat/AimAssist.java b/src/main/java/keystrokesmod/module/impl/combat/AimAssist.java index 6b36067..5454701 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/AimAssist.java +++ b/src/main/java/keystrokesmod/module/impl/combat/AimAssist.java @@ -11,8 +11,11 @@ import keystrokesmod.utility.RotationUtils; import keystrokesmod.utility.Utils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Mouse; public class AimAssist extends Module { @@ -22,10 +25,9 @@ public class AimAssist extends Module { private SliderSetting distance; private ButtonSetting clickAim; - private ButtonSetting disableWhileMining; private ButtonSetting weaponOnly; + private ButtonSetting disableWhileMining; private ButtonSetting aimInvis; - private ButtonSetting blatantMode; private ButtonSetting ignoreTeammates; private String[] aimModes = new String[] { "Normal", "Silent" }; @@ -42,58 +44,72 @@ public class AimAssist extends Module { this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); this.registerSetting(disableWhileMining = new ButtonSetting("Disable while mining", false)); this.registerSetting(aimInvis = new ButtonSetting("Aim invis", false)); - this.registerSetting(blatantMode = new ButtonSetting("Blatant mode", false)); this.registerSetting(ignoreTeammates = new ButtonSetting("Ignore teammates", false)); } @Override public String getInfo() { - String info; - info = aimModes[(int) mode.getInput()]; - return info; + return aimModes[(int) mode.getInput()]; } - @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { this.lookingAt = null; - if (mc.currentScreen != null || !mc.inGameHasFocus) { + if (mode.getInput() == 0 || !conditionsMet()) { return; } - if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { - return; - } - if (clickAim.isToggled() && !Utils.isClicking()) { - return; - } - if (disableWhileMining.isToggled() && Utils.isMining()) { - return; - } - Entity en = this.getEnemy(); if (en == null) { return; } - if (blatantMode.isToggled()) { + if (speed.getInput() == 100) { float[] rotations = RotationUtils.getRotations(en); if (rotations != null) { float yaw = rotations[0]; - float pitch = MathHelper.clamp_float(rotations[1] + 4.0F, -90, 90); + float pitch = MathHelper.clamp_float(rotations[1], -90, 90); RotationHelper.get().setRotations(yaw, pitch); - lookingAt = new Float[] { yaw, pitch }; + lookingAt = (new Float[] { yaw, pitch }); } } else { double diff = Utils.aimDifference(en, this.mode.getInput() == 1); float val = (float) ( -( diff / (101.0D - speed.getInput()) ) ) * 1.2F; - float yaw = RotationUtils.serverRotations[0] + val; + float[] rots = RotationUtils.serverRotations; + float yaw = rots[0] + val; RotationHelper.get().setYaw(yaw); lookingAt = new Float[] { yaw }; } } + @Override + public void onUpdate() { + if (mode.getInput() == 1 || !conditionsMet()) { + return; + } + Entity en = this.getEnemy(); + if (en == null) { + return; + } + if (speed.getInput() == 100) { + float[] t = Utils.getRotationsOld(en); + if (t != null) { + float y = t[0]; + float p = t[1]; + mc.thePlayer.rotationYaw = y; + mc.thePlayer.rotationPitch = p; + } + } + else { + double n = Utils.aimDifference(en, false); + if (n > 1.0D || n < -1.0D) { + float val = (float) (-(n / (101.0D - (speed.getInput())))); + mc.thePlayer.rotationYaw += val; + } + } + } + @SubscribeEvent public void onClientLook(ClientLookEvent e) { if (this.lookingAt == null) { @@ -128,7 +144,7 @@ public class AimAssist extends Module { if (AntiBot.isBot(entityPlayer)) { continue; } - if (!blatantMode.isToggled() && n != 360 && !Utils.inFov((float)n, entityPlayer)) { + if (n != 360 && !Utils.inFov((float)n, entityPlayer)) { continue; } return entityPlayer; @@ -137,4 +153,24 @@ public class AimAssist extends Module { return null; } + private boolean conditionsMet() { + if (mc.currentScreen != null || !mc.inGameHasFocus) { + return false; + } + if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { + return false; + } + if (clickAim.isToggled() && !Utils.isClicking()) { + return false; + } + if (disableWhileMining.isToggled() && isMining()) { + return false; + } + return true; + } + + private boolean isMining() { + return Mouse.isButtonDown(0) && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.objectMouseOver.getBlockPos() != null; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/AntiKnockback.java b/src/main/java/keystrokesmod/module/impl/combat/AntiKnockback.java deleted file mode 100644 index 167076f..0000000 --- a/src/main/java/keystrokesmod/module/impl/combat/AntiKnockback.java +++ /dev/null @@ -1,131 +0,0 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Mouse; - -public class AntiKnockback extends Module { - private SliderSetting horizontal; - private SliderSetting vertical; - private ButtonSetting disableInLobby; - private ButtonSetting cancelBurning; - private ButtonSetting cancelExplosion; - private ButtonSetting cancelWhileFalling; - private ButtonSetting cancelOffGround; - private SliderSetting boostMultiplier; - private ButtonSetting boostWithLMB; - - public boolean disable; - - public AntiKnockback() { - super("AntiKnockback", category.combat); - this.registerSetting(new DescriptionSetting("Overrides Velocity.")); - this.registerSetting(horizontal = new SliderSetting("Horizontal", 0.0, 0.0, 100.0, 1.0)); - this.registerSetting(vertical = new SliderSetting("Vertical", 0.0, 0.0, 100.0, 1.0)); - this.registerSetting(disableInLobby = new ButtonSetting("Disable in lobby", false)); - this.registerSetting(cancelBurning = new ButtonSetting("Cancel burning", true)); - this.registerSetting(cancelExplosion = new ButtonSetting("Cancel explosion", true)); - this.registerSetting(cancelWhileFalling = new ButtonSetting("Cancel while falling", true)); - this.registerSetting(cancelOffGround = new ButtonSetting("Cancel off ground", true)); - this.registerSetting(boostMultiplier = new SliderSetting("Damage boost", "x", 1, 0.5, 2.5, 0.01)); - this.registerSetting(boostWithLMB = new ButtonSetting("Boost with LMB", false)); - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (!Utils.nullCheck() || LongJump.stopVelocity || e.isCanceled()) { - return; - } - if (e.getPacket() instanceof S12PacketEntityVelocity) { - if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId() && !disable) { - if (!cancelBurning.isToggled() && mc.thePlayer.isBurning()) { - return; - } - if (disableInLobby.isToggled() && Utils.isLobby()) { - return; - } - e.setCanceled(true); - if (cancel()) { - return; - } - if (cancelConditions()) { - return; - } - S12PacketEntityVelocity s12PacketEntityVelocity = (S12PacketEntityVelocity) e.getPacket(); - if (horizontal.getInput() == 0 && vertical.getInput() > 0) { - mc.thePlayer.motionY = ((double) s12PacketEntityVelocity.getMotionY() / 8000) * vertical.getInput() / 100.0; - } - else if (horizontal.getInput() > 0 && vertical.getInput() == 0) { - mc.thePlayer.motionX = ((double) s12PacketEntityVelocity.getMotionX() / 8000) * horizontal.getInput() / 100.0; - mc.thePlayer.motionZ = ((double) s12PacketEntityVelocity.getMotionZ() / 8000) * horizontal.getInput() / 100.0; - } - else { - mc.thePlayer.motionX = ((double) s12PacketEntityVelocity.getMotionX() / 8000) * horizontal.getInput() / 100.0; - mc.thePlayer.motionY = ((double) s12PacketEntityVelocity.getMotionY() / 8000) * vertical.getInput() / 100.0; - mc.thePlayer.motionZ = ((double) s12PacketEntityVelocity.getMotionZ() / 8000) * horizontal.getInput() / 100.0; - } - if (boostMultiplier.getInput() != 1) { - if (boostWithLMB.isToggled() && !Mouse.isButtonDown(0)) { - return; - } - Utils.setSpeed(Utils.getHorizontalSpeed() * boostMultiplier.getInput()); - } - } - } - else if (e.getPacket() instanceof S27PacketExplosion && !disable) { - if (disableInLobby.isToggled() && Utils.isLobby()) { - return; - } - e.setCanceled(true); - if (cancelExplosion.isToggled() || cancel()) { - return; - } - if (cancelConditions()) { - return; - } - S27PacketExplosion s27PacketExplosion = (S27PacketExplosion) e.getPacket(); - if (horizontal.getInput() == 0 && vertical.getInput() > 0) { - mc.thePlayer.motionY += s27PacketExplosion.func_149144_d() * vertical.getInput() / 100.0; - } - else if (horizontal.getInput() > 0 && vertical.getInput() == 0) { - mc.thePlayer.motionX += s27PacketExplosion.func_149149_c() * horizontal.getInput() / 100.0; - mc.thePlayer.motionZ += s27PacketExplosion.func_149147_e() * horizontal.getInput() / 100.0; - } - else { - mc.thePlayer.motionX += s27PacketExplosion.func_149149_c() * horizontal.getInput() / 100.0; - mc.thePlayer.motionY += s27PacketExplosion.func_149144_d() * vertical.getInput() / 100.0; - mc.thePlayer.motionZ += s27PacketExplosion.func_149147_e() * horizontal.getInput() / 100.0; - } - } - } - - private boolean cancel() { - return (vertical.getInput() == 0 && horizontal.getInput() == 0) || ModuleManager.bedAura.cancelKnockback(); - } - - @Override - public String getInfo() { - return (int) horizontal.getInput() + "%" + " " + (int) vertical.getInput() + "%"; - } - - private boolean cancelConditions() { - if (mc.thePlayer != null) { - if (cancelWhileFalling.isToggled() && mc.thePlayer.fallDistance > 0) { - return true; - } - if (cancelOffGround.isToggled() && !mc.thePlayer.onGround) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java b/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java index 9fc0fa9..db586cd 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java +++ b/src/main/java/keystrokesmod/module/impl/combat/AutoClicker.java @@ -86,6 +86,9 @@ public class AutoClicker extends Module { @SubscribeEvent public void onRenderTick(RenderTickEvent ev) { if (ev.phase != Phase.END && Utils.nullCheck() && !Utils.isConsuming(mc.thePlayer)) { + if (ModuleManager.killAura.isEnabled() && KillAura.target != null || ModuleManager.scaffold.isEnabled) { + return; + } if (disableCreative.isToggled() && mc.thePlayer.capabilities.isCreativeMode) { return; } @@ -135,7 +138,7 @@ public class AutoClicker extends Module { if (pos != null) { Block block = mc.theWorld.getBlockState(pos).getBlock(); if (block != Blocks.air && !(block instanceof BlockLiquid)) { - if (!this.isHoldingBlockBreak && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { + if (!this.isHoldingBlockBreak) { KeyBinding.setKeyBindState(key, true); KeyBinding.onTick(key); this.isHoldingBlockBreak = true; @@ -171,7 +174,7 @@ public class AutoClicker extends Module { if (this.nextPressTime > 0L && this.nextReleaseTime > 0L) { double blockHitC = blockHitChance.getInput(); long currentTime = System.currentTimeMillis(); - if (currentTime > this.nextPressTime && (!ModuleManager.killAura.isEnabled() || KillAura.target == null)) { + if (currentTime > this.nextPressTime) { KeyBinding.setKeyBindState(key, true); KeyBinding.onTick(key); ReflectionUtils.setButton(mouse, true); diff --git a/src/main/java/keystrokesmod/module/impl/combat/JumpReset.java b/src/main/java/keystrokesmod/module/impl/combat/JumpReset.java deleted file mode 100644 index f78499f..0000000 --- a/src/main/java/keystrokesmod/module/impl/combat/JumpReset.java +++ /dev/null @@ -1,103 +0,0 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.Raven; -import keystrokesmod.event.PostMotionEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Mouse; - -public class JumpReset extends Module { - private SliderSetting chance; - - private ButtonSetting requireMouseDown; - private ButtonSetting requireMovingForward; - private ButtonSetting requireAim; - - private boolean setJump; - private boolean ignoreNext; - private boolean aiming; - private int lastHurtTime; - private double lastFallDistance; - - public JumpReset() { - super("Jump Reset", category.combat); - this.registerSetting(chance = new SliderSetting("Chance", "%", 80, 0, 100, 1)); - this.registerSetting(requireMouseDown = new ButtonSetting("Require mouse down", false)); - this.registerSetting(requireMovingForward = new ButtonSetting("Require moving forward", true)); - this.registerSetting(requireAim = new ButtonSetting("Require aim", true)); - this.closetModule = true; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - int hurtTime = mc.thePlayer.hurtTime; - boolean onGround = mc.thePlayer.onGround; - - if (onGround && lastFallDistance > 3 && !mc.thePlayer.capabilities.allowFlying) ignoreNext = true; - - if (hurtTime > lastHurtTime) { - - boolean mouseDown = Mouse.isButtonDown(0) || !requireMouseDown.isToggled(); - boolean aimingAt = aiming || !requireAim.isToggled(); - - boolean forward = mc.gameSettings.keyBindForward.isKeyDown() || !requireMovingForward.isToggled(); - - if (!ignoreNext && onGround && aimingAt && forward && mouseDown && Utils.randomizeDouble(0, 100) < chance.getInput() && !hasBadEffect()) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), setJump = true); - KeyBinding.onTick(mc.gameSettings.keyBindJump.getKeyCode()); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7jumping enabled"); - } - } - ignoreNext = false; - } - - lastHurtTime = hurtTime; - lastFallDistance = mc.thePlayer.fallDistance; - } - - @SubscribeEvent - public void onPostMotion(PostMotionEvent e) { - if (setJump && !Utils.jumpDown()) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), setJump = false); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7jumping disabled"); - } - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (e.getPacket() instanceof C03PacketPlayer.C05PacketPlayerLook) { - checkAim(((C03PacketPlayer.C05PacketPlayerLook) e.getPacket()).getYaw(), ((C03PacketPlayer.C05PacketPlayerLook) e.getPacket()).getPitch()); - } - else if (e.getPacket() instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - checkAim(((C03PacketPlayer.C06PacketPlayerPosLook) e.getPacket()).getYaw(), ((C03PacketPlayer.C06PacketPlayerPosLook) e.getPacket()).getPitch()); - } - } - - private boolean hasBadEffect() { - for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { - String name = potionEffect.getEffectName(); - return name.equals("potion.jump") || name.equals("potion.poison") || name.equals("potion.wither"); - } - return false; - } - - private void checkAim(float yaw, float pitch) { - MovingObjectPosition result = RotationUtils.rayTrace(5, ((IAccessorMinecraft) mc).getTimer().renderPartialTicks, new float[] { yaw, pitch }, null); - aiming = result != null && result.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && result.entityHit instanceof EntityOtherPlayerMP; - } -} diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index 0ce7466..0e357f1 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -1,1220 +1,1220 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.Raven; -import keystrokesmod.event.*; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.minigames.SkyWars; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.*; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.monster.EntityGiantZombie; -import net.minecraft.entity.monster.EntityIronGolem; -import net.minecraft.entity.monster.EntityPigZombie; -import net.minecraft.entity.monster.EntitySilverfish; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.network.Packet; -import net.minecraft.network.handshake.client.C00Handshake; -import net.minecraft.network.login.client.C00PacketLoginStart; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraft.util.*; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.input.Mouse; - -import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import static net.minecraft.util.EnumFacing.DOWN; - - -public class KillAura extends Module { - private SliderSetting aps; - public SliderSetting autoBlockMode; - private SliderSetting fov; - private SliderSetting attackRange; - private SliderSetting swingRange; - private SliderSetting blockRange; - public SliderSetting rotationMode; - public SliderSetting rotateMode; - private SliderSetting rotationSmoothing; - private SliderSetting sortMode; - private SliderSetting switchDelay; - private SliderSetting targets; - private ButtonSetting attackMobs; - private ButtonSetting targetInvis; - private ButtonSetting disableInInventory; - private ButtonSetting disableWhileBlocking; - private ButtonSetting disableWhileMining; - private ButtonSetting hitThroughBlocks; - private ButtonSetting ignoreTeammates; - public ButtonSetting manualBlock; - private ButtonSetting prioritizeEnemies; - private ButtonSetting requireMouseDown; - private ButtonSetting silentSwing; - private ButtonSetting weaponOnly; - - private String[] autoBlockModes = new String[] { "Manual", "Vanilla", "Partial", "Blink", "Swap" }; - private String[] rotationModes = new String[] { "Silent", "Lock view", "None" }; - private String[] rotateModes = new String[] { "Attack", "Swing" }; - private String[] sortModes = new String[] { "Distance", "Health", "Hurttime", "Yaw" }; - - // autoblock related - private String[] swapBlacklist = { "compass", "snowball", "spawn", "skull" }; - - // target variables - public static EntityLivingBase target; - public static EntityLivingBase attackingEntity; - private HashMap hitMap = new HashMap<>(); // entity id, ticks existed client - private List hostileMobs = new ArrayList<>(); - private Map golems = new HashMap<>(); // entity id, is teammate - - // blocking related - public boolean blockingClient; - public boolean blockingServer; - private int interactTicks; - private boolean firstCycle; - private boolean partialDown; - private int partialTicks; - private boolean wasUsing; - - // blink related - private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - public AtomicBoolean blinking = new AtomicBoolean(false); - private boolean lag; - private boolean swapped; - private int firstCycleTicks; - private int firstEdge; - - // other - private long lastTime = 0L; - private long delay; - private boolean shouldAttack; - private int previousAutoBlockMode; - private boolean reset; - private boolean rotated; - private boolean sendUnBlock; - private int delayTicks = 0; - private boolean lastPressedLeft; - private boolean lastPressedRight; - public boolean stoppedTargeting; // can only be true for 1 tick - public static boolean blinkOn, blinkChecked; - public boolean targeting, rotating; - private int cycle; - public int sAttacked; - private int lastSet; - - public ConcurrentLinkedQueue> delayedKnockBackPackets = new ConcurrentLinkedQueue<>(); - - public KillAura() { - super("KillAura", category.combat); - this.registerSetting(aps = new SliderSetting("APS", 16.0, 1.0, 20.0, 0.5)); - this.registerSetting(autoBlockMode = new SliderSetting("Autoblock", 0, autoBlockModes)); - this.registerSetting(fov = new SliderSetting("FOV", 360.0, 30.0, 360.0, 4.0)); - this.registerSetting(attackRange = new SliderSetting("Range (attack)", 3.0, 3.0, 6.0, 0.05)); - this.registerSetting(swingRange = new SliderSetting("Range (swing)", 3.3, 3.0, 8.0, 0.05)); - this.registerSetting(blockRange = new SliderSetting("Range (block)", 6.0, 3.0, 12.0, 0.05)); - this.registerSetting(rotationMode = new SliderSetting("Rotation mode", 0, rotationModes)); - this.registerSetting(rotateMode = new SliderSetting("Rotate on", 0, rotateModes)); - this.registerSetting(rotationSmoothing = new SliderSetting("Rotation smoothing", 0, 0, 10, 1)); - this.registerSetting(sortMode = new SliderSetting("Sort mode", 0, sortModes)); - this.registerSetting(switchDelay = new SliderSetting("Switch delay", "ms", 200.0, 50.0, 1000.0, 25.0)); - this.registerSetting(targets = new SliderSetting("Targets", 3.0, 1.0, 10.0, 1.0)); - this.registerSetting(targetInvis = new ButtonSetting("Target invis", true)); - this.registerSetting(attackMobs = new ButtonSetting("Attack mobs", false)); - this.registerSetting(disableInInventory = new ButtonSetting("Disable in inventory", true)); - this.registerSetting(disableWhileBlocking = new ButtonSetting("Disable while blocking", false)); - this.registerSetting(disableWhileMining = new ButtonSetting("Disable while mining", false)); - this.registerSetting(hitThroughBlocks = new ButtonSetting("Hit through blocks", true)); - this.registerSetting(ignoreTeammates = new ButtonSetting("Ignore teammates", true)); - this.registerSetting(manualBlock = new ButtonSetting("Manual block", false)); // does absolutely nothing - this.registerSetting(prioritizeEnemies = new ButtonSetting("Prioritize enemies", false)); - this.registerSetting(requireMouseDown = new ButtonSetting("Require mouse down", false)); - this.registerSetting(silentSwing = new ButtonSetting("Silent swing while blocking", false)); - this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); - } - - @Override - public String getInfo() { - if (rotationMode.getInput() == 2) { // None, return FOV if rotation mode is none - return String.valueOf((int) this.fov.getInput()); - } - return rotationModes[(int) rotationMode.getInput()]; - } - - @Override - public void onEnable() { - if (rotationMode.getInput() == 0 && autoBlockMode.getInput() <= 1) { - delayTicks = 1; - } - } - - @Override - public void onDisable() { - handleBlocking(false); - hitMap.clear(); - lastSet = 0; - if (blinkAutoBlock()) { // interact autoblock - resetBlinkState(true); - } - blinking.set(false); - interactTicks = 0; - setTarget(null); - if (rotated || reset) { - resetYaw(); - } - rotated = false; - swapped = false; - partialTicks = 0; - delayTicks = 0; - sAttacked = 0; - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S27PacketExplosion && blinking.get()) { - delayedKnockBackPackets.add(e.getPacket()); - e.setCanceled(true); - } - else if (e.getPacket() instanceof S12PacketEntityVelocity && blinking.get()) { - if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { - delayedKnockBackPackets.add(e.getPacket()); - e.setCanceled(true); - } - } - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - targeting = false; - wasUsing = mc.gameSettings.keyBindUseItem.isKeyDown(); - - if (autoBlockMode.getInput() != 4) { - if (target == null || !manualBlock() && manualBlock.isToggled()) { - if (ModuleUtils.swapTick == 0 && !ModuleUtils.isBlocked) { - interactTicks = 1; - } else { - interactTicks = 0; - } - } - } - if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { - boolean pressedLeft = Mouse.isButtonDown(0); - if (pressedLeft && !lastPressedLeft) { - onCustomMouse(0, true); - } - if (!pressedLeft && lastPressedLeft) { - onCustomMouse(0, false); - } - if (target == null) { - boolean pressedRight = Mouse.isButtonDown(1); - if (pressedRight && !lastPressedRight) { - onCustomMouse(1, true); - } - if (!pressedRight && lastPressedRight) { - onCustomMouse(1, false); - } - lastPressedRight = pressedRight; - } - lastPressedLeft = pressedLeft; - } - if (blinkOn) { - blinkChecked = true; - releasePackets(); - } - if (ModuleManager.bedAura.stopAutoblock) { - resetBlinkState(false); - blinking.set(false); - blockingServer = false; - return; - } - if (sendUnBlock) { - if (Raven.packetsHandler.C07.sentCurrentTick.get()) { - sendUnBlock = false; - return; - } - ReflectionUtils.setItemInUse(blockingClient = false); - sendDigPacket(); - sendUnBlock = false; - return; - } - delayTicks--; - if (delayTicks >= 0) { - return; - } - if (reset) { - resetYaw(); - reset = false; - } - if (!basicCondition() || !settingCondition()) { - setTarget(null); - return; - } - if (target == null) { - handleBlocking(false); - return; - } - double distanceToBB = getDistanceToBoundingBox(target); - boolean inBlockRange = distanceToBB <= blockRange.getInput(); - if (!autoBlockOverride() || !inBlockRange || (!manualBlock() && manualBlock.isToggled())) { // regular swing & attack if autoblock isnt overriding or isnt in autoblock range - handleSwingAndAttack(distanceToBB, false); - if (blinking.get() || lag) { - resetBlinkState(true); - blinking.set(false); - } - interactTicks = 0; - } - else if (inBlockRange && autoBlockOverride() && manualBlock()) { - handleAutoBlock(distanceToBB); - } - else if ((blinkAutoBlock() && !Utils.holdingSword()) || !inBlockRange || !manualBlock()) { // for blink autoblocks - if (blinking.get() || lag) { - resetBlinkState(true); - blinking.set(false); - } - interactTicks = 0; - } - if (inBlockRange) { - if (manualBlock()) { - handleBlocking(true); - } - if (manualBlock.isToggled()) { - handleBlocking(manualBlock()); - } - } - if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { - boolean pressedRight = Mouse.isButtonDown(1); - if (pressedRight && !lastPressedRight) { - onCustomMouse(1, true); - } - if (!pressedRight && lastPressedRight) { - onCustomMouse(1, false); - } - lastPressedRight = pressedRight; - } - targeting = true; - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void onClientRotation(ClientRotationEvent e) { - rotating = false; - handleTarget(); - if (delayTicks >= 0) { - if (rotated) { - resetYaw(e); - } - return; - } - if (!basicCondition() || !settingCondition()) { - setTarget(null); - if (rotated) { - resetYaw(e); - } - return; - } - if (target == null) { - if (rotated) { - resetYaw(e); - } - return; - } - if (ModuleManager.bedAura.stopAutoblock) { - if (rotated) { - resetYaw(e); - } - return; - } - if (rotationMode.getInput() != 2) { - if (rotateMode.getInput() == 0 && inRange(target, attackRange.getInput() - 0.005) || rotateMode.getInput() == 1 && inRange(target, swingRange.getInput())) { - float[] rotations = RotationUtils.getRotations(target, RotationUtils.prevRenderYaw, RotationUtils.prevRenderPitch); - float[] smoothedRotations = getRotationsSmoothed(rotations); - if (rotationMode.getInput() == 0) { // silent - e.yaw = smoothedRotations[0]; - e.pitch = smoothedRotations[1]; - rotated = true; - rotating = true; - } - else { - mc.thePlayer.rotationYaw = smoothedRotations[0]; - mc.thePlayer.rotationPitch = smoothedRotations[1]; - rotating = true; - } - } - else if (rotationMode.getInput() == 0) { - if (rotated) { - reset = true; - e.yaw = RotationUtils.serverRotations[0]; - e.pitch = RotationUtils.serverRotations[1]; - rotated = false; - rotating = true; - } - } - } - } - - @Override - public void onUpdate() { - if (rotationMode.getInput() == 1 && target != null) { - if (inRange(target, attackRange.getInput() - 0.005)) { - float[] rotations = RotationUtils.getRotations(target, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); - float[] smoothedRotations = getRotationsSmoothed(rotations); - mc.thePlayer.rotationYaw = smoothedRotations[0]; - mc.thePlayer.rotationPitch = smoothedRotations[1]; - } - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent event) { - if (!Utils.nullCheck()) { - return; - } - if (event.phase == TickEvent.Phase.START) { - if (System.currentTimeMillis() - this.lastTime >= delay && target != null) { - this.lastTime = System.currentTimeMillis(); - updateAttackDelay(); - if (target != null) { - shouldAttack = true; - } - if (rotationMode.getInput() == 0) { - //mc.thePlayer.renderArmYaw = mc.thePlayer.rotationYaw; - //mc.thePlayer.prevRenderArmYaw = mc.thePlayer.rotationYaw; - } - } - } - } - - @SubscribeEvent(priority = EventPriority.HIGH) - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - Packet packet = e.getPacket(); - if (packet instanceof C08PacketPlayerBlockPlacement) { - C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); - if (delayTicks >= 0) { - if (p.getStack() != null && p.getStack().getItem() instanceof ItemSword && p.getPlacedBlockDirection() != 255) { - e.setCanceled(true); - } - } - } - if (blinkChecked) { - return; - } - if (blinking.get() && !e.isCanceled()) { // blink - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { - return; - } - blinkedPackets.add(packet); - e.setCanceled(true); - } - } - - @SubscribeEvent - public void onMouse(MouseEvent e) { - if (e.button == 0 || e.button == 1) { - if (!Utils.holdingWeapon() || target == null || rotationMode.getInput() != 0) { - return; - } - e.setCanceled(true); - } - } - - @SubscribeEvent - public void onScrollSlot(PreSlotScrollEvent e) { - int slot = e.slot; - slot = (slot > 0) ? 1 : ((slot < 0) ? -1 : 0); - slot = Math.floorMod(mc.thePlayer.inventory.currentItem - slot, 9); - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slot); - if (stack != null && stack.getItem() instanceof ItemSword && wasUsing && Utils.lookingAtBlock()) { - onSwapSlot(); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7Scroll swap detected, setting delay to &b" + delayTicks + "&7. (&d" + mc.thePlayer.ticksExisted + "&7)"); - } - } - } - - @SubscribeEvent - public void onSlotUpdate(SlotUpdateEvent e) { - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(e.slot); - if (stack != null && stack.getItem() instanceof ItemSword && wasUsing && Utils.lookingAtBlock()) { - onSwapSlot(); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7Swap detected, setting delay to &b" + delayTicks + "&7. (&d" + mc.thePlayer.ticksExisted + "&7)"); - } - } - } - - @SubscribeEvent - public void onSetAttackTarget(LivingSetAttackTargetEvent e) { - if (e.entity != null && !hostileMobs.contains(e.entity)) { - if (!(e.target instanceof EntityPlayer) || !e.target.getName().equals(mc.thePlayer.getName())) { - return; - } - hostileMobs.add(e.entity); - } - if (e.target == null && hostileMobs.contains(e.entity)) { - hostileMobs.remove(e.entity); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7mob stopped attack player"); - } - } - } - - public void onSwapSlot() { - delayTicks = 1; - if (autoBlockMode.getInput() > 0 && !manualBlock()) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); - } - } - - public void onCustomMouse(int button, boolean state) { - if (rotationMode.getInput() != 0) { - return; - } - if (button == 1) { - if (state) { - if (target != null) { - if (blinkAutoBlock()) { - return; - } - if (basicCondition() && settingCondition()) { - if (!ModuleManager.bedAura.breakTick) { - if (isLookingAtEntity()) { - if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { - interactAt(true, true, false, true); - } - } - } - } - ReflectionUtils.setItemInUse(blockingClient = true); - sendBlockPacket(); - // cancel - } - else { - delayTicks = 1; - } - } - else { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); - if (!blinkAutoBlock()) { - ReflectionUtils.setItemInUse(blockingClient = false); - sendUnBlock = true; - } - } - } - else if (button == 0) { - if (!state) { - delayTicks = 1; - } - if (blinkAutoBlock()) { - return; - } - if (mc.currentScreen == null && state && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !Mouse.isButtonDown(1)) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), true); - KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode()); - } - else if (!state) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), false); - } - } - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - hitMap.clear(); - lastSet = 0; - hostileMobs.clear(); - golems.clear(); - } - } - - private void setTarget(Entity entity) { - if (entity == null || !(entity instanceof EntityLivingBase)) { - if (blockingClient) { - ReflectionUtils.setItemInUse(blockingClient = false); - sendUnBlock = true; - } - if (blinkAutoBlock()) { // interact autoblock - resetBlinkState(true); - blinking.set(false); - } - swapped = false; - partialTicks = 0; - interactTicks = 0; - handleBlocking(false); - if (target != null) { - stoppedTargeting = true; - ModuleUtils.unTargetTicks = 0; - } - target = null; - attackingEntity = null; - sAttacked = 0; - } - else { - target = (EntityLivingBase) entity; - sAttacked++; - } - } - - private void handleTarget() { - // Narrow down the targets available - List availableTargets = new ArrayList<>(); - double maxRange = getMaxRange(); - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity == null || entity == mc.thePlayer || entity.isDead) { - continue; - } - if (entity instanceof EntityPlayer) { - if (Utils.isFriended((EntityPlayer) entity)) { - continue; - } - if (((EntityPlayer) entity).deathTime != 0) { - continue; - } - if (AntiBot.isBot(entity) || (Utils.isTeammate(entity) && ignoreTeammates.isToggled())) { - continue; - } - } - else if (entity instanceof EntityCreature && attackMobs.isToggled()) { - if (((EntityCreature) entity).tasks == null || ((EntityCreature) entity).isAIDisabled() || ((EntityCreature) entity).deathTime != 0) { // no ai - continue; - } - if (!entity.getClass().getCanonicalName().startsWith("net.minecraft.entity.monster.")) { - continue; - } - } - else { - continue; - } - if (entity.isInvisible() && !targetInvis.isToggled()) { - continue; - } - float fovInput = (float) fov.getInput(); - if (fovInput != 360.0f && !Utils.inFov(fovInput, entity)) { - continue; - } - if (mc.thePlayer.getDistanceToEntity(entity) < maxRange + maxRange / 3) { // simple distance check - availableTargets.add((EntityLivingBase) entity); - } - } - // Init as a new class and adding to list - List toClassTargets = new ArrayList<>(); - for (EntityLivingBase target : availableTargets) { - double distanceRayCasted = getDistanceToBoundingBox(target); - if (distanceRayCasted > maxRange) { - continue; - } - if (!(target instanceof EntityPlayer) && attackMobs.isToggled() && !isHostile((EntityCreature) target)) { - continue; - } - if (!hitThroughBlocks.isToggled() && (!Utils.canPlayerBeSeen(target) || !inRange(target, attackRange.getInput() - 0.005))) { - continue; - } - toClassTargets.add(new KillAuraTarget(distanceRayCasted, target.getHealth(), target.hurtTime, RotationUtils.distanceFromYaw(target, false), target.getEntityId(), (target instanceof EntityPlayer) ? Utils.isEnemy((EntityPlayer) target) : false)); - } - // Sorting targets - Comparator comparator = null; - switch ((int) sortMode.getInput()) { - case 0: - comparator = Comparator.comparingDouble(entity -> entity.distance); - break; - case 1: - comparator = Comparator.comparingDouble(entityPlayer -> (double)entityPlayer.health); - break; - case 2: - comparator = Comparator.comparingDouble(entityPlayer2 -> (double)entityPlayer2.hurttime); - break; - case 3: - comparator = Comparator.comparingDouble(entity2 -> entity2.yawDelta); - break; - } - if (prioritizeEnemies.isToggled()) { - List enemies = new ArrayList<>(); - for (KillAuraTarget entity : toClassTargets) { - if (entity.isEnemy) { - enemies.add(entity); - } - } - if (!enemies.isEmpty()) { - toClassTargets = new ArrayList<>(enemies); - } - } - if (sortMode.getInput() != 0) { - Collections.sort(toClassTargets, Comparator.comparingDouble(entity -> entity.distance)); - } - Collections.sort(toClassTargets, comparator); // then sort by selected sorting mode - - List attackTargets = new ArrayList<>(); - for (KillAuraTarget killAuraTarget : toClassTargets) { - if (killAuraTarget.distance <= attackRange.getInput() - 0.005) { - attackTargets.add(killAuraTarget); - } - } - - if (!attackTargets.isEmpty()) { - - if (sAttacked == 0) { - ++lastSet; - } - - // Switch aura - int ticksExisted = lastSet; - int switchDelayTicks = (int) (switchDelay.getInput() / 50); - long noHitTicks = (long) Math.min(attackTargets.size(), targets.getInput()) * switchDelayTicks; - for (KillAuraTarget auraTarget : attackTargets) { - Integer firstHit = hitMap.get(auraTarget.entityId); - if (firstHit == null || ticksExisted - firstHit >= switchDelayTicks) { - continue; - } - if (auraTarget.distance < attackRange.getInput() - 0.005) { - setTarget(mc.theWorld.getEntityByID(auraTarget.entityId)); - return; - } - } - - for (KillAuraTarget auraTarget : attackTargets) { - Integer firstHit = hitMap.get(auraTarget.entityId); - if (firstHit == null || ticksExisted >= firstHit + noHitTicks) { - hitMap.put(auraTarget.entityId, lastSet); - setTarget(mc.theWorld.getEntityByID(auraTarget.entityId)); - return; - } - } - } - else if (!toClassTargets.isEmpty()) { - KillAuraTarget killAuraTarget = toClassTargets.get(0); - setTarget(mc.theWorld.getEntityByID(killAuraTarget.entityId)); - } - else { - setTarget(null); - } - } - - private void handleSwingAndAttack(double distance, boolean swung) { - boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.005); - if ((distance <= swingRange.getInput() || inAttackDistance) && shouldAttack && !swung) { // swing if in swing range or needs to attack - if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { - swingItem(); - } - } - if (inAttackDistance) { - attackingEntity = target; - if (shouldAttack) { - shouldAttack = false; - if (ModuleManager.bedAura.breakTick) { - return; - } - if (!isLookingAtEntity()) { - return; - } - if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { - mc.playerController.attackEntity(mc.thePlayer, target); - sAttacked = 0; - } - } - } - else { - attackingEntity = null; - } - } - - private boolean isHostile(EntityCreature entityCreature) { - if (SkyWars.onlyAuraHostiles()) { - if (entityCreature instanceof EntityGiantZombie) { - return false; - } - return !ModuleManager.skyWars.spawnedMobs.contains(entityCreature.getEntityId()); - } - else if (entityCreature instanceof EntitySilverfish) { - String teamColor = Utils.getFirstColorCode(entityCreature.getCustomNameTag()); - String teamColorSelf = Utils.getFirstColorCode(mc.thePlayer.getDisplayName().getFormattedText()); - if (!teamColor.isEmpty() && (teamColorSelf.equals(teamColor) || Utils.isTeammate(entityCreature))) { // same team - return false; - } - return true; - } - else if (entityCreature instanceof EntityIronGolem) { - if (Utils.getBedwarsStatus() != 2) { - return true; - } - if (!golems.containsKey(entityCreature.getEntityId())) { - double nearestDistance = -1; - EntityArmorStand nearestArmorStand = null; - for (Entity entity : mc.theWorld.loadedEntityList) { - if (!(entity instanceof EntityArmorStand)) { - continue; - } - String stripped = Utils.stripString(entity.getDisplayName().getFormattedText()); - if (stripped.contains("[") && stripped.endsWith("]")) { - double distanceSq = entity.getDistanceSq(entityCreature.posX, entityCreature.posY, entityCreature.posZ); - if (distanceSq < nearestDistance || nearestDistance == -1) { - nearestDistance = distanceSq; - nearestArmorStand = (EntityArmorStand) entity; - } - } - } - if (nearestArmorStand != null) { - String teamColor = Utils.getFirstColorCode(nearestArmorStand.getDisplayName().getFormattedText()); - String teamColorSelf = Utils.getFirstColorCode(mc.thePlayer.getDisplayName().getFormattedText()); - boolean isTeam = false; - if (!teamColor.isEmpty() && (teamColorSelf.equals(teamColor) || Utils.isTeammate(nearestArmorStand))) { // same team - isTeam = true; - } - golems.put(entityCreature.getEntityId(), isTeam); - return !isTeam; - } - if (ModuleManager.bedwars.spawnedMobs.contains(entityCreature.getEntityId())) { - return false; - } - return true; - } - else { - return !golems.getOrDefault(entityCreature.getEntityId(), false); - } - } - else if (entityCreature instanceof EntityPigZombie && Utils.getBedwarsStatus() != 2) { - return false; - } - return hostileMobs.contains(entityCreature); - } - - private void handleBlocking(boolean blockState) { - if (!Utils.holdingSword()) { - if (blockingClient) { - ReflectionUtils.setItemInUse(blockingClient = false); - } - return; - } - /*if (this.blockingClient == blockState && autoBlockMode.getInput() != 3) { - return; - }*/ - if (autoBlockMode.getInput() != previousAutoBlockMode) { - if (previousAutoBlockMode >= 3) { // if == interact - resetBlinkState(true); - blinking.set(false); - } - } - int keyCode = mc.gameSettings.keyBindUseItem.getKeyCode(); - switch ((int) autoBlockMode.getInput()) { - case 0: // manual, do nothing - break; - case 1: // vanilla - setKeyBindState(keyCode, blockState, false); - this.blockingClient = blockState; - break; - case 3: // blink - case 4: // swap - ReflectionUtils.setItemInUse(this.blockingClient = blockState); - break; - case 2: // partial - if (!blockState) { - rightClick(partialDown = false); - break; - } - partialTicks++; - if (partialDown) { - rightClick(partialDown = false); - partialTicks = 0; - break; - } - else if (partialTicks == 2) { - rightClick(partialDown = true); - } - break; - } - previousAutoBlockMode = (int) autoBlockMode.getInput(); - } - - private void rightClick(boolean state) { - int keyCode = mc.gameSettings.keyBindUseItem.getKeyCode(); - KeyBinding.setKeyBindState(keyCode, state); - if (state) { - KeyBinding.onTick(keyCode); - } - ReflectionUtils.setButton(1, state); - } - - private double getMaxRange() { - return Math.max(Math.max(swingRange.getInput(), attackRange.getInput() - 0.005), blockRange.getInput()); - } - - public boolean autoBlockOverride() { - return blinkAutoBlock() && Utils.holdingSword(); - } - - public boolean blinkAutoBlock() { - return (autoBlockMode.getInput() >= 3); - } - - private float unwrapYaw(float yaw, float prevYaw) { - return prevYaw + ((((yaw - prevYaw + 180f) % 360f) + 360f) % 360f - 180f); - } - - private void releaseKnockBackPackets() { - synchronized (delayedKnockBackPackets) { - for (Packet packet : delayedKnockBackPackets) { - packet.processPacket(mc.getNetHandler()); - } - } - delayedKnockBackPackets.clear(); - } - - private boolean isLookingAtEntity() { // - if (rotationMode.getInput() == 0 && rotationSmoothing.getInput() > 0) { // silent - return RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.005, RotationUtils.serverRotations); - } - return true; - } - - private void handleAutoBlock(double distance) { - boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.005); - if (inAttackDistance) { - attackingEntity = target; - } - boolean swung = false; - switch ((int) autoBlockMode.getInput()) { - case 3: // blink - interactTicks++; - switch (interactTicks) { - case 1: - if (ModuleUtils.isBlocked) { - blinking.set(true); - setSwapSlot(); - } - break; - case 2: - setCurrentSlot(); - handleInteractAndAttack(distance, true, true, swung); - sendBlockPacket(); - releasePackets(); // release - interactTicks = 0; - break; - } - break; - case 4: // swap - interactTicks++; - if (interactTicks <= 2 && cycle == 0 || interactTicks <= 1 && cycle == 1) { - if (ModuleUtils.isBlocked) { - setSwapSlot(); - } - setCurrentSlot(); - handleInteractAndAttack(distance, true, true, swung); - sendBlockPacket(); - } - else { - interactTicks = 0; - ++cycle; - if (cycle > 1) { - cycle = 0; - } - } - break; - } - } - - private void resetYaw(ClientRotationEvent event) { - reset = true; - event.yaw = RotationUtils.serverRotations[0]; - event.pitch = RotationUtils.serverRotations[1]; - rotated = false; - } - - private boolean basicCondition() { - if (!Utils.nullCheck()) { - return false; - } - if (mc.thePlayer.isDead) { - return false; - } - return true; - } - - private void setCurrentSlot() { - if (!swapped) { - return; - } - mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); - Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); - swapped = false; - } - - private void setSwapSlot() { - int bestSwapSlot = getBestSwapSlot(); - mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(bestSwapSlot)); - Raven.packetsHandler.playerSlot.set(bestSwapSlot); - swapped = true; - } - - private boolean settingCondition() { - if (requireMouseDown.isToggled() && !Mouse.isButtonDown(0)) { - return false; - } - else if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { - return false; - } - else if (disableWhileMining.isToggled() && Utils.isMining()) { - return false; - } - else if (disableInInventory.isToggled() && mc.currentScreen != null) { - return false; - } - else if (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && !ModuleManager.bedAura.allowAura.isToggled() && ModuleManager.bedAura.currentBlock != null) { - return false; - } - return true; - } - - private void sendBlockPacket() { - mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); - } - - - private void setKeyBindState(int keycode, boolean state, boolean invokeTick) { - KeyBinding.setKeyBindState(keycode, state); - if (invokeTick) { - KeyBinding.onTick(keycode); - } - } - - private void updateAttackDelay() { - delay = (long)(1000.0 / aps.getInput() + Utils.randomizeInt(-4, 4)); - } - - private void swingItem() { - if (silentSwing.isToggled() && mc.thePlayer.isBlocking()) { - mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); - } - else { - mc.thePlayer.swingItem(); - } - } - - public static double getDistanceToBoundingBox(Entity target) { - if (mc.thePlayer == null) { - return 0; - } - Vec3 playerEyePos = mc.thePlayer.getPositionEyes(((IAccessorMinecraft) mc).getTimer().renderPartialTicks); - AxisAlignedBB boundingBox = target.getEntityBoundingBox(); - double nearestX = MathHelper.clamp_double(playerEyePos.xCoord, boundingBox.minX, boundingBox.maxX); - double nearestY = MathHelper.clamp_double(playerEyePos.yCoord, boundingBox.minY, boundingBox.maxY); - double nearestZ = MathHelper.clamp_double(playerEyePos.zCoord, boundingBox.minZ, boundingBox.maxZ); - Vec3 nearestPoint = new Vec3(nearestX, nearestY, nearestZ); - return playerEyePos.distanceTo(nearestPoint); - } - - private int getBestSwapSlot() { - int currentSlot = mc.thePlayer.inventory.currentItem; - int bestSlot = -1; - double bestDamage = -1; - for (int i = 0; i < 9; ++i) { - if (i == currentSlot) { - continue; - } - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); - double damage = Utils.getDamageLevel(stack); - if (damage != 0) { - if (damage > bestDamage) { - bestDamage = damage; - bestSlot = i; - } - } - } - if (bestSlot == -1) { - for (int i = 0; i < 9; ++i) { - if (i == currentSlot) { - continue; - } - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); - if (stack == null || Arrays.stream(swapBlacklist).noneMatch(stack.getUnlocalizedName().toLowerCase()::contains)) { - bestSlot = i; - break; - } - } - } - - return bestSlot; - } - - public void resetYaw() { - float serverYaw = RotationUtils.serverRotations[0]; - float unwrappedYaw = unwrapYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw), serverYaw); - mc.thePlayer.rotationYaw = unwrappedYaw; - mc.thePlayer.prevRotationYaw = unwrappedYaw; - } - - private void interactAt(boolean interactAt, boolean interact, boolean noEvent, boolean requireInteractAt) { - if (attackingEntity == null) { - return; - } - if (ModuleManager.bedAura.breakTick) { - return; - } - boolean sent = false; - if (interactAt) { - boolean canHit = RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.005, RotationUtils.serverRotations); - if (!canHit) { - return; - } - MovingObjectPosition mov = RotationUtils.rayTrace(10, ((IAccessorMinecraft) mc).getTimer().renderPartialTicks, RotationUtils.serverRotations, hitThroughBlocks.isToggled() ? attackingEntity : null); - if (mov != null && mov.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mov.entityHit == attackingEntity) { - Vec3 hitVec = mov.hitVec; - hitVec = new Vec3(hitVec.xCoord - attackingEntity.posX, hitVec.yCoord - attackingEntity.posY, hitVec.zCoord - attackingEntity.posZ); - if (!noEvent) { - mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(attackingEntity, hitVec)); - } - else { - PacketUtils.sendPacketNoEvent(new C02PacketUseEntity(attackingEntity, hitVec)); - } - sent = true; - } - } - if (requireInteractAt && !sent) { - return; - } - if (interact) { - if (!noEvent) { - mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(attackingEntity, C02PacketUseEntity.Action.INTERACT)); - } - else { - PacketUtils.sendPacketNoEvent(new C02PacketUseEntity(attackingEntity, C02PacketUseEntity.Action.INTERACT)); - } - } - } - - private void sendDigPacket() { - if (!Utils.holdingSword()) { - return; - } - mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); - } - - private float[] getRotationsSmoothed(float rotations[]) { - float serverYaw = RotationUtils.serverRotations[0]; - float serverPitch = RotationUtils.serverRotations[1]; - float unwrappedYaw = unwrapYaw(rotations[0], serverYaw); - - float deltaYaw = unwrappedYaw - serverYaw; - float deltaPitch = rotations[1] - serverPitch; - - float yawSmoothing = (float) rotationSmoothing.getInput(); - float pitchSmoothing = yawSmoothing; - - float strafe = mc.thePlayer.moveStrafing; - if (strafe < 0 && deltaYaw < 0 || strafe > 0 && deltaYaw > 0) { - yawSmoothing = Math.max(1f, yawSmoothing / 2f); - } - - float motionY = (float) mc.thePlayer.motionY; - if (motionY > 0 && deltaPitch > 0 || motionY < 0 && deltaPitch < 0) { - pitchSmoothing = Math.max(1f, pitchSmoothing / 2f); - } - - serverYaw += deltaYaw / Math.max(1f, yawSmoothing); - serverPitch += deltaPitch / Math.max(1f, pitchSmoothing); - - return new float[] { serverYaw, serverPitch }; - } - - private void handleInteractAndAttack(double distance, boolean interactAt, boolean interact, boolean swung) { - if (ModuleManager.antiFireball != null && ModuleManager.antiFireball.isEnabled() && ModuleManager.antiFireball.fireball != null && ModuleManager.antiFireball.attack) { - if (ModuleManager.bedAura.breakTick) { - return; - } - if (!ModuleManager.antiFireball.silentSwing.isToggled()) { - mc.thePlayer.swingItem(); - } - else { - mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); - } - mc.playerController.attackEntity(mc.thePlayer, ModuleManager.antiFireball.fireball); - if (interact) { - mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ModuleManager.antiFireball.fireball, C02PacketUseEntity.Action.INTERACT)); - } - } - else { - handleSwingAndAttack(distance, swung); - interactAt(interactAt, interact, false, false); - } - } - - public void resetBlinkState(boolean unblock) { - blockingServer = false; - blinking.set(false); - releasePackets(); - if (Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && swapped) { - mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); - Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); - } - else if (unblock && lag && !ModuleManager.scaffold.isEnabled && ModuleUtils.isBlocked) { - sendUnBlock = true; - } - swapped = false; - firstEdge = firstCycleTicks = interactTicks = 0; - lag = false; - firstCycle = false; - } - - private void releasePackets() { - if (blinkedPackets.isEmpty()) { - return; - } - try { - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } - catch (Exception e) { - e.printStackTrace(); - Utils.sendModuleMessage(this, "&cThere was an error releasing blinked packets"); - } - this.releaseKnockBackPackets(); - blinkedPackets.clear(); - } - - private boolean inRange(final Entity target, final double distance) { - return RotationUtils.isPossibleToHit(target, distance, RotationUtils.getRotations(target)); - } - - private boolean manualBlock() { - return (!manualBlock.isToggled() || Mouse.isButtonDown(1)) && Utils.holdingSword(); - } - - static class KillAuraTarget { - double distance; - float health; - int hurttime; - double yawDelta; - int entityId; - boolean isEnemy; - - public KillAuraTarget(double distance, float health, int hurttime, double yawDelta, int entityId, boolean isEnemy) { - this.distance = distance; - this.health = health; - this.hurttime = hurttime; - this.yawDelta = yawDelta; - this.entityId = entityId; - this.isEnemy = isEnemy; - } - } +package keystrokesmod.module.impl.combat; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.minigames.SkyWars; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityGiantZombie; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.network.Packet; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.*; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.input.Mouse; + +import java.util.*; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import static net.minecraft.util.EnumFacing.DOWN; + + +public class KillAura extends Module { + private SliderSetting aps; + public SliderSetting autoBlockMode; + private SliderSetting fov; + private SliderSetting attackRange; + private SliderSetting swingRange; + private SliderSetting blockRange; + public SliderSetting rotationMode; + public SliderSetting rotateMode; + private SliderSetting rotationSmoothing; + private SliderSetting sortMode; + private SliderSetting switchDelay; + private SliderSetting targets; + private ButtonSetting attackMobs; + private ButtonSetting targetInvis; + private ButtonSetting disableInInventory; + private ButtonSetting disableWhileBlocking; + private ButtonSetting disableWhileMining; + private ButtonSetting hitThroughBlocks; + private ButtonSetting ignoreTeammates; + public ButtonSetting manualBlock; + private ButtonSetting prioritizeEnemies; + private ButtonSetting requireMouseDown; + private ButtonSetting silentSwing; + private ButtonSetting weaponOnly; + + private String[] autoBlockModes = new String[] { "Manual", "Vanilla", "Partial", "Blink", "Swap" }; + private String[] rotationModes = new String[] { "Silent", "Lock view", "None" }; + private String[] rotateModes = new String[] { "Attack", "Swing" }; + private String[] sortModes = new String[] { "Distance", "Health", "Hurttime", "Yaw" }; + + // autoblock related + private String[] swapBlacklist = { "compass", "snowball", "spawn", "skull" }; + + // target variables + public static EntityLivingBase target; + public static EntityLivingBase attackingEntity; + private HashMap hitMap = new HashMap<>(); // entity id, ticks existed client + private List hostileMobs = new ArrayList<>(); + private Map golems = new HashMap<>(); // entity id, is teammate + private double attackv = 0.006; + + // blocking related + public boolean blockingClient; + public boolean blockingServer; + private int interactTicks; + private boolean partialDown; + private int partialTicks; + private boolean wasUsing; + private boolean hasAutoblocked; + private boolean hasBlocked; + + // blink related + private boolean swapped; + public boolean blink; + + // other + private long lastTime = 0L; + private long delay; + private boolean shouldAttack; + private int previousAutoBlockMode; + private boolean reset; + private boolean rotated; + private boolean sendUnBlock; + private int delayTicks = 0; + private boolean lastPressedLeft; + private boolean lastPressedRight; + public boolean stoppedTargeting; // can only be true for 1 tick + public boolean targeting, rotating; + private int cycle; + public int sAttacked; + private int lastSet; + private boolean hasTargeted; + public boolean t; + private int getTicks; + + public KillAura() { + super("KillAura", category.combat); + this.registerSetting(aps = new SliderSetting("APS", 16.0, 1.0, 20.0, 0.5)); + this.registerSetting(autoBlockMode = new SliderSetting("Autoblock", 0, autoBlockModes)); + this.registerSetting(fov = new SliderSetting("FOV", 360.0, 30.0, 360.0, 4.0)); + this.registerSetting(attackRange = new SliderSetting("Range (attack)", 3.0, 3.0, 6.0, 0.05)); + this.registerSetting(swingRange = new SliderSetting("Range (swing)", 3.3, 3.0, 8.0, 0.05)); + this.registerSetting(blockRange = new SliderSetting("Range (block)", 6.0, 3.0, 12.0, 0.05)); + this.registerSetting(rotationMode = new SliderSetting("Rotation mode", 0, rotationModes)); + this.registerSetting(rotateMode = new SliderSetting("Rotate on", 0, rotateModes)); + this.registerSetting(rotationSmoothing = new SliderSetting("Rotation smoothing", 0, 0, 10, 1)); + this.registerSetting(sortMode = new SliderSetting("Sort mode", 0, sortModes)); + this.registerSetting(switchDelay = new SliderSetting("Switch delay", "ms", 200.0, 50.0, 1000.0, 25.0)); + this.registerSetting(targets = new SliderSetting("Targets", 3.0, 1.0, 10.0, 1.0)); + this.registerSetting(targetInvis = new ButtonSetting("Target invis", true)); + this.registerSetting(attackMobs = new ButtonSetting("Attack mobs", false)); + this.registerSetting(disableInInventory = new ButtonSetting("Disable in inventory", true)); + this.registerSetting(disableWhileBlocking = new ButtonSetting("Disable while blocking", false)); + this.registerSetting(disableWhileMining = new ButtonSetting("Disable while mining", false)); + this.registerSetting(hitThroughBlocks = new ButtonSetting("Hit through blocks", true)); + this.registerSetting(ignoreTeammates = new ButtonSetting("Ignore teammates", true)); + this.registerSetting(manualBlock = new ButtonSetting("Manual block", false)); // does absolutely nothing + this.registerSetting(prioritizeEnemies = new ButtonSetting("Prioritize enemies", false)); + this.registerSetting(requireMouseDown = new ButtonSetting("Require mouse down", false)); + this.registerSetting(silentSwing = new ButtonSetting("Silent swing while blocking", false)); + this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); + } + + @Override + public String getInfo() { + if (rotationMode.getInput() == 2) { // None, return FOV if rotation mode is none + return String.valueOf((int) this.fov.getInput()); + } + return rotationModes[(int) rotationMode.getInput()]; + } + + @Override + public void onEnable() { + if (rotationMode.getInput() == 0 && autoBlockMode.getInput() <= 1) { + delayTicks = 1; + } + } + + @Override + public void onDisable() { + hitMap.clear(); + lastSet = 0; + if (autoBlockOverride()) { // interact autoblock + resetAutoblock(true); + } + blink = false; + interactTicks = 0; + setTarget(null); + if (rotated || reset) { + resetYaw(); + } + rotated = false; + swapped = false; + partialTicks = 0; + delayTicks = 0; + sAttacked = 0; + t = false; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + targeting = false; + wasUsing = mc.gameSettings.keyBindUseItem.isKeyDown(); + + if (!Utils.holdingSword()) { + sendUnBlock = false; + if (hasTargeted) { + if (target == null && Utils.tabbedIn()) { + if (Mouse.isButtonDown(1)) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true); + } + } + } + } + hasTargeted = false; + + if (autoBlockMode.getInput() == 3) { + if (target == null || !manualBlock() && manualBlock.isToggled()) { + if (ModuleUtils.swapTick == 0 && !ModuleUtils.isBlocked) { + interactTicks = 1; + getTicks = getAPSToTicks(10); + } else { + interactTicks = 0; + } + } + } + if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { + boolean pressedLeft = Mouse.isButtonDown(0); + if (pressedLeft && !lastPressedLeft) { + onCustomMouse(0, true); + } + if (!pressedLeft && lastPressedLeft) { + onCustomMouse(0, false); + } + boolean pressedRight = Mouse.isButtonDown(1); + if (pressedRight && !lastPressedRight) { + onCustomMouse(1, true); + } + if (!pressedRight && lastPressedRight) { + onCustomMouse(1, false); + } + lastPressedRight = pressedRight; + lastPressedLeft = pressedLeft; + } + + if (!basicCondition() || !settingCondition()) { + setTarget(null); + } + if (reset) { + resetYaw(); + reset = false; + } + delayTicks--; + if (delayTicks >= 0) { + return; + } + if (sendUnBlock) { + sendUnBlock = false; + if (Raven.packetsHandler.C07.sentCurrentTick.get()) { + return; + } + sendDigPacket(); + return; + } + if (target == null) { + resetAutoblock(true); + return; + } + if (ModuleManager.bedAura.stopAutoblock) { + resetAutoblock(false); + return; + } + double distanceToBB = getDistanceToBoundingBox(target); + boolean inBlockRange = distanceToBB <= blockRange.getInput(); + if (!autoBlockOverride() || !inBlockRange || (!manualBlock() && manualBlock.isToggled())) { // regular swing & attack if autoblock isnt overriding or isnt in autoblock range + handleSwingAndAttack(distanceToBB, false); + resetAutoblock(true); + interactTicks = 0; + } + else if (inBlockRange && autoBlockOverride() && manualBlock()) { + handleAutoBlock(distanceToBB); + } + else if ((autoBlockOverride() && !Utils.holdingSword()) || !inBlockRange || !manualBlock()) { // for autoblocks + resetAutoblock(true); + interactTicks = 0; + } + if (inBlockRange) { + handleBlocking(); + } + if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { + boolean pressedRight = Mouse.isButtonDown(1); + if (pressedRight && !lastPressedRight) { + onCustomMouse(1, true); + } + if (!pressedRight && lastPressedRight) { + onCustomMouse(1, false); + } + lastPressedRight = pressedRight; + } + targeting = true; + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onClientRotation(ClientRotationEvent e) { + rotating = false; + handleTarget(); + if (delayTicks >= 0) { + if (rotated) { + resetYaw(e); + } + return; + } + if (!basicCondition() || !settingCondition()) { + setTarget(null); + if (rotated) { + resetYaw(e); + } + return; + } + if (target == null) { + if (rotated) { + resetYaw(e); + } + return; + } + if (ModuleManager.bedAura.stopAutoblock) { + if (rotated) { + resetYaw(e); + } + return; + } + if (rotationMode.getInput() != 2) { + if (rotateMode.getInput() == 0 && inRange(target, attackRange.getInput() - attackv) || rotateMode.getInput() == 1 && inRange(target, swingRange.getInput())) { + float[] rotations = RotationUtils.getRotations(target, RotationUtils.prevRenderYaw, RotationUtils.prevRenderPitch); + float[] smoothedRotations = getRotationsSmoothed(rotations); + if (rotationMode.getInput() == 0) { // silent + e.yaw = smoothedRotations[0]; + e.pitch = smoothedRotations[1]; + rotated = true; + rotating = true; + } + else { + mc.thePlayer.rotationYaw = smoothedRotations[0]; + mc.thePlayer.rotationPitch = smoothedRotations[1]; + rotating = true; + } + } + else if (rotationMode.getInput() == 0) { + if (rotated) { + reset = true; + e.yaw = RotationUtils.serverRotations[0]; + e.pitch = RotationUtils.serverRotations[1]; + rotated = false; + rotating = true; + } + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + Packet packet = e.getPacket(); + if (packet instanceof C08PacketPlayerBlockPlacement) { + C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); + if (delayTicks >= 0) { + if (p.getStack() != null && p.getStack().getItem() instanceof ItemSword && p.getPlacedBlockDirection() != 255) { + e.setCanceled(true); + } + } + } + } + + @Override + public void onUpdate() { + if (rotationMode.getInput() == 1 && target != null) { + if (inRange(target, attackRange.getInput() - attackv)) { + float[] rotations = RotationUtils.getRotations(target, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); + float[] smoothedRotations = getRotationsSmoothed(rotations); + mc.thePlayer.rotationYaw = smoothedRotations[0]; + mc.thePlayer.rotationPitch = smoothedRotations[1]; + } + } + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + if (!Utils.nullCheck()) { + return; + } + if (event.phase == TickEvent.Phase.START) { + if (System.currentTimeMillis() - this.lastTime >= delay && target != null) { + this.lastTime = System.currentTimeMillis(); + updateAttackDelay(); + if (target != null) { + shouldAttack = true; + } + if (rotationMode.getInput() == 0) { + //mc.thePlayer.renderArmYaw = mc.thePlayer.rotationYaw; + //mc.thePlayer.prevRenderArmYaw = mc.thePlayer.rotationYaw; + } + } + } + } + + @SubscribeEvent + public void onMouse(MouseEvent e) { + if (e.button == 0 || e.button == 1) { + if (!Utils.holdingWeapon() || target == null || !settingCondition()) { + return; + } + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onScrollSlot(PreSlotScrollEvent e) { + int slot = e.slot; + slot = (slot > 0) ? 1 : ((slot < 0) ? -1 : 0); + slot = Math.floorMod(mc.thePlayer.inventory.currentItem - slot, 9); + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slot); + if (stack != null && stack.getItem() instanceof ItemSword && wasUsing && Utils.lookingAtBlock()) { + onSwapSlot(); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7Scroll swap detected, setting delay to &b" + delayTicks + "&7. (&d" + mc.thePlayer.ticksExisted + "&7)"); + } + } + } + + @SubscribeEvent + public void onSlotUpdate(SlotUpdateEvent e) { + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(e.slot); + if (stack != null && stack.getItem() instanceof ItemSword && wasUsing && Utils.lookingAtBlock()) { + onSwapSlot(); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7Swap detected, setting delay to &b" + delayTicks + "&7. (&d" + mc.thePlayer.ticksExisted + "&7)"); + } + } + } + + @SubscribeEvent + public void onSetAttackTarget(LivingSetAttackTargetEvent e) { + if (e.entity != null && !hostileMobs.contains(e.entity)) { + if (!(e.target instanceof EntityPlayer) || !e.target.getName().equals(mc.thePlayer.getName())) { + return; + } + hostileMobs.add(e.entity); + } + if (e.target == null && hostileMobs.contains(e.entity)) { + hostileMobs.remove(e.entity); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7mob stopped attack player"); + } + } + } + + public void onSwapSlot() { + delayTicks = 1; + if (autoBlockMode.getInput() > 0 && !manualBlock()) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + } + } + + public void onCustomMouse(int button, boolean state) { + if (autoBlockOverride()) { + return; + } + if (button == 1) { + if (state) { + if (target != null) { + if (basicCondition() && settingCondition()) { + if (!ModuleManager.bedAura.breakTick) { + if (isLookingAtEntity()) { + if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { + interactAt(true, true, false, true); + } + } + } + } + ReflectionUtils.setItemInUse(blockingClient = true); + sendBlockPacket(); + // cancel + } + else { + delayTicks = 1; + } + } + else { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + if (blockingClient) { + srb(); + sendUnBlock = true; + } + } + } + else if (button == 0) { + if (!state) { + delayTicks = 1; + } + if (mc.currentScreen == null && state && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !Mouse.isButtonDown(1)) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), true); + KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode()); + } + else if (!state) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), false); + } + } + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + hitMap.clear(); + lastSet = 0; + hostileMobs.clear(); + golems.clear(); + } + } + + private void setTarget(Entity entity) { + if (entity == null || !(entity instanceof EntityLivingBase)) { + srb(); + if (autoBlockOverride()) { + resetAutoblock(true); + } + swapped = false; + partialTicks = 0; + interactTicks = 0; + if (target != null) { + stoppedTargeting = true; + ModuleUtils.unTargetTicks = 0; + } + target = null; + attackingEntity = null; + sAttacked = 0; + t = false; + } + else { + target = (EntityLivingBase) entity; + sAttacked++; + hasTargeted = true; + t = true; + } + } + + private void handleTarget() { + // Narrow down the targets available + List availableTargets = new ArrayList<>(); + double maxRange = getMaxRange(); + for (Entity entity : mc.theWorld.loadedEntityList) { + if (entity == null || entity == mc.thePlayer || entity.isDead) { + continue; + } + if (entity instanceof EntityPlayer) { + if (Utils.isFriended((EntityPlayer) entity)) { + continue; + } + if (((EntityPlayer) entity).deathTime != 0) { + continue; + } + if (AntiBot.isBot(entity) || (Utils.isTeammate(entity) && ignoreTeammates.isToggled())) { + continue; + } + } + else if (entity instanceof EntityCreature && attackMobs.isToggled()) { + if (((EntityCreature) entity).tasks == null || ((EntityCreature) entity).isAIDisabled() || ((EntityCreature) entity).deathTime != 0) { // no ai + continue; + } + if (!entity.getClass().getCanonicalName().startsWith("net.minecraft.entity.monster.")) { + continue; + } + if (Utils.getBedwarsStatus() == 2 && entity instanceof EntityPigZombie) { + continue; + } + } + else { + continue; + } + if (entity.isInvisible() && !targetInvis.isToggled()) { + continue; + } + float fovInput = (float) fov.getInput(); + if (fovInput != 360.0f && !Utils.inFov(fovInput, entity)) { + continue; + } + if (mc.thePlayer.getDistanceToEntity(entity) < maxRange + maxRange / 3) { // simple distance check + availableTargets.add((EntityLivingBase) entity); + } + } + // Init as a new class and adding to list + List toClassTargets = new ArrayList<>(); + for (EntityLivingBase target : availableTargets) { + double distanceRayCasted = getDistanceToBoundingBox(target); + if (distanceRayCasted > maxRange) { + continue; + } + if (!(target instanceof EntityPlayer) && attackMobs.isToggled() && !isHostile((EntityCreature) target)) { + continue; + } + if (!hitThroughBlocks.isToggled() && (!Utils.canPlayerBeSeen(target) || !inRange(target, attackRange.getInput() - attackv))) { + continue; + } + toClassTargets.add(new KillAuraTarget(distanceRayCasted, target.getHealth(), target.hurtTime, RotationUtils.distanceFromYaw(target, false), target.getEntityId(), (target instanceof EntityPlayer) ? Utils.isEnemy((EntityPlayer) target) : false)); + } + // Sorting targets + Comparator comparator = null; + switch ((int) sortMode.getInput()) { + case 0: + comparator = Comparator.comparingDouble(entity -> entity.distance); + break; + case 1: + comparator = Comparator.comparingDouble(entityPlayer -> (double)entityPlayer.health); + break; + case 2: + comparator = Comparator.comparingDouble(entityPlayer2 -> (double)entityPlayer2.hurttime); + break; + case 3: + comparator = Comparator.comparingDouble(entity2 -> entity2.yawDelta); + break; + } + if (prioritizeEnemies.isToggled()) { + List enemies = new ArrayList<>(); + for (KillAuraTarget entity : toClassTargets) { + if (entity.isEnemy) { + enemies.add(entity); + } + } + if (!enemies.isEmpty()) { + toClassTargets = new ArrayList<>(enemies); + } + } + if (sortMode.getInput() != 0) { + Collections.sort(toClassTargets, Comparator.comparingDouble(entity -> entity.distance)); + } + Collections.sort(toClassTargets, comparator); // then sort by selected sorting mode + + List attackTargets = new ArrayList<>(); + for (KillAuraTarget killAuraTarget : toClassTargets) { + if (killAuraTarget.distance <= attackRange.getInput() - attackv) { + attackTargets.add(killAuraTarget); + } + } + + if (!attackTargets.isEmpty()) { + + if (sAttacked == 0) { + ++lastSet; + } + + // Switch aura + int ticksExisted = lastSet; + int switchDelayTicks = (int) (switchDelay.getInput() / 50); + long noHitTicks = (long) Math.min(attackTargets.size(), targets.getInput()) * switchDelayTicks; + for (KillAuraTarget auraTarget : attackTargets) { + Integer firstHit = hitMap.get(auraTarget.entityId); + if (firstHit == null || ticksExisted - firstHit >= switchDelayTicks) { + continue; + } + if (auraTarget.distance < attackRange.getInput() - attackv) { + setTarget(mc.theWorld.getEntityByID(auraTarget.entityId)); + return; + } + } + + for (KillAuraTarget auraTarget : attackTargets) { + Integer firstHit = hitMap.get(auraTarget.entityId); + if (firstHit == null || ticksExisted >= firstHit + noHitTicks) { + hitMap.put(auraTarget.entityId, lastSet); + setTarget(mc.theWorld.getEntityByID(auraTarget.entityId)); + return; + } + } + } + else if (!toClassTargets.isEmpty()) { + KillAuraTarget killAuraTarget = toClassTargets.get(0); + setTarget(mc.theWorld.getEntityByID(killAuraTarget.entityId)); + } + else { + setTarget(null); + } + } + + private void handleSwingAndAttack(double distance, boolean swung) { + boolean inAttackDistance = inRange(target, attackRange.getInput() - attackv); + if ((distance <= swingRange.getInput() || inAttackDistance) && shouldAttack && !swung) { // swing if in swing range or needs to attack + if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { + swingItem(); + } + } + if (inAttackDistance) { + attackingEntity = target; + if (shouldAttack) { + shouldAttack = false; + if (ModuleManager.bedAura.breakTick) { + return; + } + if (!isLookingAtEntity()) { + return; + } + if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { + mc.playerController.attackEntity(mc.thePlayer, target); + sAttacked = 0; + } + } + } + else { + attackingEntity = null; + } + } + + private boolean isHostile(EntityCreature entityCreature) { + if (SkyWars.onlyAuraHostiles()) { + if (entityCreature instanceof EntityGiantZombie) { + return false; + } + return !ModuleManager.skyWars.spawnedMobs.contains(entityCreature.getEntityId()); + } + else if (entityCreature instanceof EntitySilverfish) { + String teamColor = Utils.getFirstColorCode(entityCreature.getCustomNameTag()); + String teamColorSelf = Utils.getFirstColorCode(mc.thePlayer.getDisplayName().getFormattedText()); + if (!teamColor.isEmpty() && (teamColorSelf.equals(teamColor) || Utils.isTeammate(entityCreature))) { // same team + return false; + } + return true; + } + else if (entityCreature instanceof EntityIronGolem) { + if (Utils.getBedwarsStatus() != 2) { + return true; + } + if (!golems.containsKey(entityCreature.getEntityId())) { + double nearestDistance = -1; + EntityArmorStand nearestArmorStand = null; + for (Entity entity : mc.theWorld.loadedEntityList) { + if (!(entity instanceof EntityArmorStand)) { + continue; + } + String stripped = Utils.stripString(entity.getDisplayName().getFormattedText()); + if (stripped.contains("[") && stripped.endsWith("]")) { + double distanceSq = entity.getDistanceSq(entityCreature.posX, entityCreature.posY, entityCreature.posZ); + if (distanceSq < nearestDistance || nearestDistance == -1) { + nearestDistance = distanceSq; + nearestArmorStand = (EntityArmorStand) entity; + } + } + } + if (nearestArmorStand != null) { + String teamColor = Utils.getFirstColorCode(nearestArmorStand.getDisplayName().getFormattedText()); + String teamColorSelf = Utils.getFirstColorCode(mc.thePlayer.getDisplayName().getFormattedText()); + boolean isTeam = false; + if (!teamColor.isEmpty() && (teamColorSelf.equals(teamColor) || Utils.isTeammate(nearestArmorStand))) { // same team + isTeam = true; + } + golems.put(entityCreature.getEntityId(), isTeam); + return !isTeam; + } + if (ModuleManager.bedwars.spawnedMobs.contains(entityCreature.getEntityId())) { + return false; + } + return true; + } + else { + return !golems.getOrDefault(entityCreature.getEntityId(), false); + } + } + else if (entityCreature instanceof EntityPigZombie && Utils.getBedwarsStatus() != 2) { + return false; + } + return hostileMobs.contains(entityCreature); + } + + private int getAPSToTicks(double cap) { + double apsv = aps.getInput(); + if (apsv > cap) { + apsv = cap; + } + if (apsv >= 20) { + return 0; + } + if (apsv >= 16) { + return (int) Utils.randomizeDouble(0.0D, 1.0D); + } + if (apsv >= 15) { + return 1; + } + if (apsv >= 11) { + return (int) Utils.randomizeDouble(1.0D, 2.0D); + } + if (apsv >= 10) { + return 2; + } + if (apsv >= 7) { + return (int) Utils.randomizeDouble(2.0D, 3.0D); + } + if (apsv >= 6) { + return (int) Utils.randomizeDouble(3.0D, 4.0D); + } + if (apsv >= 5) { + return 4; + } + if (apsv >= 4) { + return 5; + } + if (apsv >= 3) { + return (int) Utils.randomizeDouble(6.0D, 7.0D); + } + if (apsv >= 2) { + return 10; + } + if (apsv >= 1) { + return 20; + } + if (apsv >= 0) { + return -1; + } + return -1; + } + + private void handleBlocking() { + if (!Utils.holdingSword()) { + return; + } + /*if (this.blockingClient == blockState && autoBlockMode.getInput() != 3) { + return; + }*/ + if (autoBlockMode.getInput() != previousAutoBlockMode) { + if (previousAutoBlockMode > 0) { + resetAutoblock(true); + } + } + previousAutoBlockMode = (int) autoBlockMode.getInput(); + if (!t || !hasAutoblocked) { + return; + } + ReflectionUtils.setItemInUse(blockingClient); + } + + private double getMaxRange() { + return Math.max(Math.max(swingRange.getInput(), attackRange.getInput() - attackv), blockRange.getInput()); + } + + public boolean autoBlockOverride() { + return autoBlockMode.getInput() > 0 && Utils.holdingSword() && manualBlock(); + } + + private float unwrapYaw(float yaw, float prevYaw) { + return prevYaw + ((((yaw - prevYaw + 180f) % 360f) + 360f) % 360f - 180f); + } + + private boolean isLookingAtEntity() { // + if (rotationMode.getInput() == 0 && rotationSmoothing.getInput() > 0) { // silent + return RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - attackv, RotationUtils.serverRotations); + } + return true; + } + + private void handleAutoBlock(double distance) { + boolean inAttackDistance = inRange(target, attackRange.getInput() - attackv); + if (inAttackDistance) { + attackingEntity = target; + } + boolean swung = false; + hasAutoblocked = true; + switch ((int) autoBlockMode.getInput()) { + case 1: + blockingClient = true; + interactTicks++; + if (!hasBlocked) { + handleInteractAndAttack(distance, true, true, swung); + sendBlockPacket(); + interactTicks = 0; + } + else { + if (interactTicks >= getAPSToTicks(20)) { + handleInteractAndAttack(distance, true, true, swung); + interactTicks = 0; + } + } + break; + case 2: // partial + if (interactTicks == 0) { + getTicks = getAPSToTicks(10); + } + interactTicks++; + if (interactTicks == 1) { + if (ModuleUtils.isBlocked) { + sendDigPacket(); + blockingClient = false; + } + } + if (interactTicks == 2) { + handleInteractAndAttack(distance, true, true, swung); + sendBlockPacket(); + blockingClient = true; + } + if (interactTicks >= getTicks) { + interactTicks = 0; + } + break; + case 3: // blink + blockingClient = true; + if (interactTicks == 0) { + getTicks = getAPSToTicks(10); + } + interactTicks++; + if (interactTicks == 1) { + if (ModuleUtils.isBlocked) { + blink = true; + setSwapSlot(); + } + } + if (interactTicks == 2) { + setCurrentSlot(); + handleInteractAndAttack(distance, true, true, swung); + sendBlockPacket(); + blink = false; + } + if (interactTicks >= getTicks) { + interactTicks = 0; + } + break; + case 4: // swap + blockingClient = true; + interactTicks++; + if (interactTicks == 1) { + if (ModuleUtils.isBlocked) { + setSwapSlot(); + setCurrentSlot(); + } + handleInteractAndAttack(distance, true, true, swung); + sendBlockPacket(); + } + if (interactTicks >= getAPSToTicks(20)) { + interactTicks = 0; + } + break; + } + } + + private void resetYaw(ClientRotationEvent event) { + reset = true; + event.yaw = RotationUtils.serverRotations[0]; + event.pitch = RotationUtils.serverRotations[1]; + rotated = false; + } + + private void srb() { + if (blockingClient) { + ReflectionUtils.setItemInUse(blockingClient = false); + } + } + + private boolean basicCondition() { + if (!Utils.nullCheck()) { + return false; + } + if (mc.thePlayer.isDead) { + return false; + } + return true; + } + + private void setCurrentSlot() { + if (!swapped) { + return; + } + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); + Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); + swapped = false; + } + + private void setSwapSlot() { + int bestSwapSlot = getBestSwapSlot(); + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(bestSwapSlot)); + Raven.packetsHandler.playerSlot.set(bestSwapSlot); + swapped = true; + blockingServer = false; + hasBlocked = false; + } + + private void sendDigPacket() { + if (!Utils.holdingSword()) { + return; + } + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + blockingServer = false; + hasBlocked = false; + } + + private void sendBlockPacket() { + mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); + blockingServer = true; + hasBlocked = true; + } + + private boolean settingCondition() { + if (requireMouseDown.isToggled() && !Mouse.isButtonDown(0)) { + return false; + } + else if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { + return false; + } + else if (disableWhileMining.isToggled() && Utils.isMining()) { + return false; + } + else if (disableInInventory.isToggled() && mc.currentScreen != null) { + return false; + } + else if (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && !ModuleManager.bedAura.allowAura.isToggled() && ModuleManager.bedAura.currentBlock != null) { + return false; + } + return true; + } + + private void setKeyBindState(int keycode, boolean state, boolean invokeTick) { + KeyBinding.setKeyBindState(keycode, state); + if (invokeTick) { + KeyBinding.onTick(keycode); + } + } + + private void updateAttackDelay() { + delay = (long)(1000.0 / aps.getInput() + Utils.randomizeInt(-4, 4)); + } + + private void swingItem() { + if (silentSwing.isToggled() && mc.thePlayer.isBlocking()) { + mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); + } + else { + mc.thePlayer.swingItem(); + } + } + + public static double getDistanceToBoundingBox(Entity target) { + if (mc.thePlayer == null) { + return 0; + } + Vec3 playerEyePos = mc.thePlayer.getPositionEyes(((IAccessorMinecraft) mc).getTimer().renderPartialTicks); + AxisAlignedBB boundingBox = target.getEntityBoundingBox(); + double nearestX = MathHelper.clamp_double(playerEyePos.xCoord, boundingBox.minX, boundingBox.maxX); + double nearestY = MathHelper.clamp_double(playerEyePos.yCoord, boundingBox.minY, boundingBox.maxY); + double nearestZ = MathHelper.clamp_double(playerEyePos.zCoord, boundingBox.minZ, boundingBox.maxZ); + Vec3 nearestPoint = new Vec3(nearestX, nearestY, nearestZ); + return playerEyePos.distanceTo(nearestPoint); + } + + private int getBestSwapSlot() { + int currentSlot = mc.thePlayer.inventory.currentItem; + int bestSlot = -1; + double bestDamage = -1; + for (int i = 0; i < 9; ++i) { + if (i == currentSlot) { + continue; + } + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); + double damage = Utils.getDamageLevel(stack); + if (damage != 0) { + if (damage > bestDamage) { + bestDamage = damage; + bestSlot = i; + } + } + } + if (bestSlot == -1) { + for (int i = 0; i < 9; ++i) { + if (i == currentSlot) { + continue; + } + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); + if (stack == null || Arrays.stream(swapBlacklist).noneMatch(stack.getUnlocalizedName().toLowerCase()::contains)) { + bestSlot = i; + break; + } + } + } + + return bestSlot; + } + + private int getNextSlot() { + int currentSlot = mc.thePlayer.inventory.currentItem; + int next = -1; + + if (currentSlot < 8) { + next = currentSlot + 1; + } + else { + next = currentSlot - 1; + } + + return next; + } + + public void resetYaw() { + float serverYaw = RotationUtils.serverRotations[0]; + float unwrappedYaw = unwrapYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw), serverYaw); + mc.thePlayer.rotationYaw = unwrappedYaw; + mc.thePlayer.prevRotationYaw = unwrappedYaw; + } + + private void interactAt(boolean interactAt, boolean interact, boolean noEvent, boolean requireInteractAt) { + if (attackingEntity == null) { + return; + } + if (ModuleManager.bedAura.breakTick) { + return; + } + boolean sent = false; + if (interactAt) { + boolean canHit = RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - attackv, RotationUtils.serverRotations); + if (!canHit) { + return; + } + MovingObjectPosition mov = RotationUtils.rayTrace(10, ((IAccessorMinecraft) mc).getTimer().renderPartialTicks, RotationUtils.serverRotations, hitThroughBlocks.isToggled() ? attackingEntity : null); + if (mov != null && mov.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mov.entityHit == attackingEntity) { + Vec3 hitVec = mov.hitVec; + hitVec = new Vec3(hitVec.xCoord - attackingEntity.posX, hitVec.yCoord - attackingEntity.posY, hitVec.zCoord - attackingEntity.posZ); + if (!noEvent) { + mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(attackingEntity, hitVec)); + } + else { + PacketUtils.sendPacketNoEvent(new C02PacketUseEntity(attackingEntity, hitVec)); + } + sent = true; + } + } + if (requireInteractAt && !sent) { + return; + } + if (interact) { + if (!noEvent) { + mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(attackingEntity, C02PacketUseEntity.Action.INTERACT)); + } + else { + PacketUtils.sendPacketNoEvent(new C02PacketUseEntity(attackingEntity, C02PacketUseEntity.Action.INTERACT)); + } + } + } + + private float[] getRotationsSmoothed(float rotations[]) { + float serverYaw = RotationUtils.serverRotations[0]; + float serverPitch = RotationUtils.serverRotations[1]; + float unwrappedYaw = unwrapYaw(rotations[0], serverYaw); + + float deltaYaw = unwrappedYaw - serverYaw; + float deltaPitch = rotations[1] - serverPitch; + + float yawSmoothing = (float) rotationSmoothing.getInput(); + float pitchSmoothing = yawSmoothing; + + float strafe = mc.thePlayer.moveStrafing; + if (strafe < 0 && deltaYaw < 0 || strafe > 0 && deltaYaw > 0) { + yawSmoothing = Math.max(1f, yawSmoothing / 2f); + } + + float motionY = (float) mc.thePlayer.motionY; + if (motionY > 0 && deltaPitch > 0 || motionY < 0 && deltaPitch < 0) { + pitchSmoothing = Math.max(1f, pitchSmoothing / 2f); + } + + serverYaw += deltaYaw / Math.max(1f, yawSmoothing); + serverPitch += deltaPitch / Math.max(1f, pitchSmoothing); + + return new float[] { serverYaw, serverPitch }; + } + + private void handleInteractAndAttack(double distance, boolean interactAt, boolean interact, boolean swung) { + if (ModuleManager.antiFireball != null && ModuleManager.antiFireball.isEnabled() && ModuleManager.antiFireball.fireball != null && ModuleManager.antiFireball.attack) { + if (ModuleManager.bedAura.breakTick) { + return; + } + if (!ModuleManager.antiFireball.silentSwing.isToggled()) { + mc.thePlayer.swingItem(); + } + else { + mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); + } + mc.playerController.attackEntity(mc.thePlayer, ModuleManager.antiFireball.fireball); + if (interact) { + mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ModuleManager.antiFireball.fireball, C02PacketUseEntity.Action.INTERACT)); + } + } + else { + handleSwingAndAttack(distance, swung); + interactAt(interactAt, interact, false, false); + } + } + + public void resetAutoblock(boolean unblock) { + if (!hasAutoblocked) { + return; + } + blink = false; + if (Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && swapped) { + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); + Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); + } + else if (unblock && !ModuleManager.scaffold.isEnabled && ModuleUtils.isBlocked) { + sendUnBlock = true; + } + swapped = false; + interactTicks = 0; + hasAutoblocked = false; + hasBlocked = false; + } + + private boolean inRange(final Entity target, final double distance) { + return RotationUtils.isPossibleToHit(target, distance, RotationUtils.getRotations(target)); + } + + private boolean manualBlock() { + return (!manualBlock.isToggled() || Mouse.isButtonDown(1)) && Utils.holdingSword(); + } + + static class KillAuraTarget { + double distance; + float health; + int hurttime; + double yawDelta; + int entityId; + boolean isEnemy; + + public KillAuraTarget(double distance, float health, int hurttime, double yawDelta, int entityId, boolean isEnemy) { + this.distance = distance; + this.health = health; + this.hurttime = hurttime; + this.yawDelta = yawDelta; + this.entityId = entityId; + this.isEnemy = isEnemy; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/LagRange.java b/src/main/java/keystrokesmod/module/impl/combat/LagRange.java new file mode 100644 index 0000000..97de585 --- /dev/null +++ b/src/main/java/keystrokesmod/module/impl/combat/LagRange.java @@ -0,0 +1,189 @@ +package keystrokesmod.module.impl.combat; + +import keystrokesmod.event.PostMotionEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.script.ScriptDefaults; +import keystrokesmod.script.model.NetworkPlayer; +import keystrokesmod.script.model.Vec3; +import keystrokesmod.utility.BlinkHandler; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFishingRod; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Objects; + +public class LagRange extends Module { + + public SliderSetting latency; + private SliderSetting activationDist; + private SliderSetting hurttime; + private ButtonSetting ignoreTeammates, weaponOnly; + public ButtonSetting renderTimer, initialPosition; + + private int disableTicks; + private Vec3 lastPosition; + private double closest; + private double startFallHeight; + private boolean function; + + public boolean blink; + + private long delay; + + public LagRange() { + super("LagRange", category.combat, 0); + + this.registerSetting(latency = new SliderSetting("Latency", "ms", 300, 10, 500, 10)); + this.registerSetting(activationDist = new SliderSetting("Activation Distance", " blocks", 7, 0, 20, 1)); + this.registerSetting(hurttime = new SliderSetting("Hurttime", 2, 0, 10, 1)); + this.registerSetting(initialPosition = new ButtonSetting("Show initial position", true)); + this.registerSetting(ignoreTeammates = new ButtonSetting("Ignore teammates", false)); + this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); + } + + @Override + public String getInfo() { + return (int) latency.getInput() + "ms"; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + disableTicks--; + double boxSize = activationDist.getInput(); + + Vec3 myPosition = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + boolean onGround = mc.thePlayer.onGround; + + if (ModuleUtils.isBreaking) { + disableTicks = 1; + function = false; + } + + if (Utils.getHorizontalSpeed() > 0.4) { + disableTicks = 5; + function = false; + } + + if (Utils.holdingFishingRod() && ModuleUtils.rcTick == 1) { + disableTicks = 1; + function = false; + } + + if (Utils.isReplay() || Utils.isLobby()) { + disableTicks = 1; + function = false; + } + + if (mc.thePlayer.motionX == 0.0D && mc.thePlayer.motionY == -0.0784000015258789D && mc.thePlayer.motionZ == 0.0D && !Utils.isMoving()) { + disableTicks = 1; + function = false; + } + + a(boxSize, myPosition); + + boolean correctHeldItem = !weaponOnly.isToggled(); + if (!correctHeldItem) { + boolean holdingWeapon = false; + holdingWeapon = Utils.holdingWeapon(); // Weapon check + correctHeldItem = holdingWeapon; + } + + function = correctHeldItem && disableTicks < 0 && closest != -1 && closest < boxSize * boxSize; + + if (lastPosition != null && !onGround && lastPosition.y > myPosition.y && myPosition.y > startFallHeight) { + startFallHeight = myPosition.y; + } else if (onGround && myPosition.y < startFallHeight) { + if (startFallHeight - myPosition.y > 3 && !mc.thePlayer.capabilities.allowFlying) { // Check if you took fall damage + disableTicks = 5; + function = false; + } + startFallHeight = -Double.MAX_VALUE; + } + lastPosition = myPosition; + } + + private void a(double boxSize, Vec3 myPosition) { + closest = -1; + for (Entity entity : mc.theWorld.loadedEntityList) { + if (entity == null || entity == mc.thePlayer || entity.isDead) { + continue; + } + if (entity instanceof EntityPlayer) { + if (Utils.isFriended((EntityPlayer) entity)) { + continue; + } + if (((EntityPlayer) entity).deathTime != 0) { + continue; + } + if (AntiBot.isBot(entity) || (Utils.isTeammate(entity) && ignoreTeammates.isToggled())) { + continue; + } + } + else { + continue; + } + double maxRange = activationDist.getInput(); + if (mc.thePlayer.getDistanceToEntity(entity) < maxRange + maxRange / 3) { // simple distance check + Vec3 position = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + double distanceSq = position.distanceToSq(myPosition); + if (closest == -1 || distanceSq < closest) { + closest = distanceSq; + } + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C02PacketUseEntity) { + C02PacketUseEntity c02 = (C02PacketUseEntity) e.getPacket(); + int enemyHT = Utils.getHurttime(c02.getEntityFromWorld(mc.theWorld)); + if (Objects.equals(String.valueOf(c02.getAction()), "ATTACK")) { + if (enemyHT <= hurttime.getInput()) { + disableTicks = 1; + function = false; + } + /*Vec3 ps = new Vec3(c02.getEntityFromWorld(mc.theWorld).posX, c02.getEntityFromWorld(mc.theWorld).posY, c02.getEntityFromWorld(mc.theWorld).posZ); + Vec3 p2 = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + if (checkDistance.isToggled() && ps.distanceToSq(p2)) { + + }*/ + } + } + } + + @SubscribeEvent + public void onPostMotion(PostMotionEvent e) { + if (function) { + if (delay == -1) { + delay = Utils.time(); + blink = true; + } + if (delay > 0 && (Utils.time() - delay) >= latency.getInput()) { + delay = -1; + blink = false; + } + } + else { + blink = false; + delay = -1; + } + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/Reduce.java b/src/main/java/keystrokesmod/module/impl/combat/Reduce.java index 8be787d..6796578 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/Reduce.java +++ b/src/main/java/keystrokesmod/module/impl/combat/Reduce.java @@ -1,33 +1,33 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import net.minecraft.entity.Entity; - -public class Reduce extends Module { - private static SliderSetting chance; - private static SliderSetting reduction; - - public Reduce() { - super("Reduce", category.combat); - this.registerSetting(new DescriptionSetting("Overrides KeepSprint.")); - this.registerSetting(reduction = new SliderSetting("Attack reduction %", 60.0, 60.0, 100.0, 0.5)); - this.registerSetting(chance = new SliderSetting("Chance", "%", 100.0, 0.0, 100.0, 1.0)); - this.closetModule = true; - } - - public static void reduce(Entity entity) { - if (chance.getInput() == 0) { - return; - } - if (chance.getInput() != 100.0 && Math.random() >= chance.getInput() / 100.0) { - mc.thePlayer.motionX *= 0.6; - mc.thePlayer.motionZ *= 0.6; - return; - } - double n = (100.0 - (float)reduction.getInput()) / 100.0; - mc.thePlayer.motionX *= n; - mc.thePlayer.motionZ *= n; - } +package keystrokesmod.module.impl.combat; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import net.minecraft.entity.Entity; + +public class Reduce extends Module { + private static SliderSetting chance; + private static SliderSetting reduction; + + public Reduce() { + super("Reduce", category.combat); + this.registerSetting(new DescriptionSetting("Overrides KeepSprint.")); + this.registerSetting(reduction = new SliderSetting("Attack reduction %", 60.0, 60.0, 100.0, 0.5)); + this.registerSetting(chance = new SliderSetting("Chance", "%", 100.0, 0.0, 100.0, 1.0)); + this.closetModule = true; + } + + public static void reduce(Entity entity) { + if (chance.getInput() == 0) { + return; + } + if (chance.getInput() != 100.0 && Math.random() >= chance.getInput() / 100.0) { + mc.thePlayer.motionX *= 0.6; + mc.thePlayer.motionZ *= 0.6; + return; + } + double n = (100.0 - (float)reduction.getInput()) / 100.0; + mc.thePlayer.motionX *= n; + mc.thePlayer.motionZ *= n; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/TPAura.java b/src/main/java/keystrokesmod/module/impl/combat/TPAura.java index f421fae..8c612eb 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/TPAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/TPAura.java @@ -1,67 +1,67 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class TPAura extends Module { - private SliderSetting range; - private ButtonSetting weaponOnly; - private double x = 0; - private double z = 0; - private double y = 0; - - public TPAura() { - super("TPAura", category.combat); - this.registerSetting(range = new SliderSetting("Range", 0, 0, 50, 1)); - this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); - } - - @SubscribeEvent - public void onLivingUpdate(LivingEvent.LivingUpdateEvent e) { - if (Utils.nullCheck() && mc.thePlayer.maxHurtTime > 0 && mc.thePlayer.hurtTime == mc.thePlayer.maxHurtTime) { - this.updatePosition(); - } - } - - private void updatePosition() { - this.x = Utils.randomizeInt(-15, 15) / 10.0; - this.y = Utils.randomizeInt(10, 15) / 10.0; - this.z = Utils.randomizeInt(-15, 15) / 10.0; - } - - @Override - public void onEnable() { - if (range.getInput() == 0.0) { - Utils.sendMessage("&cTPAura range values are set to 0."); - this.disable(); - return; - } - this.updatePosition(); - } - - public void onUpdate() { - if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { - return; - } - double rangeSq = range.getInput() * range.getInput(); - for (EntityPlayer entityPlayer : mc.theWorld.playerEntities) { - if (entityPlayer != mc.thePlayer && entityPlayer.deathTime == 0) { - if (mc.thePlayer.getDistanceSqToEntity(entityPlayer) > rangeSq) { - continue; - } - if (AntiBot.isBot(entityPlayer) || Utils.isFriended(entityPlayer)) { - continue; - } - mc.thePlayer.setPosition(entityPlayer.posX + this.x, entityPlayer.posY + this.y, entityPlayer.posZ + this.z); - Utils.attackEntity(entityPlayer, true, false); - break; - } - } - } -} +package keystrokesmod.module.impl.combat; + +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class TPAura extends Module { + private SliderSetting range; + private ButtonSetting weaponOnly; + private double x = 0; + private double z = 0; + private double y = 0; + + public TPAura() { + super("TPAura", category.combat); + this.registerSetting(range = new SliderSetting("Range", 0, 0, 50, 1)); + this.registerSetting(weaponOnly = new ButtonSetting("Weapon only", false)); + } + + @SubscribeEvent + public void onLivingUpdate(LivingEvent.LivingUpdateEvent e) { + if (Utils.nullCheck() && mc.thePlayer.maxHurtTime > 0 && mc.thePlayer.hurtTime == mc.thePlayer.maxHurtTime) { + this.updatePosition(); + } + } + + private void updatePosition() { + this.x = Utils.randomizeInt(-15, 15) / 10.0; + this.y = Utils.randomizeInt(10, 15) / 10.0; + this.z = Utils.randomizeInt(-15, 15) / 10.0; + } + + @Override + public void onEnable() { + if (range.getInput() == 0.0) { + Utils.sendMessage("&cTPAura range values are set to 0."); + this.disable(); + return; + } + this.updatePosition(); + } + + public void onUpdate() { + if (weaponOnly.isToggled() && !Utils.holdingWeapon()) { + return; + } + double rangeSq = range.getInput() * range.getInput(); + for (EntityPlayer entityPlayer : mc.theWorld.playerEntities) { + if (entityPlayer != mc.thePlayer && entityPlayer.deathTime == 0) { + if (mc.thePlayer.getDistanceSqToEntity(entityPlayer) > rangeSq) { + continue; + } + if (AntiBot.isBot(entityPlayer) || Utils.isFriended(entityPlayer)) { + continue; + } + mc.thePlayer.setPosition(entityPlayer.posX + this.x, entityPlayer.posY + this.y, entityPlayer.posZ + this.z); + Utils.attackEntity(entityPlayer, true, false); + break; + } + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/combat/Velocity.java b/src/main/java/keystrokesmod/module/impl/combat/Velocity.java index 578714d..a78f581 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/Velocity.java +++ b/src/main/java/keystrokesmod/module/impl/combat/Velocity.java @@ -1,31 +1,30 @@ package keystrokesmod.module.impl.combat; import keystrokesmod.Raven; -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.ReceiveAllPacketsEvent; -import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.*; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.impl.movement.LongJump; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.KeySetting; import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.*; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.network.play.server.S12PacketEntityVelocity; import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import org.lwjgl.input.Keyboard; - -import java.util.concurrent.ConcurrentLinkedQueue; +import org.lwjgl.input.Mouse; public class Velocity extends Module { - public SliderSetting velocityModes; + public SliderSetting mode; public static SliderSetting vertical, horizontal, reverseHorizontal, explosionsHorizontal, explosionsVertical, verticalM; public static SliderSetting minExtraSpeed, extraSpeedBoost; private SliderSetting chance; @@ -36,17 +35,31 @@ public class Velocity extends Module { public ButtonSetting allowSelfFireball; public static ButtonSetting reverseDebug; private KeySetting switchToReverse, switchToPacket; + private ButtonSetting requireMouseDown; + private ButtonSetting requireMovingForward; + private ButtonSetting requireAim; + private ButtonSetting delay; + private ButtonSetting disableLobby; private boolean stopFBvelo; public boolean disableVelo; - private long delay; private boolean buttonDown, pDown, rDown; + private boolean setJump; + private boolean ignoreNext; + private boolean aiming; + private int lastHurtTime; + private double lastFallDistance; - private String[] velocityModesString = new String[] { "Normal", "Packet", "Reverse" }; + public boolean blink; + private int delayTicks; + + private int db; + + private String[] modes = new String[] { "Normal", "Packet", "Reverse", "Jump Reset" }; public Velocity() { super("Velocity", category.combat); - this.registerSetting(velocityModes = new SliderSetting("Mode", 0, velocityModesString)); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); this.registerSetting(horizontal = new SliderSetting("Horizontal", 0.0, 0.0, 100.0, 1.0)); this.registerSetting(vertical = new SliderSetting("Vertical", 0.0, 0.0, 100.0, 1.0)); this.registerSetting(verticalM = new SliderSetting("Vertical Motion Limit", 1.0, -1.0, 1, 0.1)); @@ -71,47 +84,76 @@ public class Velocity extends Module { this.registerSetting(switchToPacket = new KeySetting("Switch to packet", Keyboard.KEY_SPACE)); this.registerSetting(reverseDebug = new ButtonSetting("Show reverse debug messages", false)); + + this.registerSetting(requireMouseDown = new ButtonSetting("Require mouse down", false)); + this.registerSetting(requireMovingForward = new ButtonSetting("Require moving forward", false)); + this.registerSetting(requireAim = new ButtonSetting("Require aim", false)); + this.registerSetting(delay = new ButtonSetting("Delay", false)); + + this.registerSetting(disableLobby = new ButtonSetting("Disable in lobby", false)); } public void guiUpdate() { - this.onlyWhileAttacking.setVisible(velocityModes.getInput() == 0, this); - this.onlyWhileTargeting.setVisible(velocityModes.getInput() == 0, this); - this.disableS.setVisible(velocityModes.getInput() == 0, this); + this.onlyWhileAttacking.setVisible(mode.getInput() == 0, this); + this.onlyWhileTargeting.setVisible(mode.getInput() == 0, this); + this.disableS.setVisible(mode.getInput() == 0, this); - this.allowSelfFireball.setVisible(velocityModes.getInput() == 1, this); - this.zzWhileNotTargeting.setVisible(velocityModes.getInput() == 1, this); + this.allowSelfFireball.setVisible(mode.getInput() == 1, this); + this.zzWhileNotTargeting.setVisible(mode.getInput() == 1, this); - this.switchToReverse.setVisible(velocityModes.getInput() == 1, this); - this.switchToPacket.setVisible(velocityModes.getInput() == 2, this); + this.switchToReverse.setVisible(mode.getInput() == 1, this); + this.switchToPacket.setVisible(mode.getInput() == 2, this); - this.horizontal.setVisible(velocityModes.getInput() != 2, this); - this.vertical.setVisible(velocityModes.getInput() != 2, this); - this.verticalM.setVisible(velocityModes.getInput() == 1, this); - this.chance.setVisible(velocityModes.getInput() != 2, this); - this.reverseHorizontal.setVisible(velocityModes.getInput() == 2, this); + this.horizontal.setVisible(mode.getInput() != 2 && mode.getInput() != 3, this); + this.vertical.setVisible(mode.getInput() != 2 && mode.getInput() != 3, this); + this.verticalM.setVisible(mode.getInput() == 1, this); + this.chance.setVisible(mode.getInput() != 2, this); + this.reverseHorizontal.setVisible(mode.getInput() == 2, this); - this.explosionsHorizontal.setVisible(velocityModes.getInput() != 0, this); - this.explosionsVertical.setVisible(velocityModes.getInput() != 0, this); + this.explosionsHorizontal.setVisible(mode.getInput() != 0 && mode.getInput() != 3, this); + this.explosionsVertical.setVisible(mode.getInput() != 0 && mode.getInput() != 3, this); - this.minExtraSpeed.setVisible(velocityModes.getInput() == 2, this); - this.extraSpeedBoost.setVisible(velocityModes.getInput() == 2, this); - this.reverseDebug.setVisible(velocityModes.getInput() == 2, this); + this.minExtraSpeed.setVisible(mode.getInput() == 2, this); + this.extraSpeedBoost.setVisible(mode.getInput() == 2, this); + this.reverseDebug.setVisible(mode.getInput() == 2, this); + + this.requireMouseDown.setVisible(mode.getInput() == 3, this); + this.requireMovingForward.setVisible(mode.getInput() == 3, this); + this.requireAim.setVisible(mode.getInput() == 3, this); + this.delay.setVisible(mode.getInput() == 3, this); + } + + @Override + public String getInfo() { + return mode.getInput() == 2 ? "-" + ((int) reverseHorizontal.getInput()) + "%" : (mode.getInput() == 3 ? modes[(int) mode.getInput()] : ((int) horizontal.getInput() + "%" + " " + (int) vertical.getInput() + "%")); + } + + @Override + public void onDisable() { + blink = false; + delayTicks = 0; + stopFBvelo = disableVelo = false; + buttonDown = pDown = rDown = false; + setJump = ignoreNext = aiming = false; + lastHurtTime = 0; + lastFallDistance = 0; + db = 0; } @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { if (Utils.tabbedIn()) { - if (switchToReverse.isPressed() && velocityModes.getInput() == 1 && !buttonDown) { - velocityModes.setValue(2); + if (switchToReverse.isPressed() && mode.getInput() == 1 && !buttonDown) { + mode.setValue(2); buttonDown = true; - Utils.print(Utils.formatColor("&7[&dR&7]&7 Switched to &bReverse&7 Velocity mode")); + Utils.modulePrint(Utils.formatColor("&7[&dR&7]&7 Switched to &bReverse&7 Velocity mode")); } - if (switchToPacket.isPressed() && velocityModes.getInput() == 2 && !buttonDown) { - velocityModes.setValue(1); + if (switchToPacket.isPressed() && mode.getInput() == 2 && !buttonDown) { + mode.setValue(1); buttonDown = true; - Utils.print(Utils.formatColor("&7[&dR&7]&7 Switched to &bPacket&7 Velocity mode")); + Utils.modulePrint(Utils.formatColor("&7[&dR&7]&7 Switched to &bPacket&7 Velocity mode")); } } if (switchToReverse.isPressed() || switchToPacket.isPressed()) { @@ -120,12 +162,74 @@ public class Velocity extends Module { else { buttonDown = false; } + + if (delayTicks-- == 0 && delay.isToggled()) { + blink = false; + } + + if (db > 0) { + db--; + } + + int hurtTime = mc.thePlayer.hurtTime; + boolean onGround = mc.thePlayer.onGround; + + if (onGround && lastFallDistance > 3 && !mc.thePlayer.capabilities.allowFlying) ignoreNext = true; + if (hurtTime > lastHurtTime) { + + boolean mouseDown = Mouse.isButtonDown(0) || !requireMouseDown.isToggled(); + boolean aimingAt = aiming || !requireAim.isToggled(); + + boolean forward = mc.gameSettings.keyBindForward.isKeyDown() || !requireMovingForward.isToggled(); + + handlejr(onGround, aimingAt, forward, mouseDown); + ignoreNext = false; + } + + lastHurtTime = hurtTime; + lastFallDistance = mc.thePlayer.fallDistance; + } + + private void handlejr(boolean onGround, boolean aimingAt, boolean forward, boolean mouseDown) { + if (mode.getInput() != 3) { + return; + } + if (disableLobby.isToggled() && Utils.isLobby()) { + return; + } + if (db > 0) { + return; + } + if (!ignoreNext && onGround && aimingAt && forward && mouseDown && Utils.randomizeDouble(0, 100) < chance.getInput() && !hasBadEffect()) { + if (delay.isToggled()) { + blink = true; + delayTicks = 3; + } + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), setJump = true); + KeyBinding.onTick(mc.gameSettings.keyBindJump.getKeyCode()); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7jumping enabled"); + } + } + } + + @SubscribeEvent + public void onPostMotion(PostMotionEvent e) { + if (setJump && !Utils.jumpDown()) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), setJump = false); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7jumping disabled"); + } + } } @SubscribeEvent public void onReceivePacketAll(ReceiveAllPacketsEvent e) { - if (velocityModes.getInput() >= 1) { - if (!Utils.nullCheck() || LongJump.stopVelocity || e.isCanceled() || velocityModes.getInput() == 2 && ModuleUtils.firstDamage || ModuleManager.bhop.isEnabled() && ModuleManager.bhop.damageBoost.isToggled() && ModuleUtils.firstDamage && (!ModuleManager.bhop.damageBoostRequireKey.isToggled() || ModuleManager.bhop.damageBoostKey.isPressed())) { + if (e.getPacket() instanceof S27PacketExplosion) { + db = 10; + } + if (mode.getInput() == 1) { + if (!Utils.nullCheck() || LongJump.stopVelocity || e.isCanceled() || disableLobby.isToggled() && Utils.isLobby() || ModuleManager.bhop.isEnabled() && ModuleManager.bhop.damageBoost.isToggled() && ModuleUtils.firstDamage && (!ModuleManager.bhop.damageBoostRequireKey.isToggled() || ModuleManager.bhop.damageBoostKey.isPressed())) { return; } if (e.getPacket() instanceof S27PacketExplosion) { @@ -200,14 +304,9 @@ public class Velocity extends Module { } } - @Override - public String getInfo() { - return (int) horizontal.getInput() + "%" + " " + (int) vertical.getInput() + "%"; - } - @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent ev) { - if (velocityModes.getInput() == 0) { + if (mode.getInput() == 0) { if (Utils.nullCheck() && !LongJump.stopVelocity && !ModuleManager.bedAura.cancelKnockback()) { if (mc.thePlayer.maxHurtTime <= 0 || mc.thePlayer.hurtTime != mc.thePlayer.maxHurtTime) { return; @@ -227,6 +326,9 @@ public class Velocity extends Module { if (chance.getInput() == 0) { return; } + if (disableLobby.isToggled() && Utils.isLobby()) { + return; + } if (chance.getInput() != 100) { double ch = Math.random(); if (ch >= chance.getInput() / 100.0D) { @@ -244,24 +346,33 @@ public class Velocity extends Module { } } + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C03PacketPlayer.C05PacketPlayerLook) { + checkAim(((C03PacketPlayer.C05PacketPlayerLook) e.getPacket()).getYaw(), ((C03PacketPlayer.C05PacketPlayerLook) e.getPacket()).getPitch()); + } + else if (e.getPacket() instanceof C03PacketPlayer.C06PacketPlayerPosLook) { + checkAim(((C03PacketPlayer.C06PacketPlayerPosLook) e.getPacket()).getYaw(), ((C03PacketPlayer.C06PacketPlayerPosLook) e.getPacket()).getPitch()); + } + } + public boolean dontEditMotion() { - if (mc.thePlayer.motionY >= verticalM.getInput() && !mc.thePlayer.onGround || velocityModes.getInput() == 1 && zzWhileNotTargeting.isToggled() && KillAura.attackingEntity != null || ModuleManager.noFall.start || ModuleManager.blink.isEnabled() && ModuleManager.blink.cancelKnockback.isToggled() || ModuleManager.bedAura.cancelKnockback() || ModuleManager.tower.cancelKnockback()) { + if (mc.thePlayer.motionY >= verticalM.getInput() && !mc.thePlayer.onGround || mode.getInput() == 1 && zzWhileNotTargeting.isToggled() && KillAura.attackingEntity == null) { return true; } return false; } - private boolean blinkModules() { - if (ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blinking.get()) { - return true; - } - if (ModuleManager.blink.isEnabled() && ModuleManager.blink.started) { - return true; - } - if (ModuleManager.antiVoid.isEnabled() && ModuleManager.antiVoid.started) { - return true; + private boolean hasBadEffect() { + for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { + String name = potionEffect.getEffectName(); + return name.equals("potion.jump") || name.equals("potion.poison") || name.equals("potion.wither"); } return false; } + private void checkAim(float yaw, float pitch) { + MovingObjectPosition result = RotationUtils.rayTrace(5, ((IAccessorMinecraft) mc).getTimer().renderPartialTicks, new float[] { yaw, pitch }, null); + aiming = result != null && result.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && result.entityHit instanceof EntityOtherPlayerMP; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/WTap.java b/src/main/java/keystrokesmod/module/impl/combat/WTap.java index 136167b..ca8e40c 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/WTap.java +++ b/src/main/java/keystrokesmod/module/impl/combat/WTap.java @@ -1,77 +1,82 @@ -package keystrokesmod.module.impl.combat; - -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.entity.player.AttackEntityEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.HashMap; - -public class WTap extends Module { - private SliderSetting delay; - private SliderSetting hurttime; - private SliderSetting chance; - private ButtonSetting playersOnly; - - private final HashMap hits = new HashMap<>(); - public static boolean stopSprint = false; - - public WTap() { - super("WTap", category.combat); - this.registerSetting(delay = new SliderSetting("Delay", "ms", 200, 0, 1000, 50)); - this.registerSetting(hurttime = new SliderSetting("Hurttime", 0, 0, 10, 1)); - this.registerSetting(chance = new SliderSetting("Chance", "%", 100, 0, 100, 1)); - this.registerSetting(playersOnly = new ButtonSetting("Players only", true)); - this.closetModule = true; - } - - @SubscribeEvent - public void onAttack(AttackEntityEvent event) { - if (!Utils.nullCheck() || event.entityPlayer != mc.thePlayer || !mc.thePlayer.isSprinting()) { - return; - } - if (chance.getInput() == 0) { - return; - } - if (playersOnly.isToggled()) { - if (!(event.target instanceof EntityPlayer)) { - return; - } - if (AntiBot.isBot(event.target)) { - return; - } - } - else if (!(event.target instanceof EntityLivingBase)) { - return; - } - if (((EntityLivingBase)event.target).deathTime != 0) { - return; - } - if (((EntityLivingBase) event.target).hurtTime > hurttime.getInput()) { - return; - } - long currentMs = System.currentTimeMillis(); - Long lastHit = this.hits.get(event.target.getEntityId()); - if (lastHit != null && Utils.timeBetween(lastHit, currentMs) <= (long) delay.getInput()) { - return; - } - if (chance.getInput() != 100.0D) { - double ch = Math.random(); - if (ch >= chance.getInput() / 100.0D) { - return; - } - } - this.hits.put(event.target.getEntityId(), currentMs); - stopSprint = true; - } - - public void onDisable() { - stopSprint = false; - this.hits.clear(); - } +package keystrokesmod.module.impl.combat; + +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.HashMap; + +public class WTap extends Module { + private SliderSetting delay; + private SliderSetting hurttime; + private SliderSetting chance; + private ButtonSetting playersOnly; + + private final HashMap hits = new HashMap<>(); + public static boolean stopSprint = false; + + public WTap() { + super("WTap", category.combat); + this.registerSetting(delay = new SliderSetting("Delay", "ms", 200, 0, 1000, 50)); + this.registerSetting(hurttime = new SliderSetting("Hurttime", 0, 0, 10, 1)); + this.registerSetting(chance = new SliderSetting("Chance", "%", 100, 0, 100, 1)); + this.registerSetting(playersOnly = new ButtonSetting("Players only", true)); + this.closetModule = true; + } + + @Override + public String getInfo() { + return (int) delay.getInput() + "ms"; + } + + @SubscribeEvent + public void onAttack(AttackEntityEvent event) { + if (!Utils.nullCheck() || event.entityPlayer != mc.thePlayer || !mc.thePlayer.isSprinting()) { + return; + } + if (chance.getInput() == 0) { + return; + } + if (playersOnly.isToggled()) { + if (!(event.target instanceof EntityPlayer)) { + return; + } + if (AntiBot.isBot(event.target)) { + return; + } + } + else if (!(event.target instanceof EntityLivingBase)) { + return; + } + if (((EntityLivingBase)event.target).deathTime != 0) { + return; + } + if (((EntityLivingBase) event.target).hurtTime > hurttime.getInput()) { + return; + } + long currentMs = System.currentTimeMillis(); + Long lastHit = this.hits.get(event.target.getEntityId()); + if (lastHit != null && Utils.timeBetween(lastHit, currentMs) <= (long) delay.getInput()) { + return; + } + if (chance.getInput() != 100.0D) { + double ch = Math.random(); + if (ch >= chance.getInput() / 100.0D) { + return; + } + } + this.hits.put(event.target.getEntityId(), currentMs); + stopSprint = true; + } + + public void onDisable() { + stopSprint = false; + this.hits.clear(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/minigames/AutoRequeue.java b/src/main/java/keystrokesmod/module/impl/minigames/AutoRequeue.java index d534c40..6f8c861 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/AutoRequeue.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/AutoRequeue.java @@ -1,66 +1,66 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class AutoRequeue extends Module { - private SliderSetting delay; - - private String receivedMessage = ""; - private long receiveTime = 0; - - public AutoRequeue() { - super("AutoRequeue", category.minigames); - this.registerSetting(new DescriptionSetting("Automatically requeues games.")); - this.registerSetting(delay = new SliderSetting("Delay", " second", 0.5, 0, 5, 0.1)); - this.closetModule = true; - } - - @Override - public void onDisable() { - receivedMessage = ""; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!receivedMessage.isEmpty() && System.currentTimeMillis() - receiveTime >= delay.getInput() * 1000) { - mc.thePlayer.sendChatMessage(receivedMessage); - receivedMessage = ""; - } - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent e) { - if (e.type == 2 || !Utils.nullCheck()) { - return; - } - String stripped = Utils.stripColor(e.message.getUnformattedText()); - if (stripped.isEmpty() || !stripped.contains("play again")) { - return; - } - if (e.message != null) { - for (IChatComponent component : e.message.getSiblings()) { - if (component != null && component.getFormattedText().contains("Click here")) { - if (component.getChatStyle() != null && component.getChatStyle().getChatClickEvent() != null && component.getChatStyle().getChatClickEvent().getValue().startsWith("/")) { - this.receivedMessage = component.getChatStyle().getChatClickEvent().getValue(); - this.receiveTime = System.currentTimeMillis(); - } - } - } - } - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - receivedMessage = ""; // will not requeue if you left the world where the message was sent - } - } +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class AutoRequeue extends Module { + private SliderSetting delay; + + private String receivedMessage = ""; + private long receiveTime = 0; + + public AutoRequeue() { + super("AutoRequeue", category.minigames); + this.registerSetting(new DescriptionSetting("Automatically requeues games.")); + this.registerSetting(delay = new SliderSetting("Delay", " second", 0.5, 0, 5, 0.1)); + this.closetModule = true; + } + + @Override + public void onDisable() { + receivedMessage = ""; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!receivedMessage.isEmpty() && System.currentTimeMillis() - receiveTime >= delay.getInput() * 1000) { + mc.thePlayer.sendChatMessage(receivedMessage); + receivedMessage = ""; + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (e.type == 2 || !Utils.nullCheck()) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + if (stripped.isEmpty() || !stripped.contains("play again")) { + return; + } + if (e.message != null) { + for (IChatComponent component : e.message.getSiblings()) { + if (component != null && component.getFormattedText().contains("Click here")) { + if (component.getChatStyle() != null && component.getChatStyle().getChatClickEvent() != null && component.getChatStyle().getChatClickEvent().getValue().startsWith("/")) { + this.receivedMessage = component.getChatStyle().getChatClickEvent().getValue(); + this.receiveTime = System.currentTimeMillis(); + } + } + } + } + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + receivedMessage = ""; // will not requeue if you left the world where the message was sent + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/minigames/AutoWho.java b/src/main/java/keystrokesmod/module/impl/minigames/AutoWho.java index be5852b..a5ea170 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/AutoWho.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/AutoWho.java @@ -1,68 +1,68 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class AutoWho extends Module { - private ButtonSetting artifical; - private ButtonSetting hideMessage; - private ButtonSetting removeBots; - private ButtonSetting onGameStart; - - public AutoWho() { - super("AutoWho", category.minigames); - this.registerSetting(new DescriptionSetting("Automatically execute /who.")); - this.registerSetting(new DescriptionSetting(Utils.formatColor("Use '&enick [nick]&r' when nicked."))); - this.registerSetting(artifical = new ButtonSetting("Artificial", false)); - this.registerSetting(hideMessage = new ButtonSetting("Hide message", false)); - this.registerSetting(removeBots = new ButtonSetting("Remove bots", true)); - this.registerSetting(onGameStart = new ButtonSetting("On game start", false)); - } - - @SubscribeEvent - public void onChatReceive(ClientChatReceivedEvent e) { - if (e.type == 2 || !Utils.nullCheck()) { - return; - } - final String r = Utils.stripColor(e.message.getUnformattedText()); - if (r.isEmpty()) { - return; - } - if (!onGameStart.isToggled() && (r.replace("!", "").trim().startsWith(Utils.getServerName()) && ((r.contains("(") && r.contains(")")) || r.contains("/"))) || onGameStart.isToggled() && r.contains("Protect your bed and destroy the enemy beds.")) { - this.artificial(); - } - else if (hideMessage.isToggled() && r.startsWith("ONLINE: ")) { - e.setCanceled(true); - Utils.log.info("[CHAT] " + r); - } - } - - private void artificial() { - if (artifical.isToggled()) { - String online = hideMessage.isToggled() ? "ONLINE: " : "&b&lONLINE: &r"; - for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(true)) { - if (removeBots.isToggled() && networkPlayerInfo.getResponseTime() > 1) { - continue; - } - if (hideMessage.isToggled()) { - online = online + networkPlayerInfo.getGameProfile().getName() + ", "; - } else { - online = online + ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()) + "�" + "7, "; - } - } - if (hideMessage.isToggled()) { - Utils.log.info("[CHAT] " + (online + mc.thePlayer.getName())); - return; - } - Utils.sendRawMessage(online + mc.thePlayer.getDisplayName().getFormattedText()); - } else { - mc.thePlayer.sendChatMessage("/who"); - } - } -} +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class AutoWho extends Module { + private ButtonSetting artifical; + private ButtonSetting hideMessage; + private ButtonSetting removeBots; + private ButtonSetting onGameStart; + + public AutoWho() { + super("AutoWho", category.minigames); + this.registerSetting(new DescriptionSetting("Automatically execute /who.")); + this.registerSetting(new DescriptionSetting(Utils.formatColor("Use '&enick [nick]&r' when nicked."))); + this.registerSetting(artifical = new ButtonSetting("Artificial", false)); + this.registerSetting(hideMessage = new ButtonSetting("Hide message", false)); + this.registerSetting(removeBots = new ButtonSetting("Remove bots", true)); + this.registerSetting(onGameStart = new ButtonSetting("On game start", false)); + } + + @SubscribeEvent + public void onChatReceive(ClientChatReceivedEvent e) { + if (e.type == 2 || !Utils.nullCheck()) { + return; + } + final String r = Utils.stripColor(e.message.getUnformattedText()); + if (r.isEmpty()) { + return; + } + if (!onGameStart.isToggled() && (r.replace("!", "").trim().startsWith(Utils.getServerName()) && ((r.contains("(") && r.contains(")")) || r.contains("/"))) || onGameStart.isToggled() && r.contains("Protect your bed and destroy the enemy beds.")) { + this.artificial(); + } + else if (hideMessage.isToggled() && r.startsWith("ONLINE: ")) { + e.setCanceled(true); + Utils.log.info("[CHAT] " + r); + } + } + + private void artificial() { + if (artifical.isToggled()) { + String online = hideMessage.isToggled() ? "ONLINE: " : "&b&lONLINE: &r"; + for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(true)) { + if (removeBots.isToggled() && networkPlayerInfo.getResponseTime() > 1) { + continue; + } + if (hideMessage.isToggled()) { + online = online + networkPlayerInfo.getGameProfile().getName() + ", "; + } else { + online = online + ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()) + "�" + "7, "; + } + } + if (hideMessage.isToggled()) { + Utils.log.info("[CHAT] " + (online + mc.thePlayer.getName())); + return; + } + Utils.sendRawMessage(online + mc.thePlayer.getDisplayName().getFormattedText()); + } else { + mc.thePlayer.sendChatMessage("/who"); + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java b/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java index e08b047..6e52174 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/BedWars.java @@ -1,281 +1,281 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.BlockBed; -import net.minecraft.block.BlockObsidian; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.monster.EntityIronGolem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemEnderPearl; -import net.minecraft.item.ItemFireball; -import net.minecraft.item.ItemMonsterPlacer; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.server.S23PacketBlockChange; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -public class BedWars extends Module { - public static ButtonSetting whitelistOwnBed; - private ButtonSetting diamondArmor; - private ButtonSetting fireball; - private ButtonSetting enderPearl; - private ButtonSetting obsidian; - private ButtonSetting shouldPing; - - private BlockPos spawnPos; - private boolean check; - private boolean waitForRespawn; - private long respawnMessageTime; - - public static boolean outsideSpawn = true; - - private List armoredPlayer = new ArrayList<>(); - private Map lastHeldMap = new ConcurrentHashMap<>(); - private Map obsidianPos = new HashMap<>(); // blockPos, time received - public List entitySpawnQueue = new ArrayList<>(); - public List spawnedMobs = new ArrayList<>(); // entity id - - private int obsidianColor = new Color(106, 13, 173).getRGB(); - - public BedWars() { - super("Bed Wars", category.minigames); - this.registerSetting(whitelistOwnBed = new ButtonSetting("Whitelist own bed", true)); - this.registerSetting(new DescriptionSetting("Game alerts")); - this.registerSetting(diamondArmor = new ButtonSetting("Diamond armor", true)); - this.registerSetting(fireball = new ButtonSetting("Fireball", false)); - this.registerSetting(obsidian = new ButtonSetting("Obsidian", true)); - this.registerSetting(enderPearl = new ButtonSetting("Ender pearl", true)); - this.registerSetting(shouldPing = new ButtonSetting("Should ping", true)); - this.closetModule = true; - } - - public void onEnable() { - check = false; - outsideSpawn = true; - } - - public void onDisable() { - outsideSpawn = true; - entitySpawnQueue.clear(); - spawnedMobs.clear(); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderWorld(RenderWorldLastEvent e) { - if (Utils.nullCheck() && obsidian.isToggled()) { - if (this.obsidianPos.isEmpty()) { - return; - } - try { - Iterator> iterator = this.obsidianPos.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - BlockPos blockPos = entry.getKey(); - Long receivedMs = entry.getValue(); - - if (!(mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockObsidian) && Utils.timeBetween(System.currentTimeMillis(), receivedMs) >= 500) { - iterator.remove(); - continue; - } - RenderUtils.renderBlock(blockPos, obsidianColor, false, true); - } - - } - catch (Exception exception) {} - } - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - armoredPlayer.clear(); - lastHeldMap.clear(); - obsidianPos.clear(); - entitySpawnQueue.clear(); - spawnedMobs.clear(); - waitForRespawn = false; - } - else { - if (e.entity != null && e.entity instanceof EntityIronGolem) { - if (Utils.getBedwarsStatus() != 2) { - return; - } - Vec3 spawnPosition = new Vec3(e.entity.posX, e.entity.posY, e.entity.posZ); - for (SkyWars.SpawnEggInfo eggInfo : entitySpawnQueue) { - if (eggInfo.spawnPos.distanceTo(spawnPosition) > 3 || Utils.timeBetween(mc.thePlayer.ticksExisted, eggInfo.tickSpawned) > 60) { // 3 seconds or not at spawn point then not own mob - return; - } - if (!entitySpawnQueue.remove(eggInfo)) { - return; - } - spawnedMobs.add(e.entity.getEntityId()); - } - } - } - } - - public void onUpdate() { - if (Utils.getBedwarsStatus() == 2) { - if (diamondArmor.isToggled() || enderPearl.isToggled() || obsidian.isToggled()) { - for (EntityPlayer p : mc.theWorld.playerEntities) { - if (p == null) { - continue; - } - if (p == mc.thePlayer) { - continue; - } - if (AntiBot.isBot(p)) { - continue; - } - String name = p.getName(); - ItemStack item = p.getHeldItem(); - if (diamondArmor.isToggled()) { - ItemStack leggings = p.inventory.armorInventory[1]; - if (!armoredPlayer.contains(name) && p.inventory != null && leggings != null && leggings.getItem() != null && leggings.getItem() == Items.diamond_leggings) { - armoredPlayer.add(name); - Utils.sendMessage("&eAlert: &r" + p.getDisplayName().getFormattedText() + " &7has purchased &bDiamond Armor"); - ping(); - } - } - if (item != null && !lastHeldMap.containsKey(name)) { - String itemType = getItemType(item); - if (itemType != null) { - lastHeldMap.put(name, itemType); - double distance = Math.round(mc.thePlayer.getDistanceToEntity(p)); - handleAlert(itemType, p.getDisplayName().getFormattedText(), Utils.asWholeNum(distance)); - } - } else if (lastHeldMap.containsKey(name)) { - String itemType = lastHeldMap.get(name); - if (!itemType.equals(getItemType(item))) { - lastHeldMap.remove(name); - } - } - } - } - if (whitelistOwnBed.isToggled()) { - if (check) { - spawnPos = mc.thePlayer.getPosition(); - check = false; - } - if (spawnPos == null) { - outsideSpawn = true; - } - else { - outsideSpawn = mc.thePlayer.getDistanceSq(spawnPos) > 800; - } - } - else { - outsideSpawn = true; - } - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { - C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); - if (p.getPlacedBlockDirection() != 255 && p.getStack() != null && p.getStack().getItem() != null) { - if (p.getStack().getItem() instanceof ItemMonsterPlacer) { - Class oclass = EntityList.stringToClassMapping.get(ItemMonsterPlacer.getEntityName(p.getStack())); - if (oclass == null) { - return; - } - if (oclass.getSimpleName().equals("EntityIronGolem")) { - entitySpawnQueue.add(new SkyWars.SpawnEggInfo(p.getPosition(), mc.thePlayer.ticksExisted)); - } - } - } - } - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S23PacketBlockChange) { - S23PacketBlockChange p = (S23PacketBlockChange) e.getPacket(); - if (p.getBlockState() != null && p.getBlockState().getBlock() instanceof BlockObsidian && isNextToBed(p.getBlockPosition())) { - this.obsidianPos.put(p.getBlockPosition(), System.currentTimeMillis()); - } - } - } - - private boolean isNextToBed(BlockPos blockPos) { - for (EnumFacing enumFacing : EnumFacing.values()) { - BlockPos offset = blockPos.offset(enumFacing); - if (BlockUtils.getBlock(offset) instanceof BlockBed) { - return true; - } - } - return false; - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent c) { - if (!Utils.nullCheck()) { - return; - } - String strippedMessage = Utils.stripColor(c.message.getUnformattedText()); - if (strippedMessage.startsWith(" ") && strippedMessage.contains("Protect your bed and destroy the enemy beds.")) { - check = true; - waitForRespawn = false; - } - else if (strippedMessage.equals("You will respawn because you still have a bed!")) { - waitForRespawn = true; - respawnMessageTime = System.currentTimeMillis(); - } - else if (strippedMessage.equals("You have respawned!") && waitForRespawn && Utils.timeBetween(System.currentTimeMillis(), respawnMessageTime) <= 12000) { - check = true; - waitForRespawn = false; - } - } - - private String getItemType(ItemStack item) { - if (item == null || item.getItem() == null) { - return null; - } - String unlocalizedName = item.getItem().getUnlocalizedName(); - if (item.getItem() instanceof ItemEnderPearl && enderPearl.isToggled()) { - return "&7an §3Ender Pearl"; - } - else if (unlocalizedName.contains("tile.obsidian") && obsidian.isToggled()) { - return "§dObsidian"; - } - else if (item.getItem() instanceof ItemFireball && fireball.isToggled()) { - return "&7a §6Fireball"; - } - return null; - } - - private void handleAlert(String itemType, String name, String info) { - String alert = "&eAlert: &r" + name + " &7is holding " + itemType + " &7(" + "§d" + info + "m" + "&7)"; - Utils.sendMessage(alert); - ping(); - } - - private void ping() { - if (shouldPing.isToggled()) { - mc.thePlayer.playSound("note.pling", 1.0f, 1.0f); - } - } +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.BlockBed; +import net.minecraft.block.BlockObsidian; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemEnderPearl; +import net.minecraft.item.ItemFireball; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +public class BedWars extends Module { + public static ButtonSetting whitelistOwnBed; + private ButtonSetting diamondArmor; + private ButtonSetting fireball; + private ButtonSetting enderPearl; + private ButtonSetting obsidian; + private ButtonSetting shouldPing; + + private BlockPos spawnPos; + private boolean check; + private boolean waitForRespawn; + private long respawnMessageTime; + + public static boolean outsideSpawn = true; + + private List armoredPlayer = new ArrayList<>(); + private Map lastHeldMap = new ConcurrentHashMap<>(); + private Map obsidianPos = new HashMap<>(); // blockPos, time received + public List entitySpawnQueue = new ArrayList<>(); + public List spawnedMobs = new ArrayList<>(); // entity id + + private int obsidianColor = new Color(106, 13, 173).getRGB(); + + public BedWars() { + super("Bed Wars", category.minigames); + this.registerSetting(whitelistOwnBed = new ButtonSetting("Whitelist own bed", true)); + this.registerSetting(new DescriptionSetting("Game alerts")); + this.registerSetting(diamondArmor = new ButtonSetting("Diamond armor", true)); + this.registerSetting(fireball = new ButtonSetting("Fireball", false)); + this.registerSetting(obsidian = new ButtonSetting("Obsidian", true)); + this.registerSetting(enderPearl = new ButtonSetting("Ender pearl", true)); + this.registerSetting(shouldPing = new ButtonSetting("Should ping", true)); + this.closetModule = true; + } + + public void onEnable() { + check = false; + outsideSpawn = true; + } + + public void onDisable() { + outsideSpawn = true; + entitySpawnQueue.clear(); + spawnedMobs.clear(); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderWorld(RenderWorldLastEvent e) { + if (Utils.nullCheck() && obsidian.isToggled()) { + if (this.obsidianPos.isEmpty()) { + return; + } + try { + Iterator> iterator = this.obsidianPos.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + BlockPos blockPos = entry.getKey(); + Long receivedMs = entry.getValue(); + + if (!(mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockObsidian) && Utils.timeBetween(System.currentTimeMillis(), receivedMs) >= 500) { + iterator.remove(); + continue; + } + RenderUtils.renderBlock(blockPos, obsidianColor, false, true); + } + + } + catch (Exception exception) {} + } + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + armoredPlayer.clear(); + lastHeldMap.clear(); + obsidianPos.clear(); + entitySpawnQueue.clear(); + spawnedMobs.clear(); + waitForRespawn = false; + } + else { + if (e.entity != null && e.entity instanceof EntityIronGolem) { + if (Utils.getBedwarsStatus() != 2) { + return; + } + Vec3 spawnPosition = new Vec3(e.entity.posX, e.entity.posY, e.entity.posZ); + for (SkyWars.SpawnEggInfo eggInfo : entitySpawnQueue) { + if (eggInfo.spawnPos.distanceTo(spawnPosition) > 3 || Utils.timeBetween(mc.thePlayer.ticksExisted, eggInfo.tickSpawned) > 60) { // 3 seconds or not at spawn point then not own mob + return; + } + if (!entitySpawnQueue.remove(eggInfo)) { + return; + } + spawnedMobs.add(e.entity.getEntityId()); + } + } + } + } + + public void onUpdate() { + if (Utils.getBedwarsStatus() == 2) { + if (diamondArmor.isToggled() || enderPearl.isToggled() || obsidian.isToggled()) { + for (EntityPlayer p : mc.theWorld.playerEntities) { + if (p == null) { + continue; + } + if (p == mc.thePlayer) { + continue; + } + if (AntiBot.isBot(p)) { + continue; + } + String name = p.getName(); + ItemStack item = p.getHeldItem(); + if (diamondArmor.isToggled()) { + ItemStack leggings = p.inventory.armorInventory[1]; + if (!armoredPlayer.contains(name) && p.inventory != null && leggings != null && leggings.getItem() != null && leggings.getItem() == Items.diamond_leggings) { + armoredPlayer.add(name); + Utils.sendMessage("&eAlert: &r" + p.getDisplayName().getFormattedText() + " &7has purchased &bDiamond Armor"); + ping(); + } + } + if (item != null && !lastHeldMap.containsKey(name)) { + String itemType = getItemType(item); + if (itemType != null) { + lastHeldMap.put(name, itemType); + double distance = Math.round(mc.thePlayer.getDistanceToEntity(p)); + handleAlert(itemType, p.getDisplayName().getFormattedText(), Utils.asWholeNum(distance)); + } + } else if (lastHeldMap.containsKey(name)) { + String itemType = lastHeldMap.get(name); + if (!itemType.equals(getItemType(item))) { + lastHeldMap.remove(name); + } + } + } + } + if (whitelistOwnBed.isToggled()) { + if (check) { + spawnPos = mc.thePlayer.getPosition(); + check = false; + } + if (spawnPos == null) { + outsideSpawn = true; + } + else { + outsideSpawn = mc.thePlayer.getDistanceSq(spawnPos) > 800; + } + } + else { + outsideSpawn = true; + } + } + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { + C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); + if (p.getPlacedBlockDirection() != 255 && p.getStack() != null && p.getStack().getItem() != null) { + if (p.getStack().getItem() instanceof ItemMonsterPlacer) { + Class oclass = EntityList.stringToClassMapping.get(ItemMonsterPlacer.getEntityName(p.getStack())); + if (oclass == null) { + return; + } + if (oclass.getSimpleName().equals("EntityIronGolem")) { + entitySpawnQueue.add(new SkyWars.SpawnEggInfo(p.getPosition(), mc.thePlayer.ticksExisted)); + } + } + } + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (e.getPacket() instanceof S23PacketBlockChange) { + S23PacketBlockChange p = (S23PacketBlockChange) e.getPacket(); + if (p.getBlockState() != null && p.getBlockState().getBlock() instanceof BlockObsidian && isNextToBed(p.getBlockPosition())) { + this.obsidianPos.put(p.getBlockPosition(), System.currentTimeMillis()); + } + } + } + + private boolean isNextToBed(BlockPos blockPos) { + for (EnumFacing enumFacing : EnumFacing.values()) { + BlockPos offset = blockPos.offset(enumFacing); + if (BlockUtils.getBlock(offset) instanceof BlockBed) { + return true; + } + } + return false; + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent c) { + if (!Utils.nullCheck()) { + return; + } + String strippedMessage = Utils.stripColor(c.message.getUnformattedText()); + if (strippedMessage.startsWith(" ") && strippedMessage.contains("Protect your bed and destroy the enemy beds.")) { + check = true; + waitForRespawn = false; + } + else if (strippedMessage.equals("You will respawn because you still have a bed!")) { + waitForRespawn = true; + respawnMessageTime = System.currentTimeMillis(); + } + else if (strippedMessage.equals("You have respawned!") && waitForRespawn && Utils.timeBetween(System.currentTimeMillis(), respawnMessageTime) <= 12000) { + check = true; + waitForRespawn = false; + } + } + + private String getItemType(ItemStack item) { + if (item == null || item.getItem() == null) { + return null; + } + String unlocalizedName = item.getItem().getUnlocalizedName(); + if (item.getItem() instanceof ItemEnderPearl && enderPearl.isToggled()) { + return "&7an §3Ender Pearl"; + } + else if (unlocalizedName.contains("tile.obsidian") && obsidian.isToggled()) { + return "§dObsidian"; + } + else if (item.getItem() instanceof ItemFireball && fireball.isToggled()) { + return "&7a §6Fireball"; + } + return null; + } + + private void handleAlert(String itemType, String name, String info) { + String alert = "&eAlert: &r" + name + " &7is holding " + itemType + " &7(" + "§d" + info + "m" + "&7)"; + Utils.sendMessage(alert); + ping(); + } + + private void ping() { + if (shouldPing.isToggled()) { + Utils.ping(); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java b/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java index 2a8b231..c5e58c4 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/CTWFly.java @@ -1,252 +1,252 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.Raven; -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.CommandManager; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.client.C09PacketHeldItemChange; -import net.minecraft.network.play.server.*; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.awt.*; -import java.util.Objects; - -public class CTWFly extends Module { - public static SliderSetting horizontalSpeed; - private SliderSetting verticalSpeed; - private SliderSetting maxFlyTicks; - private boolean d; - private boolean a = false; - - private boolean begin, placed; - private int flyTicks, ticks321; - - private int percent, percentDisplay; - - private static int widthOffset = 55; - private static String get321 = "Waiting for explosion..."; - - private int color = new Color(0, 187, 255, 255).getRGB(); - - public CTWFly() { - super("CTW Fly", category.minigames); - this.registerSetting(new DescriptionSetting("Use TNT to fly")); - this.registerSetting(new DescriptionSetting("(High speed values will dog)")); - this.registerSetting(horizontalSpeed = new SliderSetting("Horizontal speed", 4.0, 1.0, 9.0, 0.1)); - this.registerSetting(verticalSpeed = new SliderSetting("Vertical speed", 2.0, 1.0, 9.0, 0.1)); - this.registerSetting(maxFlyTicks = new SliderSetting("Max fly ticks", 40, 1, 80, 1)); - - } - - public void onDisable() { - if (begin || placed) { - disabled(); - } - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - Packet packet = e.getPacket(); - - if (packet instanceof S29PacketSoundEffect) { - S29PacketSoundEffect s29 = (S29PacketSoundEffect) packet; - if (!Objects.equals(String.valueOf(s29.getSoundName()), "random.explode")) { - return; - } - if (mc.thePlayer.getPosition().distanceSq(s29.getX(), s29.getY(), s29.getZ()) <= 30) { - begin = true; - placed = false; - flyTicks = 0; - } - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && Utils.holdingTNT()) { - placed = true; - } - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent e) { - if (!Utils.nullCheck()) { - return; - } - String stripped = Utils.stripColor(e.message.getUnformattedText()); - - if (stripped.contains("You cannot place blocks here!") && placed) { - disabled(); - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix - public void onMoveInput(PrePlayerInputEvent e) { - if (!placed) { - return; - } - e.setForward(0); - e.setStrafe(0); - Utils.setSpeed(0); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (placed) { - if (ticks321 >= 45) { - ticks321 = 0; - } - ++ticks321; - } - if (!begin) { - return; - } - this.d = mc.thePlayer.capabilities.isFlying; - if (++flyTicks >= maxFlyTicks.getInput() + 1) { - disabled(); - } - - double percentCalc = 1000 / maxFlyTicks.getInput(); - if (percent < 1000) percent = percent + (int) percentCalc; - percentDisplay = percent / 10; - if (flyTicks >= maxFlyTicks.getInput()) percentDisplay = 100; - - - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck() || !begin && !placed) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - } - color = Theme.getGradient((int) HUD.theme.getInput(), 0); - if (!placed) { - widthOffset = percentDisplay < 10 ? 8 : percentDisplay < 100 ? 12 : 14; - } else { - switch (ticks321) { - case 15: - get321 = "Waiting for explosion."; - widthOffset = 51; - break; - case 30: - get321 = "Waiting for explosion.."; - widthOffset = 53; - break; - case 45: - get321 = "Waiting for explosion..."; - widthOffset = 55; - break; - } - } - String text = placed ? get321 : (percentDisplay + "%"); - int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; - mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); - } - - public void onUpdate() { - if (!begin) { - return; - } - if (mc.currentScreen == null) { - if (Utils.jumpDown()) { - mc.thePlayer.motionY = 0.3 * verticalSpeed.getInput(); - } - else if (Utils.sneakDown()) { - mc.thePlayer.motionY = -0.3 * verticalSpeed.getInput(); - } - else { - mc.thePlayer.motionY = 0.0; - } - } - else { - mc.thePlayer.motionY = 0.0; - } - mc.thePlayer.capabilities.setFlySpeed(0.2f); - mc.thePlayer.capabilities.isFlying = true; - setSpeed(0.85 * horizontalSpeed.getInput()); - } - - - - public static void setSpeed(final double n) { - if (n == 0.0) { - mc.thePlayer.motionZ = 0; - mc.thePlayer.motionX = 0; - return; - } - double n3 = mc.thePlayer.movementInput.moveForward; - double n4 = mc.thePlayer.movementInput.moveStrafe; - float rotationYaw = mc.thePlayer.rotationYaw; - if (n3 == 0.0 && n4 == 0.0) { - mc.thePlayer.motionZ = 0; - mc.thePlayer.motionX = 0; - } - else { - if (n3 != 0.0) { - if (n4 > 0.0) { - rotationYaw += ((n3 > 0.0) ? -45 : 45); - } - else if (n4 < 0.0) { - rotationYaw += ((n3 > 0.0) ? 45 : -45); - } - n4 = 0.0; - if (n3 > 0.0) { - n3 = 1.0; - } - else if (n3 < 0.0) { - n3 = -1.0; - } - } - final double radians = Math.toRadians(rotationYaw + 90.0f); - final double sin = Math.sin(radians); - final double cos = Math.cos(radians); - mc.thePlayer.motionX = n3 * n * cos + n4 * n * sin; - mc.thePlayer.motionZ = n3 * n * sin - n4 * n * cos; - } - } - - private void disabled() { - begin = placed = false; - if (mc.thePlayer.capabilities.allowFlying) { - mc.thePlayer.capabilities.isFlying = this.d; - } - else { - mc.thePlayer.capabilities.isFlying = false; - } - this.d = false; - if (flyTicks > 0) { - mc.thePlayer.motionX = 0; - mc.thePlayer.motionY = 0; - mc.thePlayer.motionZ = 0; - } - flyTicks = percent = ticks321 = 0; - - get321 = "Waiting for explosion..."; - widthOffset = 55; - } -} +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.CommandManager; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.server.*; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.awt.*; +import java.util.Objects; + +public class CTWFly extends Module { + public static SliderSetting horizontalSpeed; + private SliderSetting verticalSpeed; + private SliderSetting maxFlyTicks; + private boolean d; + private boolean a = false; + + private boolean begin, placed; + private int flyTicks, ticks321; + + private int percent, percentDisplay; + + private static int widthOffset = 55; + private static String get321 = "Waiting for explosion..."; + + private int color = new Color(0, 187, 255, 255).getRGB(); + + public CTWFly() { + super("CTW Fly", category.minigames); + this.registerSetting(new DescriptionSetting("Use TNT to fly")); + this.registerSetting(new DescriptionSetting("(High speed values will dog)")); + this.registerSetting(horizontalSpeed = new SliderSetting("Horizontal speed", 4.0, 1.0, 9.0, 0.1)); + this.registerSetting(verticalSpeed = new SliderSetting("Vertical speed", 2.0, 1.0, 9.0, 0.1)); + this.registerSetting(maxFlyTicks = new SliderSetting("Max fly ticks", 40, 1, 80, 1)); + + } + + public void onDisable() { + if (begin || placed) { + disabled(); + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + Packet packet = e.getPacket(); + + if (packet instanceof S29PacketSoundEffect) { + S29PacketSoundEffect s29 = (S29PacketSoundEffect) packet; + if (!Objects.equals(String.valueOf(s29.getSoundName()), "random.explode")) { + return; + } + if (mc.thePlayer.getPosition().distanceSq(s29.getX(), s29.getY(), s29.getZ()) <= 30) { + begin = true; + placed = false; + flyTicks = 0; + } + } + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && Utils.holdingTNT()) { + placed = true; + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (!Utils.nullCheck()) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + + if (stripped.contains("You cannot place blocks here!") && placed) { + disabled(); + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix + public void onMoveInput(PrePlayerInputEvent e) { + if (!placed) { + return; + } + e.setForward(0); + e.setStrafe(0); + Utils.setSpeed(0); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (placed) { + if (ticks321 >= 45) { + ticks321 = 0; + } + ++ticks321; + } + if (!begin) { + return; + } + this.d = mc.thePlayer.capabilities.isFlying; + if (++flyTicks >= maxFlyTicks.getInput() + 1) { + disabled(); + } + + double percentCalc = 1000 / maxFlyTicks.getInput(); + if (percent < 1000) percent = percent + (int) percentCalc; + percentDisplay = percent / 10; + if (flyTicks >= maxFlyTicks.getInput()) percentDisplay = 100; + + + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck() || !begin && !placed) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + } + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + if (!placed) { + widthOffset = percentDisplay < 10 ? 8 : percentDisplay < 100 ? 12 : 14; + } else { + switch (ticks321) { + case 15: + get321 = "Waiting for explosion."; + widthOffset = 51; + break; + case 30: + get321 = "Waiting for explosion.."; + widthOffset = 53; + break; + case 45: + get321 = "Waiting for explosion..."; + widthOffset = 55; + break; + } + } + String text = placed ? get321 : (percentDisplay + "%"); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + } + + public void onUpdate() { + if (!begin) { + return; + } + if (mc.currentScreen == null) { + if (Utils.jumpDown()) { + mc.thePlayer.motionY = 0.3 * verticalSpeed.getInput(); + } + else if (Utils.sneakDown()) { + mc.thePlayer.motionY = -0.3 * verticalSpeed.getInput(); + } + else { + mc.thePlayer.motionY = 0.0; + } + } + else { + mc.thePlayer.motionY = 0.0; + } + mc.thePlayer.capabilities.setFlySpeed(0.2f); + mc.thePlayer.capabilities.isFlying = true; + setSpeed(0.85 * horizontalSpeed.getInput()); + } + + + + public static void setSpeed(final double n) { + if (n == 0.0) { + mc.thePlayer.motionZ = 0; + mc.thePlayer.motionX = 0; + return; + } + double n3 = mc.thePlayer.movementInput.moveForward; + double n4 = mc.thePlayer.movementInput.moveStrafe; + float rotationYaw = mc.thePlayer.rotationYaw; + if (n3 == 0.0 && n4 == 0.0) { + mc.thePlayer.motionZ = 0; + mc.thePlayer.motionX = 0; + } + else { + if (n3 != 0.0) { + if (n4 > 0.0) { + rotationYaw += ((n3 > 0.0) ? -45 : 45); + } + else if (n4 < 0.0) { + rotationYaw += ((n3 > 0.0) ? 45 : -45); + } + n4 = 0.0; + if (n3 > 0.0) { + n3 = 1.0; + } + else if (n3 < 0.0) { + n3 = -1.0; + } + } + final double radians = Math.toRadians(rotationYaw + 90.0f); + final double sin = Math.sin(radians); + final double cos = Math.cos(radians); + mc.thePlayer.motionX = n3 * n * cos + n4 * n * sin; + mc.thePlayer.motionZ = n3 * n * sin - n4 * n * cos; + } + } + + private void disabled() { + begin = placed = false; + if (mc.thePlayer.capabilities.allowFlying) { + mc.thePlayer.capabilities.isFlying = this.d; + } + else { + mc.thePlayer.capabilities.isFlying = false; + } + this.d = false; + if (flyTicks > 0) { + mc.thePlayer.motionX = 0; + mc.thePlayer.motionY = 0; + mc.thePlayer.motionZ = 0; + } + flyTicks = percent = ticks321 = 0; + + get321 = "Waiting for explosion..."; + widthOffset = 55; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java b/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java index 8e5d058..ed5dade 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/SkyWars.java @@ -1,249 +1,249 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.event.UseItemEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemEnderPearl; -import net.minecraft.item.ItemMonsterPlacer; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class SkyWars extends Module { - public ButtonSetting strengthIndicator; - public ButtonSetting onlyAuraHostileMobs; - public ButtonSetting renderTimeWarp; - - public Map strengthPlayers = new HashMap<>(); - private Map entitySpawnQueue = new LinkedHashMap<>(); // type name, spawn info - private Map timeWarpPositions = new LinkedHashMap<>(); // position when thrown, time when thrown - public List spawnedMobs = new ArrayList<>(); // entity id - - private final int strengthColor = new Color(255, 0, 0).getRGB(); - private final int timeWarpColor = new Color(210, 0, 255, 64).getRGB(); - - private String[] killMessages = new String[] {" by ", " to ", " with ", " of ", " from ", " knight ", " for "}; - private boolean thrownPearl; - public static boolean isSkyWarsTeams = false; - - public SkyWars() { - super("Sky Wars", category.minigames); - this.registerSetting(onlyAuraHostileMobs = new ButtonSetting("Only aura hostile mobs", true)); - this.registerSetting(renderTimeWarp = new ButtonSetting("Render time warp", true)); - this.registerSetting(strengthIndicator = new ButtonSetting("Strength indicator", true)); - } - - @Override - public void onDisable() { - clear(); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!strengthIndicator.isToggled() || !Utils.nullCheck() || strengthPlayers.isEmpty() || Utils.getSkyWarsStatus() != 2) { - return; - } - int customMode = getCustomMode(); - if (customMode == 2) { - return; - } - isSkyWarsTeams = customMode == 1; - long duration = isSkyWarsTeams ? 2000 : 5000; - ArrayList keysList = new ArrayList<>(strengthPlayers.keySet()); - for (EntityPlayer entityPlayer : keysList) { - long storedTime = strengthPlayers.get(entityPlayer); - long timePassed = System.currentTimeMillis() - storedTime; - if (timePassed < duration && !AntiBot.isBot(entityPlayer)) { - continue; - } - strengthPlayers.remove(entityPlayer); - } - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent e) { - if (e.type == 2 || !Utils.nullCheck()) { - return; - } - String stripped = Utils.stripColor(e.message.getUnformattedText()); - if (stripped.isEmpty()) { - return; - } - if (stripped.equals("You will be warped back in 3 seconds!") && thrownPearl) { - timeWarpPositions.put(new Vec3(mc.thePlayer.lastTickPosX, mc.thePlayer.lastTickPosY, mc.thePlayer.lastTickPosZ), System.currentTimeMillis()); - thrownPearl = false; - return; - } - if (strengthIndicator.isToggled() && Utils.getSkyWarsStatus() == 2) { - if (getCustomMode() == 2) { // lab, then no - return; - } - if (stripped.endsWith(".") && Arrays.stream(killMessages).anyMatch(stripped::contains)) { - String[] parts = stripped.split(" "); - for (String part : parts) { - if (!part.endsWith(".")) { - continue; - } - String name = part.substring(0, part.length() - 1); - for (EntityPlayer entity : mc.theWorld.playerEntities) { - if (!entity.getName().trim().equals(name) || entity == mc.thePlayer) { - continue; - } - strengthPlayers.put(entity, System.currentTimeMillis()); - break; - } - } - } - } - } - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent e) { - if (!Utils.nullCheck() || Utils.getSkyWarsStatus() != 2) { - return; - } - if (strengthIndicator.isToggled()) { - for (EntityPlayer entityPlayer : strengthPlayers.keySet()) { - if (AntiBot.isBot(entityPlayer)) { - continue; - } - RenderUtils.renderEntity(entityPlayer, 2, 0, 0, strengthColor, false); - } - } - if (renderTimeWarp.isToggled()) { - Iterator> iterator = this.timeWarpPositions.entrySet().iterator(); - long currentTime = System.currentTimeMillis(); - - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - Vec3 position = entry.getKey(); - long timeThrown = entry.getValue(); - - if (currentTime - timeThrown >= 3050) { - iterator.remove(); - } - else { - RenderUtils.drawPlayerBoundingBox(position, timeWarpColor); - } - } - } - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - clear(); - } - else { - if (e.entity != null) { - if (Utils.getSkyWarsStatus() != 2) { - return; - } - String entityClassName = e.entity.getClass().getSimpleName(); - if (entitySpawnQueue.containsKey(entityClassName)) { - Vec3 spawnPosition = new Vec3(e.entity.posX, e.entity.posY, e.entity.posZ); - SpawnEggInfo eggInfo = entitySpawnQueue.get(entityClassName); - if (eggInfo.spawnPos.distanceTo(spawnPosition) > 3 || Utils.timeBetween(mc.thePlayer.ticksExisted, eggInfo.tickSpawned) > 60) { // 3 seconds or not at spawn point then not own mob - return; - } - if (!entitySpawnQueue.remove(entityClassName, eggInfo)) { - return; - } - spawnedMobs.add(e.entity.getEntityId()); - } - } - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { - C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); - if (p.getPlacedBlockDirection() != 255 && p.getStack() != null && p.getStack().getItem() != null) { - if (!(p.getStack().getItem() instanceof ItemMonsterPlacer)) { - return; - } - Class oclass = EntityList.stringToClassMapping.get(ItemMonsterPlacer.getEntityName(p.getStack())); - if (oclass == null) { - return; - } - entitySpawnQueue.put(oclass.getSimpleName(), new SpawnEggInfo(p.getPosition(), mc.thePlayer.ticksExisted)); - } - } - } - - @SubscribeEvent - public void onUseItem(UseItemEvent e) { - if (e.usedItemStack != null && e.usedItemStack.getItem() instanceof ItemEnderPearl && Utils.getSkyWarsStatus() == 2) { - ItemStack stack = e.usedItemStack; - if (Utils.stripString(stack.getDisplayName()).equals("Time Warp Pearl")) { - thrownPearl = true; - } - else { - if (stack.getDisplayName().startsWith("§b§l")) { - List toolTip = stack.getTooltip(mc.thePlayer, true); - if (toolTip != null && toolTip.size() > 1 && Utils.stripString(toolTip.get(1)).contains("Teleports you back to your")) { - thrownPearl = true; - } - } - } - } - } - - private void clear() { - strengthPlayers.clear(); - spawnedMobs.clear(); - entitySpawnQueue.clear(); - timeWarpPositions.clear(); - thrownPearl = false; - } - - public static boolean onlyAuraHostiles() { - return ModuleManager.skyWars != null && ModuleManager.skyWars.isEnabled() && ModuleManager.skyWars.onlyAuraHostileMobs.isToggled() && Utils.getSkyWarsStatus() == 2; - } - - public int getCustomMode() { - List sidebar = Utils.getSidebarLines(); - if (sidebar == null || sidebar.isEmpty()) { - return -1; - } - for (String line : sidebar) { - line = Utils.stripColor(line); - if (line.startsWith("Teams left: ")) { - return 1; - } - else if (line.startsWith("Lab: ")) { - return 2; - } - } - return -1; - } - - public static class SpawnEggInfo { - public Vec3 spawnPos; - public int tickSpawned; - - public SpawnEggInfo(BlockPos spawnPos, int tickSpawned) { - this.spawnPos = new Vec3(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()); - this.tickSpawned = tickSpawned; - } - } +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.event.UseItemEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemEnderPearl; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class SkyWars extends Module { + public ButtonSetting strengthIndicator; + public ButtonSetting onlyAuraHostileMobs; + public ButtonSetting renderTimeWarp; + + public Map strengthPlayers = new HashMap<>(); + private Map entitySpawnQueue = new LinkedHashMap<>(); // type name, spawn info + private Map timeWarpPositions = new LinkedHashMap<>(); // position when thrown, time when thrown + public List spawnedMobs = new ArrayList<>(); // entity id + + private final int strengthColor = new Color(255, 0, 0).getRGB(); + private final int timeWarpColor = new Color(210, 0, 255, 64).getRGB(); + + private String[] killMessages = new String[] {" by ", " to ", " with ", " of ", " from ", " knight ", " for "}; + private boolean thrownPearl; + public static boolean isSkyWarsTeams = false; + + public SkyWars() { + super("Sky Wars", category.minigames); + this.registerSetting(onlyAuraHostileMobs = new ButtonSetting("Only aura hostile mobs", true)); + this.registerSetting(renderTimeWarp = new ButtonSetting("Render time warp", true)); + this.registerSetting(strengthIndicator = new ButtonSetting("Strength indicator", true)); + } + + @Override + public void onDisable() { + clear(); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!strengthIndicator.isToggled() || !Utils.nullCheck() || strengthPlayers.isEmpty() || Utils.getSkyWarsStatus() != 2) { + return; + } + int customMode = getCustomMode(); + if (customMode == 2) { + return; + } + isSkyWarsTeams = customMode == 1; + long duration = isSkyWarsTeams ? 2000 : 5000; + ArrayList keysList = new ArrayList<>(strengthPlayers.keySet()); + for (EntityPlayer entityPlayer : keysList) { + long storedTime = strengthPlayers.get(entityPlayer); + long timePassed = System.currentTimeMillis() - storedTime; + if (timePassed < duration && !AntiBot.isBot(entityPlayer)) { + continue; + } + strengthPlayers.remove(entityPlayer); + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (e.type == 2 || !Utils.nullCheck()) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + if (stripped.isEmpty()) { + return; + } + if (stripped.equals("You will be warped back in 3 seconds!") && thrownPearl) { + timeWarpPositions.put(new Vec3(mc.thePlayer.lastTickPosX, mc.thePlayer.lastTickPosY, mc.thePlayer.lastTickPosZ), System.currentTimeMillis()); + thrownPearl = false; + return; + } + if (strengthIndicator.isToggled() && Utils.getSkyWarsStatus() == 2) { + if (getCustomMode() == 2) { // lab, then no + return; + } + if (stripped.endsWith(".") && Arrays.stream(killMessages).anyMatch(stripped::contains)) { + String[] parts = stripped.split(" "); + for (String part : parts) { + if (!part.endsWith(".")) { + continue; + } + String name = part.substring(0, part.length() - 1); + for (EntityPlayer entity : mc.theWorld.playerEntities) { + if (!entity.getName().trim().equals(name) || entity == mc.thePlayer) { + continue; + } + strengthPlayers.put(entity, System.currentTimeMillis()); + break; + } + } + } + } + } + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent e) { + if (!Utils.nullCheck() || Utils.getSkyWarsStatus() != 2) { + return; + } + if (strengthIndicator.isToggled()) { + for (EntityPlayer entityPlayer : strengthPlayers.keySet()) { + if (AntiBot.isBot(entityPlayer)) { + continue; + } + RenderUtils.renderEntity(entityPlayer, 2, 0, 0, strengthColor, false); + } + } + if (renderTimeWarp.isToggled()) { + Iterator> iterator = this.timeWarpPositions.entrySet().iterator(); + long currentTime = System.currentTimeMillis(); + + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + Vec3 position = entry.getKey(); + long timeThrown = entry.getValue(); + + if (currentTime - timeThrown >= 3050) { + iterator.remove(); + } + else { + RenderUtils.drawPlayerBoundingBox(position, timeWarpColor); + } + } + } + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + clear(); + } + else { + if (e.entity != null) { + if (Utils.getSkyWarsStatus() != 2) { + return; + } + String entityClassName = e.entity.getClass().getSimpleName(); + if (entitySpawnQueue.containsKey(entityClassName)) { + Vec3 spawnPosition = new Vec3(e.entity.posX, e.entity.posY, e.entity.posZ); + SpawnEggInfo eggInfo = entitySpawnQueue.get(entityClassName); + if (eggInfo.spawnPos.distanceTo(spawnPosition) > 3 || Utils.timeBetween(mc.thePlayer.ticksExisted, eggInfo.tickSpawned) > 60) { // 3 seconds or not at spawn point then not own mob + return; + } + if (!entitySpawnQueue.remove(entityClassName, eggInfo)) { + return; + } + spawnedMobs.add(e.entity.getEntityId()); + } + } + } + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { + C08PacketPlayerBlockPlacement p = (C08PacketPlayerBlockPlacement) e.getPacket(); + if (p.getPlacedBlockDirection() != 255 && p.getStack() != null && p.getStack().getItem() != null) { + if (!(p.getStack().getItem() instanceof ItemMonsterPlacer)) { + return; + } + Class oclass = EntityList.stringToClassMapping.get(ItemMonsterPlacer.getEntityName(p.getStack())); + if (oclass == null) { + return; + } + entitySpawnQueue.put(oclass.getSimpleName(), new SpawnEggInfo(p.getPosition(), mc.thePlayer.ticksExisted)); + } + } + } + + @SubscribeEvent + public void onUseItem(UseItemEvent e) { + if (e.usedItemStack != null && e.usedItemStack.getItem() instanceof ItemEnderPearl && Utils.getSkyWarsStatus() == 2) { + ItemStack stack = e.usedItemStack; + if (Utils.stripString(stack.getDisplayName()).equals("Time Warp Pearl")) { + thrownPearl = true; + } + else { + if (stack.getDisplayName().startsWith("§b§l")) { + List toolTip = stack.getTooltip(mc.thePlayer, true); + if (toolTip != null && toolTip.size() > 1 && Utils.stripString(toolTip.get(1)).contains("Teleports you back to your")) { + thrownPearl = true; + } + } + } + } + } + + private void clear() { + strengthPlayers.clear(); + spawnedMobs.clear(); + entitySpawnQueue.clear(); + timeWarpPositions.clear(); + thrownPearl = false; + } + + public static boolean onlyAuraHostiles() { + return ModuleManager.skyWars != null && ModuleManager.skyWars.isEnabled() && ModuleManager.skyWars.onlyAuraHostileMobs.isToggled() && Utils.getSkyWarsStatus() == 2; + } + + public int getCustomMode() { + List sidebar = Utils.getSidebarLines(); + if (sidebar == null || sidebar.isEmpty()) { + return -1; + } + for (String line : sidebar) { + line = Utils.stripColor(line); + if (line.startsWith("Teams left: ")) { + return 1; + } + else if (line.startsWith("Lab: ")) { + return 2; + } + } + return -1; + } + + public static class SpawnEggInfo { + public Vec3 spawnPos; + public int tickSpawned; + + public SpawnEggInfo(BlockPos spawnPos, int tickSpawned) { + this.spawnPos = new Vec3(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()); + this.tickSpawned = tickSpawned; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/minigames/SpeedBuilders.java b/src/main/java/keystrokesmod/module/impl/minigames/SpeedBuilders.java index 09971f8..2abac01 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/SpeedBuilders.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/SpeedBuilders.java @@ -1,531 +1,531 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.*; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraft.util.*; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -public class SpeedBuilders extends Module { - - private SliderSetting placeDelay; - private ButtonSetting antiMiss; - private ButtonSetting autoPlace; - private ButtonSetting autoSwap; - private ButtonSetting hoverPlace; - private ButtonSetting infoHud; - private ButtonSetting renderBlocks; - private ButtonSetting renderOnlyPlaceable; - - private ConcurrentHashMap buildInfo = new ConcurrentHashMap<>(); - - private BlockPos platformCenter; - private boolean listenForPacket; - public List platformPositions = Arrays.asList( - new BlockPos(45, 71, -18), - new BlockPos(-16, 71, 45), - new BlockPos(18, 71, 45), - new BlockPos(45, 71, 16), - new BlockPos(-18, 71, -45), - new BlockPos(-45, 71, -16), - new BlockPos(-45, 71, 18), - new BlockPos(16, 71, -45) - ); - - private int highlightColor = new Color(31, 255, 22, 44).getRGB(); - private int notPlaceableColor = new Color(184, 255, 183, 30).getRGB(); - - private boolean doneCollecting; - private double blockCount; - private int lastPlaceTick = 0; - private boolean eliminated; - - public SpeedBuilders() { - super("Speed Builders", category.minigames); - this.registerSetting(new DescriptionSetting("Middle click to toggle auto.")); - this.registerSetting(placeDelay = new SliderSetting("Place delay", " tick", 0.5, 0, 10, 0.5)); - this.registerSetting(antiMiss = new ButtonSetting("Anti miss", false)); - this.registerSetting(autoPlace = new ButtonSetting("Auto place", false)); - this.registerSetting(autoSwap = new ButtonSetting("Auto swap", true)); - this.registerSetting(hoverPlace = new ButtonSetting("Hover place", true)); - this.registerSetting(infoHud = new ButtonSetting("Info HUD", true)); - this.registerSetting(renderBlocks = new ButtonSetting("Render blocks", true)); - this.registerSetting(renderOnlyPlaceable = new ButtonSetting("Render only placeable", false)); - } - - @Override - public void onDisable() { - lastPlaceTick = 0; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - int gameStatus = getGameStatus(); - if (gameStatus == -1 || platformCenter == null) { - return; - } - if (gameStatus == 4) { - doneCollecting = true; - } - if (gameStatus == 1 && !doneCollecting) { - buildInfo = getBuildInfo(platformCenter); - if (!buildInfo.isEmpty()) { - blockCount = buildInfo.size(); - } - } - if (gameStatus == 2) { - doneCollecting = false; - for (Map.Entry entry : buildInfo.entrySet()) { - IBlockState currentState = mc.theWorld.getBlockState(entry.getKey()); - IBlockState requiredState = entry.getValue().requiredState; - - if (currentState == null || requiredState == null) { - entry.getValue().isPlaced = false; - continue; - } - - if (currentState.equals(requiredState) ||(requiredState.getBlock() instanceof BlockLeaves && (currentState.getBlock().equals(requiredState.getBlock())))) { - entry.getValue().isPlaced = true; - } - else { - entry.getValue().isPlaced = false; - } - } - - if (getLookInfo() != null) { - MovingObjectPosition mop = getLookInfo(); - if (mop.sideHit != null) { - BlockPos targetPos = mop.getBlockPos(); - BlockPos facePos = targetPos.offset(mop.sideHit); - - BuildBlockInfo info = buildInfo.get(facePos); - if (info != null && !info.isPlaced) { - if (autoSwap.isToggled()) { - int requiredMeta = info.requiredState.getBlock().getMetaFromState(info.requiredState); - int slot = getSlot(info.requiredState.getBlock(), requiredMeta); - if (slot != -1 && slot != mc.thePlayer.inventory.currentItem) { - mc.thePlayer.inventory.currentItem = slot; - } - } - if ((hoverPlace.isToggled()) && holdingSameBlock(info.requiredState) && correctPlaceState(info.requiredState, targetPos, mop.sideHit, mop.hitVec, mc.thePlayer.getHeldItem())) { - if (lastPlaceTick++ < placeDelay.getInput()) { - return; - } - ((IAccessorMinecraft) mc).callRightClickMouse(); - lastPlaceTick = 0; - } - } - } - } - } - } - - @SubscribeEvent - public void onMouse(MouseEvent e) { - if (!e.buttonstate || !Utils.nullCheck() || mc.currentScreen != null) { - return; - } - if (e.button == 1 && antiMiss.isToggled() && getLookInfo() != null && getGameStatus() == 2) { - MovingObjectPosition mop = getLookInfo(); - if (mop.sideHit != null) { - BlockPos targetPos = mop.getBlockPos(); - BlockPos facePos = targetPos.offset(mop.sideHit); - - BuildBlockInfo info = buildInfo.get(facePos); - if (info == null || !holdingSameBlock(info.requiredState) || !correctPlaceState(info.requiredState, targetPos, mop.sideHit, mop.hitVec, mc.thePlayer.getHeldItem())) { - e.setCanceled(true); - } - } - } - else if (e.button == 2) { - if (autoSwap.isToggled()) { - autoSwap.disable(); - hoverPlace.disable(); - } - else { - autoSwap.enable(); - hoverPlace.enable(); - } - } - } - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent ev) { - if (!Utils.nullCheck() || getGameStatus() != 2 || !renderBlocks.isToggled()) { - return; - } - - for (Map.Entry buildData : buildInfo.entrySet()) { - BuildBlockInfo info = buildData.getValue(); - if (info.isPlaced) { - continue; - } - if (!holdingSameBlock(info.requiredState)) { - continue; - } - BlockPos pos = buildData.getKey(); - boolean useWhite = true; - for (EnumFacing dir : EnumFacing.values()) { - BlockPos neighborPos = pos.offset(dir); - if (BlockUtils.getBlock(neighborPos) != Blocks.air) { - useWhite = false; - } - } - if (renderOnlyPlaceable.isToggled() && useWhite) { - continue; - } - RenderUtils.renderBlockModel(buildData.getValue().requiredState, pos.getX(), pos.getY(), pos.getZ(), useWhite ? notPlaceableColor : highlightColor); - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent e) { - if (e.phase != TickEvent.Phase.END || !Utils.nullCheck() || mc.currentScreen != null) { - return; - } - int gameStatus = getGameStatus(); - if (infoHud.isToggled()) { - List lines = new ArrayList<>(); - lines.add("§6Speed Builders"); - lines.add("§7Status: §b" + ((gameStatus == 1 || gameStatus == 4) - ? "Showing" : (gameStatus == 2) - ? "Building" : (gameStatus == 3) - ? "Judging" : "§cDisabled")); - if (gameStatus == 2 && !eliminated) { - double placedCount = 0; - for (BuildBlockInfo info : buildInfo.values()) { - if (info.isPlaced) placedCount++; - } - double percentage = 0.0; - if (buildInfo.isEmpty()) { - percentage = 100.0; - placedCount = blockCount; - } else if (blockCount > 0) { - percentage = ((placedCount) / blockCount) * 100.0; - } - lines.add("§7Progress: §b" + (int) placedCount + "§7/§b" + (int) blockCount + " " + Math.round(percentage) + "%"); - } - lines.add("§7Auto: " + (autoEnabled() ? "§aENABLED" : "§cDISABLED")); - - int padding = 4; - int maxWidth = 0; - for (String line : lines) { - int lineWidth = mc.fontRendererObj.getStringWidth(line); - if (lineWidth > maxWidth) { - maxWidth = lineWidth; - } - } - - int lineHeight = mc.fontRendererObj.FONT_HEIGHT; - int lineSpacing = 3; - int totalHeight = lines.size() * lineHeight + (lines.size() - 1) * lineSpacing + padding * 2; - int totalWidth = maxWidth + padding * 2; - - float x = -5; - float y = 110; - - RenderUtils.drawRoundedRectangle(x, y, x + totalWidth + 7, y + totalHeight - 2, 7, Utils.mergeAlpha(Color.black.getRGB(), 120)); - - float textX = x + padding; - float textY = y + padding; - - for (int i = 0; i < lines.size(); i++) { - mc.fontRendererObj.drawString(lines.get(i), (int) (textX + 5), (int) (textY + i * (lineHeight + lineSpacing)), -1); - } - } - } - - @SubscribeEvent - public void onEntityJoin(EntityJoinWorldEvent e) { - if (!Utils.nullCheck() || e.entity == null) { - return; - } - if (e.entity == mc.thePlayer) { - buildInfo.clear(); - platformCenter = null; - listenForPacket = false; - doneCollecting = false; - eliminated = false; - } - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent e) { - if (e.type == 2 || !Utils.nullCheck() || getGameStatus() == -1 || listenForPacket) { - return; - } - String stripped = Utils.stripColor(e.message.getUnformattedText()); - if (stripped.isEmpty()) { - return; - } - if (stripped.contains("Perfectly recreate the build you are shown each") || stripped.contains("The game starts in 1 second!")) { - listenForPacket = true; - } - if (stripped.startsWith(Utils.getServerName()) && stripped.contains(" got a perfect build in ") && stripped.endsWith("s!")) { - buildInfo.clear(); - doneCollecting = false; - } - if (stripped.startsWith("Player eliminated: " + Utils.getServerName()) && stripped.endsWith("%)")) { - eliminated = true; - } - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (listenForPacket && Utils.nullCheck() && e.getPacket() instanceof S08PacketPlayerPosLook) { - Vec3 setPos = new Vec3(((S08PacketPlayerPosLook) e.getPacket()).getX(), ((S08PacketPlayerPosLook) e.getPacket()).getY(), ((S08PacketPlayerPosLook) e.getPacket()).getZ()); - if (platformCenter == null) { - platformCenter = findCenter(setPos); - } - listenForPacket = false; - } - } - - public int getGameStatus() { - List sidebar = Utils.getSidebarLines(); - if (sidebar == null || sidebar.isEmpty()) { - return -1; - } - if (!Utils.stripColor(sidebar.get(0)).startsWith("BUILD BATTLE")) { - return -1; - } - for (int i = 0; i < sidebar.size() - 1; i++) { - String currentLine = Utils.stripColor(sidebar.get(i)); - String nextLine = Utils.stripColor(sidebar.get(i + 1)); - - if (currentLine.startsWith("Round:")) { - if (nextLine.startsWith("Starts In: 00:03") && Utils.stripColor(sidebar.get(i + 3)).startsWith("Theme:")) { - return 4; - } - if (nextLine.startsWith("Starts In:")) { - return 1; - } - if (nextLine.startsWith("Time Left:")) { - return 2; - } - if (nextLine.startsWith("Judging:")) { - return 3; - } - } - } - return 0; - } - - public BlockPos findCenter(Vec3 position) { - BlockPos closestPos = null; - double closestDistSq = Double.MAX_VALUE; - double maxDistance = 30.0; - double maxDistSq = maxDistance * maxDistance; - - for (BlockPos pos : platformPositions) { - double dx = pos.getX() - position.xCoord; - double dy = pos.getY() - position.yCoord; - double dz = pos.getZ() - position.zCoord; - double distSq = Math.abs(dx * dx + dy * dy + dz * dz); - - if (distSq <= maxDistSq && distSq < closestDistSq) { - closestDistSq = distSq; - closestPos = pos; - } - } - return closestPos; - } - - public ConcurrentHashMap getBuildInfo(BlockPos centerPos) { - ConcurrentHashMap blockInfo = new ConcurrentHashMap<>(); - int startX = centerPos.getX() - 3; - int endX = centerPos.getX() + 3; - int startZ = centerPos.getZ() - 3; - int endZ = centerPos.getZ() + 3; - - int startY = centerPos.getY() + 1; - int endY = startY + 30; - - for (int x = startX; x <= endX; x++) { - for (int z = startZ; z <= endZ; z++) { - for (int y = startY; y <= endY; y++) { - BlockPos currentPos = new BlockPos(x, y, z); - IBlockState state = mc.theWorld.getBlockState(currentPos); - if (state.getBlock() == Blocks.air) { - continue; - } - blockInfo.put(currentPos, new BuildBlockInfo(state)); - } - } - } - - return blockInfo; - } - - public boolean autoEnabled() { - return autoSwap.isToggled() && hoverPlace.isToggled(); - } - - public boolean holdingSameBlock(IBlockState requiredState) { - if (mc.thePlayer == null || requiredState == null) { - return false; - } - - ItemStack heldItem = mc.thePlayer.getHeldItem(); - if (heldItem == null) { - return false; - } - - Item item = heldItem.getItem(); - Block requiredBlock = requiredState.getBlock(); - - if ((requiredBlock == Blocks.water || requiredBlock == Blocks.flowing_water) && item == Items.water_bucket) { - return true; - } - - if (!(item instanceof ItemBlock)) { - return false; - } - - Block heldBlock = ((ItemBlock) item).getBlock(); - int heldMeta = heldItem.getItemDamage(); - int requiredMeta = requiredBlock.getMetaFromState(requiredState); - - if (requiredBlock == Blocks.leaves || requiredBlock == Blocks.leaves2) { - requiredMeta = requiredMeta & 3; - heldMeta = heldMeta & 3; - } - - if (removeMeta(heldBlock)) { - heldMeta = 0; - requiredMeta = 0; - } - - return heldBlock == requiredBlock && heldMeta == requiredMeta; - } - - - public MovingObjectPosition getLookInfo() { - MovingObjectPosition movingObjectPosition = mc.objectMouseOver; - if (movingObjectPosition == null || movingObjectPosition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || movingObjectPosition.getBlockPos() == null) { - return null; - } - return mc.objectMouseOver; - } - - private int getSlot(Block block, int meta) { - if (removeMeta(block)) { - meta = 0; - } - if (block == Blocks.leaves || block == Blocks.leaves2) { - meta &= 3; - } - - for (int i = 0; i < 9; ++i) { - ItemStack itemStack = mc.thePlayer.inventory.mainInventory[i]; - if (itemStack != null && itemStack.getItem() instanceof ItemBlock && itemStack.stackSize > 0) { - Block invBlock = ((ItemBlock) itemStack.getItem()).getBlock(); - int invMeta = itemStack.getItemDamage(); - - if (removeMeta(block)) { - invMeta = 0; - } - - if (invBlock == Blocks.leaves || invBlock == Blocks.leaves2) { - invMeta &= 3; - } - - if (invBlock == block && invMeta == meta) { - return i; - } - } - } - return -1; - } - - private boolean removeMeta(Block block) { - return (block instanceof BlockStairs || block instanceof BlockDoublePlant || block instanceof BlockFlower || block instanceof BlockSkull || block instanceof BlockLadder || block instanceof BlockPumpkin || block instanceof BlockCauldron || block instanceof BlockRail || block instanceof BlockRailBase || block instanceof BlockTripWireHook || block instanceof BlockTripWire || block instanceof BlockDispenser || block instanceof BlockDropper || block instanceof BlockHopper || block instanceof BlockTorch || block instanceof BlockButton || block instanceof BlockLever || block instanceof BlockTrapDoor || block instanceof BlockSlab); - } - - private boolean correctPlaceState(IBlockState requiredState, BlockPos blockPos, EnumFacing enumFacing, Vec3 hitVec, ItemStack heldItem) { - if (requiredState == null || blockPos == null || enumFacing == null || hitVec == null || heldItem == null || !(heldItem.getItem() instanceof ItemBlock)) { - return false; - } - - if (requiredState.getBlock() instanceof BlockLeaves || requiredState.getBlock() instanceof BlockButton) { - return true; - } - - ItemBlock itemBlock = (ItemBlock) heldItem.getItem(); - Block block = itemBlock.getBlock(); - int meta = heldItem.getItemDamage(); - - Vec3 relativeHitVec = hitVec.subtract(new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ())); - - IBlockState simulatedState = block.onBlockPlaced(mc.theWorld, blockPos, enumFacing, - (float) relativeHitVec.xCoord, (float) relativeHitVec.yCoord, (float) relativeHitVec.zCoord, meta, mc.thePlayer); - - if (simulatedState == null) { - return false; - } - - if (simulatedState.getBlock() != requiredState.getBlock()) { - return false; - } - - int simulatedMeta = simulatedState.getBlock().getMetaFromState(simulatedState); - int requiredMeta = requiredState.getBlock().getMetaFromState(requiredState); - if (simulatedMeta != requiredMeta) { - return false; - } - if (simulatedState.getProperties().containsKey(BlockDirectional.FACING) && requiredState.getProperties().containsKey(BlockDirectional.FACING)) { - EnumFacing simulatedFacing = simulatedState.getValue(BlockDirectional.FACING); - EnumFacing requiredFacing = requiredState.getValue(BlockDirectional.FACING); - if (simulatedFacing != requiredFacing) { - return false; - } - } - if (simulatedState.getBlock() instanceof BlockStairs && requiredState.getBlock() instanceof BlockStairs) { - EnumFacing simulatedFacing = simulatedState.getValue(BlockStairs.FACING); - EnumFacing requiredFacing = requiredState.getValue(BlockStairs.FACING); - BlockStairs.EnumHalf simulatedHalf = simulatedState.getValue(BlockStairs.HALF); - BlockStairs.EnumHalf requiredHalf = requiredState.getValue(BlockStairs.HALF); - - if (simulatedFacing != requiredFacing || simulatedHalf != requiredHalf) { - return false; - } - } - - return true; - } - - class BuildBlockInfo { - public IBlockState requiredState; - public boolean isPlaced; - - public BuildBlockInfo(IBlockState state) { - this.requiredState = state; - this.isPlaced = false; - } - } +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.*; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.util.*; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +public class SpeedBuilders extends Module { + + private SliderSetting placeDelay; + private ButtonSetting antiMiss; + private ButtonSetting autoPlace; + private ButtonSetting autoSwap; + private ButtonSetting hoverPlace; + private ButtonSetting infoHud; + private ButtonSetting renderBlocks; + private ButtonSetting renderOnlyPlaceable; + + private ConcurrentHashMap buildInfo = new ConcurrentHashMap<>(); + + private BlockPos platformCenter; + private boolean listenForPacket; + public List platformPositions = Arrays.asList( + new BlockPos(45, 71, -18), + new BlockPos(-16, 71, 45), + new BlockPos(18, 71, 45), + new BlockPos(45, 71, 16), + new BlockPos(-18, 71, -45), + new BlockPos(-45, 71, -16), + new BlockPos(-45, 71, 18), + new BlockPos(16, 71, -45) + ); + + private int highlightColor = new Color(31, 255, 22, 44).getRGB(); + private int notPlaceableColor = new Color(184, 255, 183, 30).getRGB(); + + private boolean doneCollecting; + private double blockCount; + private int lastPlaceTick = 0; + private boolean eliminated; + + public SpeedBuilders() { + super("Speed Builders", category.minigames); + this.registerSetting(new DescriptionSetting("Middle click to toggle auto.")); + this.registerSetting(placeDelay = new SliderSetting("Place delay", " tick", 0.5, 0, 10, 0.5)); + this.registerSetting(antiMiss = new ButtonSetting("Anti miss", false)); + this.registerSetting(autoPlace = new ButtonSetting("Auto place", false)); + this.registerSetting(autoSwap = new ButtonSetting("Auto swap", true)); + this.registerSetting(hoverPlace = new ButtonSetting("Hover place", true)); + this.registerSetting(infoHud = new ButtonSetting("Info HUD", true)); + this.registerSetting(renderBlocks = new ButtonSetting("Render blocks", true)); + this.registerSetting(renderOnlyPlaceable = new ButtonSetting("Render only placeable", false)); + } + + @Override + public void onDisable() { + lastPlaceTick = 0; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + int gameStatus = getGameStatus(); + if (gameStatus == -1 || platformCenter == null) { + return; + } + if (gameStatus == 4) { + doneCollecting = true; + } + if (gameStatus == 1 && !doneCollecting) { + buildInfo = getBuildInfo(platformCenter); + if (!buildInfo.isEmpty()) { + blockCount = buildInfo.size(); + } + } + if (gameStatus == 2) { + doneCollecting = false; + for (Map.Entry entry : buildInfo.entrySet()) { + IBlockState currentState = mc.theWorld.getBlockState(entry.getKey()); + IBlockState requiredState = entry.getValue().requiredState; + + if (currentState == null || requiredState == null) { + entry.getValue().isPlaced = false; + continue; + } + + if (currentState.equals(requiredState) ||(requiredState.getBlock() instanceof BlockLeaves && (currentState.getBlock().equals(requiredState.getBlock())))) { + entry.getValue().isPlaced = true; + } + else { + entry.getValue().isPlaced = false; + } + } + + if (getLookInfo() != null) { + MovingObjectPosition mop = getLookInfo(); + if (mop.sideHit != null) { + BlockPos targetPos = mop.getBlockPos(); + BlockPos facePos = targetPos.offset(mop.sideHit); + + BuildBlockInfo info = buildInfo.get(facePos); + if (info != null && !info.isPlaced) { + if (autoSwap.isToggled()) { + int requiredMeta = info.requiredState.getBlock().getMetaFromState(info.requiredState); + int slot = getSlot(info.requiredState.getBlock(), requiredMeta); + if (slot != -1 && slot != mc.thePlayer.inventory.currentItem) { + mc.thePlayer.inventory.currentItem = slot; + } + } + if ((hoverPlace.isToggled()) && holdingSameBlock(info.requiredState) && correctPlaceState(info.requiredState, targetPos, mop.sideHit, mop.hitVec, mc.thePlayer.getHeldItem())) { + if (lastPlaceTick++ < placeDelay.getInput()) { + return; + } + ((IAccessorMinecraft) mc).callRightClickMouse(); + lastPlaceTick = 0; + } + } + } + } + } + } + + @SubscribeEvent + public void onMouse(MouseEvent e) { + if (!e.buttonstate || !Utils.nullCheck() || mc.currentScreen != null) { + return; + } + if (e.button == 1 && antiMiss.isToggled() && getLookInfo() != null && getGameStatus() == 2) { + MovingObjectPosition mop = getLookInfo(); + if (mop.sideHit != null) { + BlockPos targetPos = mop.getBlockPos(); + BlockPos facePos = targetPos.offset(mop.sideHit); + + BuildBlockInfo info = buildInfo.get(facePos); + if (info == null || !holdingSameBlock(info.requiredState) || !correctPlaceState(info.requiredState, targetPos, mop.sideHit, mop.hitVec, mc.thePlayer.getHeldItem())) { + e.setCanceled(true); + } + } + } + else if (e.button == 2) { + if (autoSwap.isToggled()) { + autoSwap.disable(); + hoverPlace.disable(); + } + else { + autoSwap.enable(); + hoverPlace.enable(); + } + } + } + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent ev) { + if (!Utils.nullCheck() || getGameStatus() != 2 || !renderBlocks.isToggled()) { + return; + } + + for (Map.Entry buildData : buildInfo.entrySet()) { + BuildBlockInfo info = buildData.getValue(); + if (info.isPlaced) { + continue; + } + if (!holdingSameBlock(info.requiredState)) { + continue; + } + BlockPos pos = buildData.getKey(); + boolean useWhite = true; + for (EnumFacing dir : EnumFacing.values()) { + BlockPos neighborPos = pos.offset(dir); + if (BlockUtils.getBlock(neighborPos) != Blocks.air) { + useWhite = false; + } + } + if (renderOnlyPlaceable.isToggled() && useWhite) { + continue; + } + RenderUtils.renderBlockModel(buildData.getValue().requiredState, pos.getX(), pos.getY(), pos.getZ(), useWhite ? notPlaceableColor : highlightColor); + } + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent e) { + if (e.phase != TickEvent.Phase.END || !Utils.nullCheck() || mc.currentScreen != null) { + return; + } + int gameStatus = getGameStatus(); + if (infoHud.isToggled()) { + List lines = new ArrayList<>(); + lines.add("§6Speed Builders"); + lines.add("§7Status: §b" + ((gameStatus == 1 || gameStatus == 4) + ? "Showing" : (gameStatus == 2) + ? "Building" : (gameStatus == 3) + ? "Judging" : "§cDisabled")); + if (gameStatus == 2 && !eliminated) { + double placedCount = 0; + for (BuildBlockInfo info : buildInfo.values()) { + if (info.isPlaced) placedCount++; + } + double percentage = 0.0; + if (buildInfo.isEmpty()) { + percentage = 100.0; + placedCount = blockCount; + } else if (blockCount > 0) { + percentage = ((placedCount) / blockCount) * 100.0; + } + lines.add("§7Progress: §b" + (int) placedCount + "§7/§b" + (int) blockCount + " " + Math.round(percentage) + "%"); + } + lines.add("§7Auto: " + (autoEnabled() ? "§aENABLED" : "§cDISABLED")); + + int padding = 4; + int maxWidth = 0; + for (String line : lines) { + int lineWidth = mc.fontRendererObj.getStringWidth(line); + if (lineWidth > maxWidth) { + maxWidth = lineWidth; + } + } + + int lineHeight = mc.fontRendererObj.FONT_HEIGHT; + int lineSpacing = 3; + int totalHeight = lines.size() * lineHeight + (lines.size() - 1) * lineSpacing + padding * 2; + int totalWidth = maxWidth + padding * 2; + + float x = -5; + float y = 110; + + RenderUtils.drawRoundedRectangle(x, y, x + totalWidth + 7, y + totalHeight - 2, 7, Utils.mergeAlpha(Color.black.getRGB(), 120)); + + float textX = x + padding; + float textY = y + padding; + + for (int i = 0; i < lines.size(); i++) { + mc.fontRendererObj.drawString(lines.get(i), (int) (textX + 5), (int) (textY + i * (lineHeight + lineSpacing)), -1); + } + } + } + + @SubscribeEvent + public void onEntityJoin(EntityJoinWorldEvent e) { + if (!Utils.nullCheck() || e.entity == null) { + return; + } + if (e.entity == mc.thePlayer) { + buildInfo.clear(); + platformCenter = null; + listenForPacket = false; + doneCollecting = false; + eliminated = false; + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (e.type == 2 || !Utils.nullCheck() || getGameStatus() == -1 || listenForPacket) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + if (stripped.isEmpty()) { + return; + } + if (stripped.contains("Perfectly recreate the build you are shown each") || stripped.contains("The game starts in 1 second!")) { + listenForPacket = true; + } + if (stripped.startsWith(Utils.getServerName()) && stripped.contains(" got a perfect build in ") && stripped.endsWith("s!")) { + buildInfo.clear(); + doneCollecting = false; + } + if (stripped.startsWith("Player eliminated: " + Utils.getServerName()) && stripped.endsWith("%)")) { + eliminated = true; + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (listenForPacket && Utils.nullCheck() && e.getPacket() instanceof S08PacketPlayerPosLook) { + Vec3 setPos = new Vec3(((S08PacketPlayerPosLook) e.getPacket()).getX(), ((S08PacketPlayerPosLook) e.getPacket()).getY(), ((S08PacketPlayerPosLook) e.getPacket()).getZ()); + if (platformCenter == null) { + platformCenter = findCenter(setPos); + } + listenForPacket = false; + } + } + + public int getGameStatus() { + List sidebar = Utils.getSidebarLines(); + if (sidebar == null || sidebar.isEmpty()) { + return -1; + } + if (!Utils.stripColor(sidebar.get(0)).startsWith("BUILD BATTLE")) { + return -1; + } + for (int i = 0; i < sidebar.size() - 1; i++) { + String currentLine = Utils.stripColor(sidebar.get(i)); + String nextLine = Utils.stripColor(sidebar.get(i + 1)); + + if (currentLine.startsWith("Round:")) { + if (nextLine.startsWith("Starts In: 00:03") && Utils.stripColor(sidebar.get(i + 3)).startsWith("Theme:")) { + return 4; + } + if (nextLine.startsWith("Starts In:")) { + return 1; + } + if (nextLine.startsWith("Time Left:")) { + return 2; + } + if (nextLine.startsWith("Judging:")) { + return 3; + } + } + } + return 0; + } + + public BlockPos findCenter(Vec3 position) { + BlockPos closestPos = null; + double closestDistSq = Double.MAX_VALUE; + double maxDistance = 30.0; + double maxDistSq = maxDistance * maxDistance; + + for (BlockPos pos : platformPositions) { + double dx = pos.getX() - position.xCoord; + double dy = pos.getY() - position.yCoord; + double dz = pos.getZ() - position.zCoord; + double distSq = Math.abs(dx * dx + dy * dy + dz * dz); + + if (distSq <= maxDistSq && distSq < closestDistSq) { + closestDistSq = distSq; + closestPos = pos; + } + } + return closestPos; + } + + public ConcurrentHashMap getBuildInfo(BlockPos centerPos) { + ConcurrentHashMap blockInfo = new ConcurrentHashMap<>(); + int startX = centerPos.getX() - 3; + int endX = centerPos.getX() + 3; + int startZ = centerPos.getZ() - 3; + int endZ = centerPos.getZ() + 3; + + int startY = centerPos.getY() + 1; + int endY = startY + 30; + + for (int x = startX; x <= endX; x++) { + for (int z = startZ; z <= endZ; z++) { + for (int y = startY; y <= endY; y++) { + BlockPos currentPos = new BlockPos(x, y, z); + IBlockState state = mc.theWorld.getBlockState(currentPos); + if (state.getBlock() == Blocks.air) { + continue; + } + blockInfo.put(currentPos, new BuildBlockInfo(state)); + } + } + } + + return blockInfo; + } + + public boolean autoEnabled() { + return autoSwap.isToggled() && hoverPlace.isToggled(); + } + + public boolean holdingSameBlock(IBlockState requiredState) { + if (mc.thePlayer == null || requiredState == null) { + return false; + } + + ItemStack heldItem = mc.thePlayer.getHeldItem(); + if (heldItem == null) { + return false; + } + + Item item = heldItem.getItem(); + Block requiredBlock = requiredState.getBlock(); + + if ((requiredBlock == Blocks.water || requiredBlock == Blocks.flowing_water) && item == Items.water_bucket) { + return true; + } + + if (!(item instanceof ItemBlock)) { + return false; + } + + Block heldBlock = ((ItemBlock) item).getBlock(); + int heldMeta = heldItem.getItemDamage(); + int requiredMeta = requiredBlock.getMetaFromState(requiredState); + + if (requiredBlock == Blocks.leaves || requiredBlock == Blocks.leaves2) { + requiredMeta = requiredMeta & 3; + heldMeta = heldMeta & 3; + } + + if (removeMeta(heldBlock)) { + heldMeta = 0; + requiredMeta = 0; + } + + return heldBlock == requiredBlock && heldMeta == requiredMeta; + } + + + public MovingObjectPosition getLookInfo() { + MovingObjectPosition movingObjectPosition = mc.objectMouseOver; + if (movingObjectPosition == null || movingObjectPosition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || movingObjectPosition.getBlockPos() == null) { + return null; + } + return mc.objectMouseOver; + } + + private int getSlot(Block block, int meta) { + if (removeMeta(block)) { + meta = 0; + } + if (block == Blocks.leaves || block == Blocks.leaves2) { + meta &= 3; + } + + for (int i = 0; i < 9; ++i) { + ItemStack itemStack = mc.thePlayer.inventory.mainInventory[i]; + if (itemStack != null && itemStack.getItem() instanceof ItemBlock && itemStack.stackSize > 0) { + Block invBlock = ((ItemBlock) itemStack.getItem()).getBlock(); + int invMeta = itemStack.getItemDamage(); + + if (removeMeta(block)) { + invMeta = 0; + } + + if (invBlock == Blocks.leaves || invBlock == Blocks.leaves2) { + invMeta &= 3; + } + + if (invBlock == block && invMeta == meta) { + return i; + } + } + } + return -1; + } + + private boolean removeMeta(Block block) { + return (block instanceof BlockStairs || block instanceof BlockDoublePlant || block instanceof BlockFlower || block instanceof BlockSkull || block instanceof BlockLadder || block instanceof BlockPumpkin || block instanceof BlockCauldron || block instanceof BlockRail || block instanceof BlockRailBase || block instanceof BlockTripWireHook || block instanceof BlockTripWire || block instanceof BlockDispenser || block instanceof BlockDropper || block instanceof BlockHopper || block instanceof BlockTorch || block instanceof BlockButton || block instanceof BlockLever || block instanceof BlockTrapDoor || block instanceof BlockSlab); + } + + private boolean correctPlaceState(IBlockState requiredState, BlockPos blockPos, EnumFacing enumFacing, Vec3 hitVec, ItemStack heldItem) { + if (requiredState == null || blockPos == null || enumFacing == null || hitVec == null || heldItem == null || !(heldItem.getItem() instanceof ItemBlock)) { + return false; + } + + if (requiredState.getBlock() instanceof BlockLeaves || requiredState.getBlock() instanceof BlockButton) { + return true; + } + + ItemBlock itemBlock = (ItemBlock) heldItem.getItem(); + Block block = itemBlock.getBlock(); + int meta = heldItem.getItemDamage(); + + Vec3 relativeHitVec = hitVec.subtract(new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ())); + + IBlockState simulatedState = block.onBlockPlaced(mc.theWorld, blockPos, enumFacing, + (float) relativeHitVec.xCoord, (float) relativeHitVec.yCoord, (float) relativeHitVec.zCoord, meta, mc.thePlayer); + + if (simulatedState == null) { + return false; + } + + if (simulatedState.getBlock() != requiredState.getBlock()) { + return false; + } + + int simulatedMeta = simulatedState.getBlock().getMetaFromState(simulatedState); + int requiredMeta = requiredState.getBlock().getMetaFromState(requiredState); + if (simulatedMeta != requiredMeta) { + return false; + } + if (simulatedState.getProperties().containsKey(BlockDirectional.FACING) && requiredState.getProperties().containsKey(BlockDirectional.FACING)) { + EnumFacing simulatedFacing = simulatedState.getValue(BlockDirectional.FACING); + EnumFacing requiredFacing = requiredState.getValue(BlockDirectional.FACING); + if (simulatedFacing != requiredFacing) { + return false; + } + } + if (simulatedState.getBlock() instanceof BlockStairs && requiredState.getBlock() instanceof BlockStairs) { + EnumFacing simulatedFacing = simulatedState.getValue(BlockStairs.FACING); + EnumFacing requiredFacing = requiredState.getValue(BlockStairs.FACING); + BlockStairs.EnumHalf simulatedHalf = simulatedState.getValue(BlockStairs.HALF); + BlockStairs.EnumHalf requiredHalf = requiredState.getValue(BlockStairs.HALF); + + if (simulatedFacing != requiredFacing || simulatedHalf != requiredHalf) { + return false; + } + } + + return true; + } + + class BuildBlockInfo { + public IBlockState requiredState; + public boolean isPlaced; + + public BuildBlockInfo(IBlockState state) { + this.requiredState = state; + this.isPlaced = false; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/minigames/WoolWars.java b/src/main/java/keystrokesmod/module/impl/minigames/WoolWars.java index b1cce3b..1118b12 100644 --- a/src/main/java/keystrokesmod/module/impl/minigames/WoolWars.java +++ b/src/main/java/keystrokesmod/module/impl/minigames/WoolWars.java @@ -1,424 +1,424 @@ -package keystrokesmod.module.impl.minigames; - -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockStairs; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Mouse; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -public class WoolWars extends Module { - public SliderSetting breakSpeed; - public SliderSetting range; - public SliderSetting breakDelay; - public SliderSetting placeDelay; - public ButtonSetting onlyMiddleClick; - public ButtonSetting onlyVisible; - - private final int middlePositionColors = new Color(255, 153, 204).getRGB(); - private final int miningColor = new Color(200, 100, 255).getRGB(); - private final int placeColor = new Color(150, 70, 255).getRGB(); - - private BlockPos middlePos; - private BlockPos miningPos; - private MovingObjectPosition placeMop; - - private float curBlockDamageMP; - private int delay; - private int swapBack = -1; - private double lastRange; - private double rangeSq; - private float placingYaw; - private float placingPitch; - private boolean fakeSwing; - - public WoolWars() { - super("WoolWars", category.minigames, 0); - - this.registerSetting(new DescriptionSetting("Nukes and places at control point.")); - this.registerSetting(breakSpeed = new SliderSetting("Break speed", 0.2, 0.0, 0.8, 0.05)); - this.registerSetting(breakDelay = new SliderSetting("Delay after breaking", 3.0, 1.0, 10.0, 1.0)); - this.registerSetting(placeDelay = new SliderSetting("Delay after placing", 1.0, 1.0, 10.0, 1.0)); - this.registerSetting(range = new SliderSetting("Range", 5.0, 1.0, 8.0, 0.5)); - this.registerSetting(onlyVisible = new ButtonSetting("Only visible", true)); - this.registerSetting(onlyMiddleClick = new ButtonSetting("Only while middle clicking", true)); - } - - @Override - public void guiUpdate() { - if (lastRange != range.getInput()) { - lastRange = range.getInput(); - rangeSq = Math.pow(lastRange + 2.0, 2.0); - } - } - - @Override - public void onDisable() { - swapBack(); - reset(); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent event) { - if (!isWoolWars()) { - reset(); - return; - } - if (middlePos == null) { - middlePos = getMiddlePos(); - } - else if (!mc.thePlayer.capabilities.allowFlying && mc.thePlayer.getDistanceSq(middlePos) < rangeSq && isActiveRound() && (!onlyMiddleClick.isToggled() || Mouse.isButtonDown(2))) { - if (swapBack == -1) { - swapBack = mc.thePlayer.inventory.currentItem; - } - if (delay > 0 && --delay > 0) { - if (fakeSwing) { - mc.thePlayer.swingItem(); - } - return; - } - if (placeMop != null) { - return; - } - if (miningPos == null) { - List posList = getPossiblePos(middlePos, true); - if (!posList.isEmpty()) { - BlockPos closestPos = getClosestPos(posList, true); - if (closestPos != null) { - int blockSlot = getBlockSlot(); - if (blockSlot == -1) { - return; - } - Utils.switchSlot(blockSlot, true); - search: - for (int i = 0; i < 360; i += 10) { - float yaw = (float) (mc.thePlayer.rotationYaw + i + randomRotationOffset()); - int j = 20; - while (j < 90) { - float pitch = RotationUtils.clampPitch((float) (j + randomRotationOffset())); - MovingObjectPosition mop = Utils.getTarget(lastRange, yaw, pitch); - if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && BlockUtils.isBlockPosEqual(BlockUtils.offsetPos(mop), closestPos)) { - placeMop = mop; - placingYaw = yaw; - placingPitch = pitch; - break search; - } - else { - j += 5; - } - } - } - return; - } - } - posList = getPossiblePos(middlePos, false); - if (posList.isEmpty()) { - middlePos = null; - swapBack(); - return; - } - BlockPos closestPos = getClosestPos(posList, false); - if (closestPos == null) { - return; - } - miningPos = closestPos; - switchToSlot(Utils.getTool(BlockUtils.getBlock(closestPos))); - miningPos = closestPos; - mc.thePlayer.swingItem(); - startBreak(miningPos); - } - else if (!Utils.isPossibleToReach(miningPos, lastRange)) { - abortBreak(miningPos); - miningPos = null; - curBlockDamageMP = (delay = 0); - return; - } - curBlockDamageMP += BlockUtils.getBlockHardness(BlockUtils.getBlock(miningPos), mc.thePlayer.getHeldItem(), false, false); - if (curBlockDamageMP < breakSpeed.getInput()) { - curBlockDamageMP = (float) breakSpeed.getInput(); - } - if (curBlockDamageMP >= 1.0f) { - stopBreak(miningPos); - mc.playerController.onPlayerDestroyBlock(miningPos, EnumFacing.UP); - miningPos = null; - curBlockDamageMP = 0.0f; - delay = (int) breakDelay.getInput(); - fakeSwing = true; - } - mc.theWorld.sendBlockBreakProgress(mc.thePlayer.getEntityId(), miningPos, (int) (curBlockDamageMP * 10.0f) - 1); - mc.thePlayer.swingItem(); - } - else if (miningPos != null) { - abortBreak(miningPos); - miningPos = null; - curBlockDamageMP = (delay = 0); - swapBack(); - } - else if (swapBack != -1) { - swapBack(); - } - } - - public double randomRotationOffset() { - return Math.random() - 0.5; - } - - public boolean switchToSlot(int slot) { - if (slot == -1) { - return false; - } - mc.thePlayer.inventory.currentItem = slot; - return true; - } - - private BlockPos getMiddlePos() { - BlockPos middlePos = null; - int y; - int startY; - for (startY = (y = (int) Math.floor(mc.thePlayer.posY + 20.0)); y > -1; --y) { - BlockPos pos = BlockUtils.pos(0.0, y, 0.0); - if (BlockUtils.getBlock(pos.add(0, 0, 2)) instanceof BlockStairs || isControlPointBlock(pos, false)) { - middlePos = pos; - break; - } - } - if (middlePos == null) { - for (y = startY; y > -1; --y) { - BlockPos pos = BlockUtils.pos(0.0, y, 6.0); - if (BlockUtils.getBlock(pos.add(0, 0, 2)) instanceof BlockStairs || isControlPointBlock(pos, false)) { - middlePos = pos; - break; - } - } - } - return middlePos; - } - - private List getPossiblePos(BlockPos middlePos, boolean airOnly) { - List posList = new ArrayList<>(); - for (int zOffset = -1; zOffset <= 1; ++zOffset) { - for (int xOffset = -1; xOffset <= 1; ++xOffset) { - BlockPos pos = new BlockPos(middlePos.getX() + xOffset, middlePos.getY(), middlePos.getZ() + zOffset); - if (airOnly) { - if (!(BlockUtils.getBlock(pos) instanceof BlockAir)) { - continue; - } - } else if (!isControlPointBlock(pos, true)) { - continue; - } - posList.add(pos); - } - } - return posList; - } - - private BlockPos getClosestPos(List posList, boolean down) { - BlockPos closestPos = null; - double leastDistSq = rangeSq + 1.0; - for (BlockPos pos : posList) { - if (!Utils.isPossibleToReach(down ? pos.down() : pos, lastRange)) { - continue; - } - if (onlyVisible.isToggled() && !BlockUtils.canBlockBeSeen(pos)) { - continue; - } - double distSq = mc.thePlayer.getDistanceSq(pos); - if (distSq >= leastDistSq) { - continue; - } - leastDistSq = distSq; - closestPos = pos; - } - return closestPos; - } - - private boolean isControlPointBlock(BlockPos pos, boolean verifyWoolColor) { - Block block = BlockUtils.getBlock(pos); - if (block != Blocks.wool) { - return block == Blocks.snow || block == Blocks.quartz_block; - } - if (!verifyWoolColor) { - return true; - } - EnumDyeColor teamColor = null; - for (int i = 0; i < InventoryPlayer.getHotbarSize(); ++i) { - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() == Blocks.wool) { - teamColor = EnumDyeColor.byMetadata(stack.getMetadata()); - break; - } - } - return BlockUtils.getWoolColor(BlockUtils.getBlockState(pos)) != teamColor; - } - - private boolean isActiveRound() { - for (String line : Utils.getSidebarLines()) { - String strip = Utils.stripString(line); - if (strip.contains("State: Active Round")) { - return true; - } - } - return false; - } - - public int getBlockSlot() { - for (int slot = 0; slot < InventoryPlayer.getHotbarSize(); ++slot) { - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slot); - if (stack != null) { - if (stack.getItem() instanceof ItemBlock) { - Block block = ((ItemBlock) stack.getItem()).getBlock(); - if (BlockUtils.isNormalBlock(block)) { - return slot; - } - } - } - } - return -1; - } - - @SubscribeEvent - public void onPreMotion(PreMotionEvent e) { - if (placeMop != null) { - if (placingPitch > 90.0f) { - if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem(), placeMop.getBlockPos(), placeMop.sideHit, placeMop.hitVec)) { - mc.thePlayer.swingItem(); - mc.getItemRenderer().resetEquippedProgress(); - delay = (int) placeDelay.getInput(); - fakeSwing = false; - } - placeMop = null; - } - else { - placingPitch += 300.0f; - } - e.setYaw(placingYaw); - e.setPitch(placingPitch - 300.0f); - return; - } - if (miningPos != null) { - float[] rotations = RotationUtils.getRotationsToBlock(miningPos, EnumFacing.UP, e.getYaw(), e.getPitch()); - if (rotations != null) { - e.setRotations(rotations[0], rotations[1]); - } - } - if (delay > 0 && (!onlyMiddleClick.isToggled() || Mouse.isButtonDown(2))) { - List posList = getPossiblePos(middlePos, true); - BlockPos closestPos = null; - if (!posList.isEmpty()) { - closestPos = getClosestPos(posList, true); - } - if (closestPos == null) { - posList = getPossiblePos(middlePos, false); - closestPos = getClosestPos(posList, false); - } - if (closestPos != null) { - float[] rotations = RotationUtils.getRotationsToBlock(closestPos, EnumFacing.UP, e.getYaw(), e.getPitch()); - if (rotations != null) { - e.setRotations(rotations[0], rotations[1]); - } - } - } - } - - private boolean isWoolWars() { - if (!Utils.nullCheck() || !Utils.isHypixel()) { - return false; - } - Scoreboard scoreboard = mc.theWorld.getScoreboard(); - if (scoreboard == null) { - return false; - } - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - return objective != null && Utils.stripString(objective.getDisplayName()).contains("WOOL WARS"); - } - - private void swapBack() { - if (swapBack != -1) { - mc.thePlayer.inventory.currentItem = swapBack; - swapBack = -1; - } - } - - private void reset() { - middlePos = (miningPos = null); - placeMop = null; - curBlockDamageMP = (delay = 0); - swapBack = -1; - } - - @SubscribeEvent - public void onRender(RenderWorldLastEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (middlePos != null) { - for (BlockPos pos : getPossiblePos(middlePos, false)) { - RenderUtils.renderBlock(pos, this.middlePositionColors, true, false); - } - } - if (miningPos != null) { - RenderUtils.renderBlock(miningPos, this.miningColor, false, true); - } - else if (placeMop != null) { - RenderUtils.renderBlock(BlockUtils.offsetPos(placeMop), this.placeColor, false, true); - } - } - - @SubscribeEvent - public void onMouse(MouseEvent e) { - if (e.button == 0) { - if (e.buttonstate && (miningPos != null || placeMop != null)) { - e.setCanceled(true); - } - } - else if (e.button == 1 && (miningPos != null || placeMop != null)) { - e.setCanceled(true); - } - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - reset(); - } - } - - public static void startBreak(BlockPos pos) { - mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, EnumFacing.UP)); - } - - public static void stopBreak(BlockPos pos) { - mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, EnumFacing.UP)); - } - - public static void abortBreak(final BlockPos pos) { - mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, pos, EnumFacing.DOWN)); - } +package keystrokesmod.module.impl.minigames; + +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockStairs; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Mouse; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class WoolWars extends Module { + public SliderSetting breakSpeed; + public SliderSetting range; + public SliderSetting breakDelay; + public SliderSetting placeDelay; + public ButtonSetting onlyMiddleClick; + public ButtonSetting onlyVisible; + + private final int middlePositionColors = new Color(255, 153, 204).getRGB(); + private final int miningColor = new Color(200, 100, 255).getRGB(); + private final int placeColor = new Color(150, 70, 255).getRGB(); + + private BlockPos middlePos; + private BlockPos miningPos; + private MovingObjectPosition placeMop; + + private float curBlockDamageMP; + private int delay; + private int swapBack = -1; + private double lastRange; + private double rangeSq; + private float placingYaw; + private float placingPitch; + private boolean fakeSwing; + + public WoolWars() { + super("WoolWars", category.minigames, 0); + + this.registerSetting(new DescriptionSetting("Nukes and places at control point.")); + this.registerSetting(breakSpeed = new SliderSetting("Break speed", 0.2, 0.0, 0.8, 0.05)); + this.registerSetting(breakDelay = new SliderSetting("Delay after breaking", 3.0, 1.0, 10.0, 1.0)); + this.registerSetting(placeDelay = new SliderSetting("Delay after placing", 1.0, 1.0, 10.0, 1.0)); + this.registerSetting(range = new SliderSetting("Range", 5.0, 1.0, 8.0, 0.5)); + this.registerSetting(onlyVisible = new ButtonSetting("Only visible", true)); + this.registerSetting(onlyMiddleClick = new ButtonSetting("Only while middle clicking", true)); + } + + @Override + public void guiUpdate() { + if (lastRange != range.getInput()) { + lastRange = range.getInput(); + rangeSq = Math.pow(lastRange + 2.0, 2.0); + } + } + + @Override + public void onDisable() { + swapBack(); + reset(); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent event) { + if (!isWoolWars()) { + reset(); + return; + } + if (middlePos == null) { + middlePos = getMiddlePos(); + } + else if (!mc.thePlayer.capabilities.allowFlying && mc.thePlayer.getDistanceSq(middlePos) < rangeSq && isActiveRound() && (!onlyMiddleClick.isToggled() || Mouse.isButtonDown(2))) { + if (swapBack == -1) { + swapBack = mc.thePlayer.inventory.currentItem; + } + if (delay > 0 && --delay > 0) { + if (fakeSwing) { + mc.thePlayer.swingItem(); + } + return; + } + if (placeMop != null) { + return; + } + if (miningPos == null) { + List posList = getPossiblePos(middlePos, true); + if (!posList.isEmpty()) { + BlockPos closestPos = getClosestPos(posList, true); + if (closestPos != null) { + int blockSlot = getBlockSlot(); + if (blockSlot == -1) { + return; + } + Utils.switchSlot(blockSlot, true); + search: + for (int i = 0; i < 360; i += 10) { + float yaw = (float) (mc.thePlayer.rotationYaw + i + randomRotationOffset()); + int j = 20; + while (j < 90) { + float pitch = RotationUtils.clampPitch((float) (j + randomRotationOffset())); + MovingObjectPosition mop = Utils.getTarget(lastRange, yaw, pitch); + if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && BlockUtils.isBlockPosEqual(BlockUtils.offsetPos(mop), closestPos)) { + placeMop = mop; + placingYaw = yaw; + placingPitch = pitch; + break search; + } + else { + j += 5; + } + } + } + return; + } + } + posList = getPossiblePos(middlePos, false); + if (posList.isEmpty()) { + middlePos = null; + swapBack(); + return; + } + BlockPos closestPos = getClosestPos(posList, false); + if (closestPos == null) { + return; + } + miningPos = closestPos; + switchToSlot(Utils.getTool(BlockUtils.getBlock(closestPos))); + miningPos = closestPos; + mc.thePlayer.swingItem(); + startBreak(miningPos); + } + else if (!Utils.isPossibleToReach(miningPos, lastRange)) { + abortBreak(miningPos); + miningPos = null; + curBlockDamageMP = (delay = 0); + return; + } + curBlockDamageMP += BlockUtils.getBlockHardness(BlockUtils.getBlock(miningPos), mc.thePlayer.getHeldItem(), false, false); + if (curBlockDamageMP < breakSpeed.getInput()) { + curBlockDamageMP = (float) breakSpeed.getInput(); + } + if (curBlockDamageMP >= 1.0f) { + stopBreak(miningPos); + mc.playerController.onPlayerDestroyBlock(miningPos, EnumFacing.UP); + miningPos = null; + curBlockDamageMP = 0.0f; + delay = (int) breakDelay.getInput(); + fakeSwing = true; + } + mc.theWorld.sendBlockBreakProgress(mc.thePlayer.getEntityId(), miningPos, (int) (curBlockDamageMP * 10.0f) - 1); + mc.thePlayer.swingItem(); + } + else if (miningPos != null) { + abortBreak(miningPos); + miningPos = null; + curBlockDamageMP = (delay = 0); + swapBack(); + } + else if (swapBack != -1) { + swapBack(); + } + } + + public double randomRotationOffset() { + return Math.random() - 0.5; + } + + public boolean switchToSlot(int slot) { + if (slot == -1) { + return false; + } + mc.thePlayer.inventory.currentItem = slot; + return true; + } + + private BlockPos getMiddlePos() { + BlockPos middlePos = null; + int y; + int startY; + for (startY = (y = (int) Math.floor(mc.thePlayer.posY + 20.0)); y > -1; --y) { + BlockPos pos = BlockUtils.pos(0.0, y, 0.0); + if (BlockUtils.getBlock(pos.add(0, 0, 2)) instanceof BlockStairs || isControlPointBlock(pos, false)) { + middlePos = pos; + break; + } + } + if (middlePos == null) { + for (y = startY; y > -1; --y) { + BlockPos pos = BlockUtils.pos(0.0, y, 6.0); + if (BlockUtils.getBlock(pos.add(0, 0, 2)) instanceof BlockStairs || isControlPointBlock(pos, false)) { + middlePos = pos; + break; + } + } + } + return middlePos; + } + + private List getPossiblePos(BlockPos middlePos, boolean airOnly) { + List posList = new ArrayList<>(); + for (int zOffset = -1; zOffset <= 1; ++zOffset) { + for (int xOffset = -1; xOffset <= 1; ++xOffset) { + BlockPos pos = new BlockPos(middlePos.getX() + xOffset, middlePos.getY(), middlePos.getZ() + zOffset); + if (airOnly) { + if (!(BlockUtils.getBlock(pos) instanceof BlockAir)) { + continue; + } + } else if (!isControlPointBlock(pos, true)) { + continue; + } + posList.add(pos); + } + } + return posList; + } + + private BlockPos getClosestPos(List posList, boolean down) { + BlockPos closestPos = null; + double leastDistSq = rangeSq + 1.0; + for (BlockPos pos : posList) { + if (!Utils.isPossibleToReach(down ? pos.down() : pos, lastRange)) { + continue; + } + if (onlyVisible.isToggled() && !BlockUtils.canBlockBeSeen(pos)) { + continue; + } + double distSq = mc.thePlayer.getDistanceSq(pos); + if (distSq >= leastDistSq) { + continue; + } + leastDistSq = distSq; + closestPos = pos; + } + return closestPos; + } + + private boolean isControlPointBlock(BlockPos pos, boolean verifyWoolColor) { + Block block = BlockUtils.getBlock(pos); + if (block != Blocks.wool) { + return block == Blocks.snow || block == Blocks.quartz_block; + } + if (!verifyWoolColor) { + return true; + } + EnumDyeColor teamColor = null; + for (int i = 0; i < InventoryPlayer.getHotbarSize(); ++i) { + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() == Blocks.wool) { + teamColor = EnumDyeColor.byMetadata(stack.getMetadata()); + break; + } + } + return BlockUtils.getWoolColor(BlockUtils.getBlockState(pos)) != teamColor; + } + + private boolean isActiveRound() { + for (String line : Utils.getSidebarLines()) { + String strip = Utils.stripString(line); + if (strip.contains("State: Active Round")) { + return true; + } + } + return false; + } + + public int getBlockSlot() { + for (int slot = 0; slot < InventoryPlayer.getHotbarSize(); ++slot) { + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(slot); + if (stack != null) { + if (stack.getItem() instanceof ItemBlock) { + Block block = ((ItemBlock) stack.getItem()).getBlock(); + if (BlockUtils.isNormalBlock(block)) { + return slot; + } + } + } + } + return -1; + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent e) { + if (placeMop != null) { + if (placingPitch > 90.0f) { + if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem(), placeMop.getBlockPos(), placeMop.sideHit, placeMop.hitVec)) { + mc.thePlayer.swingItem(); + mc.getItemRenderer().resetEquippedProgress(); + delay = (int) placeDelay.getInput(); + fakeSwing = false; + } + placeMop = null; + } + else { + placingPitch += 300.0f; + } + e.setYaw(placingYaw); + e.setPitch(placingPitch - 300.0f); + return; + } + if (miningPos != null) { + float[] rotations = RotationUtils.getRotationsToBlock(miningPos, EnumFacing.UP, e.getYaw(), e.getPitch()); + if (rotations != null) { + e.setRotations(rotations[0], rotations[1]); + } + } + if (delay > 0 && (!onlyMiddleClick.isToggled() || Mouse.isButtonDown(2))) { + List posList = getPossiblePos(middlePos, true); + BlockPos closestPos = null; + if (!posList.isEmpty()) { + closestPos = getClosestPos(posList, true); + } + if (closestPos == null) { + posList = getPossiblePos(middlePos, false); + closestPos = getClosestPos(posList, false); + } + if (closestPos != null) { + float[] rotations = RotationUtils.getRotationsToBlock(closestPos, EnumFacing.UP, e.getYaw(), e.getPitch()); + if (rotations != null) { + e.setRotations(rotations[0], rotations[1]); + } + } + } + } + + private boolean isWoolWars() { + if (!Utils.nullCheck() || !Utils.isHypixel()) { + return false; + } + Scoreboard scoreboard = mc.theWorld.getScoreboard(); + if (scoreboard == null) { + return false; + } + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + return objective != null && Utils.stripString(objective.getDisplayName()).contains("WOOL WARS"); + } + + private void swapBack() { + if (swapBack != -1) { + mc.thePlayer.inventory.currentItem = swapBack; + swapBack = -1; + } + } + + private void reset() { + middlePos = (miningPos = null); + placeMop = null; + curBlockDamageMP = (delay = 0); + swapBack = -1; + } + + @SubscribeEvent + public void onRender(RenderWorldLastEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (middlePos != null) { + for (BlockPos pos : getPossiblePos(middlePos, false)) { + RenderUtils.renderBlock(pos, this.middlePositionColors, true, false); + } + } + if (miningPos != null) { + RenderUtils.renderBlock(miningPos, this.miningColor, false, true); + } + else if (placeMop != null) { + RenderUtils.renderBlock(BlockUtils.offsetPos(placeMop), this.placeColor, false, true); + } + } + + @SubscribeEvent + public void onMouse(MouseEvent e) { + if (e.button == 0) { + if (e.buttonstate && (miningPos != null || placeMop != null)) { + e.setCanceled(true); + } + } + else if (e.button == 1 && (miningPos != null || placeMop != null)) { + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + reset(); + } + } + + public static void startBreak(BlockPos pos) { + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, EnumFacing.UP)); + } + + public static void stopBreak(BlockPos pos) { + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, EnumFacing.UP)); + } + + public static void abortBreak(final BlockPos pos) { + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, pos, EnumFacing.DOWN)); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java index 0be1b36..09f3482 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java @@ -125,10 +125,10 @@ public class Bhop extends Module { if (Utils.isMoving()) { if (!Utils.noSlowingBackWithBow() && !ModuleManager.sprint.disableBackwards() && !slowBackwards()) { - Utils.setSpeed((speedModifier - Utils.randomizeDouble(0.0003, 0.0001)) * ModuleUtils.applyFrictionMulti()); + Utils.setSpeed((speedModifier) * ModuleUtils.applyFrictionMulti()); } else { - Utils.setSpeed((speedModifier - Utils.randomizeDouble(0.0003, 0.0001)) - 0.3); + Utils.setSpeed((speedModifier) - 0.3); } didMove = true; } diff --git a/src/main/java/keystrokesmod/module/impl/movement/Dolphin.java b/src/main/java/keystrokesmod/module/impl/movement/Dolphin.java index bfe9566..acf0a21 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Dolphin.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Dolphin.java @@ -1,61 +1,61 @@ -package keystrokesmod.module.impl.movement; - -import keystrokesmod.event.PostPlayerInputEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; - -public class Dolphin extends Module { - public SliderSetting horSpeed; - public SliderSetting verSpeed; - public ButtonSetting buoyant; - public ButtonSetting disableUsing; - public ButtonSetting disableVerticalWhileMoving; - public ButtonSetting forwardOnly; - - public Dolphin() { - super("Dolphin", category.movement, 0); - this.registerSetting(horSpeed = new SliderSetting("Horizontal speed", 1.0, 1.0, 8.0, 0.1)); - this.registerSetting(verSpeed = new SliderSetting("Vertical speed", 1.0, 1.0, 8.0, 0.1)); - this.registerSetting(buoyant = new ButtonSetting("Buoyant", false)); - this.registerSetting(disableUsing = new ButtonSetting("Disable while using", true)); - this.registerSetting(disableVerticalWhileMoving = new ButtonSetting("Disable vertical while moving", false)); - this.registerSetting(forwardOnly = new ButtonSetting("Forward only", true)); - } - - @SubscribeEvent - public void onPostPlayerInput(PostPlayerInputEvent event) { - if (!mc.thePlayer.isInWater() || mc.thePlayer.capabilities.isFlying) { - return; - } - if (disableUsing.isToggled() && mc.thePlayer.isUsingItem()) { - return; - } - if (forwardOnly.isToggled() && !Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode())) { - return; - } - if (buoyant.isToggled()) { - mc.thePlayer.motionY = 0.0; - } - if (Utils.isUserMoving()) { - double horizontalSpeed = 0.078 * horSpeed.getInput(); - Utils.setSpeed(horizontalSpeed); - if (disableVerticalWhileMoving.isToggled()) { - return; - } - } - if (Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode())) { - mc.thePlayer.motionY = 0.02 + 0.04 * verSpeed.getInput(); - } - else if (!mc.thePlayer.onGround && Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) { - mc.thePlayer.movementInput.sneak = false; - mc.thePlayer.motionY = -0.1 - 0.03 * verSpeed.getInput(); - } - else if (buoyant.isToggled()) { - mc.thePlayer.motionY = 0.0; - } - } -} +package keystrokesmod.module.impl.movement; + +import keystrokesmod.event.PostPlayerInputEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; + +public class Dolphin extends Module { + public SliderSetting horSpeed; + public SliderSetting verSpeed; + public ButtonSetting buoyant; + public ButtonSetting disableUsing; + public ButtonSetting disableVerticalWhileMoving; + public ButtonSetting forwardOnly; + + public Dolphin() { + super("Dolphin", category.movement, 0); + this.registerSetting(horSpeed = new SliderSetting("Horizontal speed", 1.0, 1.0, 8.0, 0.1)); + this.registerSetting(verSpeed = new SliderSetting("Vertical speed", 1.0, 1.0, 8.0, 0.1)); + this.registerSetting(buoyant = new ButtonSetting("Buoyant", false)); + this.registerSetting(disableUsing = new ButtonSetting("Disable while using", true)); + this.registerSetting(disableVerticalWhileMoving = new ButtonSetting("Disable vertical while moving", false)); + this.registerSetting(forwardOnly = new ButtonSetting("Forward only", true)); + } + + @SubscribeEvent + public void onPostPlayerInput(PostPlayerInputEvent event) { + if (!mc.thePlayer.isInWater() || mc.thePlayer.capabilities.isFlying) { + return; + } + if (disableUsing.isToggled() && mc.thePlayer.isUsingItem()) { + return; + } + if (forwardOnly.isToggled() && !Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode())) { + return; + } + if (buoyant.isToggled()) { + mc.thePlayer.motionY = 0.0; + } + if (Utils.isUserMoving()) { + double horizontalSpeed = 0.078 * horSpeed.getInput(); + Utils.setSpeed(horizontalSpeed); + if (disableVerticalWhileMoving.isToggled()) { + return; + } + } + if (Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode())) { + mc.thePlayer.motionY = 0.02 + 0.04 * verSpeed.getInput(); + } + else if (!mc.thePlayer.onGround && Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) { + mc.thePlayer.movementInput.sneak = false; + mc.thePlayer.motionY = -0.1 - 0.03 * verSpeed.getInput(); + } + else if (buoyant.isToggled()) { + mc.thePlayer.motionY = 0.0; + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/movement/FastFall.java b/src/main/java/keystrokesmod/module/impl/movement/FastFall.java index 6ed40ef..6c5eb70 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/FastFall.java +++ b/src/main/java/keystrokesmod/module/impl/movement/FastFall.java @@ -1,121 +1,121 @@ -package keystrokesmod.module.impl.movement; - -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.init.Blocks; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.util.BlockPos; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class FastFall extends Module { - public SliderSetting mode; - private ButtonSetting disableAdventure; - private ButtonSetting ignoreVoid; - private ButtonSetting disableNoFall; - private String[] modes = new String[]{"Accelerate", "Timer"}; - - private double initialY; - private boolean isFalling; - - private int fallTicks; - private int motion; - - private SliderSetting ticks; - - public FastFall() { - super("FastFall", category.player); - this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); - this.registerSetting(disableAdventure = new ButtonSetting("Disable adventure", false)); - this.registerSetting(ignoreVoid = new ButtonSetting("Ignore void", true)); - this.registerSetting(disableNoFall = new ButtonSetting("Disable while NoFalling", true)); - this.registerSetting(ticks = new SliderSetting("Intervals", 2, 1, 10, 1)); - } - - public void onDisable() { - Utils.resetTimer(); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (reset()) { - if (isFalling) Utils.resetTimer(); - initialY = mc.thePlayer.posY; - isFalling = false; - fallTicks = motion = 0; - return; - } - else if ((double) mc.thePlayer.fallDistance >= 2) { - isFalling = true; - } - - double predictedY = mc.thePlayer.posY + mc.thePlayer.motionY; - double distanceFallen = initialY - predictedY; - - if (isFalling && mode.getInput() == 0) { - ++fallTicks; - Utils.resetTimer(); - if (fallTicks >= ticks.getInput()) { - mc.thePlayer.motionY -= ((double) motion / 95); - fallTicks = 0; - motion++; - } - } - - if (isFalling && mode.getInput() == 1) { - ++fallTicks; - Utils.resetTimer(); - if (fallTicks >= ticks.getInput()) { - Utils.getTimer().timerSpeed = 1.5F; - fallTicks = 0; - } - } - } - - @Override - public String getInfo() { - return modes[(int) mode.getInput()]; - } - - private boolean isVoid() { - return Utils.overVoid(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); - } - - private boolean reset() { - if (disableAdventure.isToggled() && mc.playerController.getCurrentGameType().isAdventure()) { - return true; - } - if (ignoreVoid.isToggled() && isVoid()) { - return true; - } - if (Utils.isReplay()) { - return true; - } - if (mc.thePlayer.onGround) { - return true; - } - if (mc.thePlayer.motionY > -0.0784) { - return true; - } - if (mc.thePlayer.capabilities.isCreativeMode) { - return true; - } - if (mc.thePlayer.capabilities.isFlying) { - return true; - } - if (ModuleManager.scaffold.isEnabled) { - return true; - } - if (ModuleManager.noFall.isFalling) { - return true; - } - return false; - } - +package keystrokesmod.module.impl.movement; + +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.init.Blocks; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.util.BlockPos; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class FastFall extends Module { + public SliderSetting mode; + private ButtonSetting disableAdventure; + private ButtonSetting ignoreVoid; + private ButtonSetting disableNoFall; + private String[] modes = new String[]{"Accelerate", "Timer"}; + + private double initialY; + private boolean isFalling; + + private int fallTicks; + private int motion; + + private SliderSetting ticks; + + public FastFall() { + super("FastFall", category.player); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + this.registerSetting(disableAdventure = new ButtonSetting("Disable adventure", false)); + this.registerSetting(ignoreVoid = new ButtonSetting("Ignore void", true)); + this.registerSetting(disableNoFall = new ButtonSetting("Disable while NoFalling", true)); + this.registerSetting(ticks = new SliderSetting("Intervals", 2, 1, 10, 1)); + } + + public void onDisable() { + Utils.resetTimer(); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (reset()) { + if (isFalling) Utils.resetTimer(); + initialY = mc.thePlayer.posY; + isFalling = false; + fallTicks = motion = 0; + return; + } + else if ((double) mc.thePlayer.fallDistance >= 2) { + isFalling = true; + } + + double predictedY = mc.thePlayer.posY + mc.thePlayer.motionY; + double distanceFallen = initialY - predictedY; + + if (isFalling && mode.getInput() == 0) { + ++fallTicks; + Utils.resetTimer(); + if (fallTicks >= ticks.getInput()) { + mc.thePlayer.motionY -= ((double) motion / 95); + fallTicks = 0; + motion++; + } + } + + if (isFalling && mode.getInput() == 1) { + ++fallTicks; + Utils.resetTimer(); + if (fallTicks >= ticks.getInput()) { + Utils.getTimer().timerSpeed = 1.5F; + fallTicks = 0; + } + } + } + + @Override + public String getInfo() { + return modes[(int) mode.getInput()]; + } + + private boolean isVoid() { + return Utils.overVoid(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + } + + private boolean reset() { + if (disableAdventure.isToggled() && mc.playerController.getCurrentGameType().isAdventure()) { + return true; + } + if (ignoreVoid.isToggled() && isVoid()) { + return true; + } + if (Utils.isReplay()) { + return true; + } + if (mc.thePlayer.onGround) { + return true; + } + if (mc.thePlayer.motionY > -0.0784) { + return true; + } + if (mc.thePlayer.capabilities.isCreativeMode) { + return true; + } + if (mc.thePlayer.capabilities.isFlying) { + return true; + } + if (ModuleManager.scaffold.isEnabled) { + return true; + } + if (ModuleManager.noFall.isFalling) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java index 059446c..706bedf 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java +++ b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java @@ -1,512 +1,504 @@ -package keystrokesmod.module.impl.movement; - -import keystrokesmod.Raven; -import keystrokesmod.event.PrePlayerInputEvent; -import keystrokesmod.event.*; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.mixin.interfaces.IMixinItemRenderer; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.KeySetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.*; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.client.C09PacketHeldItemChange; -import net.minecraft.network.play.client.C0APacketAnimation; -import net.minecraft.network.play.server.*; -import net.minecraft.potion.PotionEffect; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.input.Keyboard; - -import java.awt.*; - -public class LongJump extends Module { - private SliderSetting mode; - - private SliderSetting boostSetting; - private SliderSetting motionTicks; - private SliderSetting verticalMotion; - private SliderSetting motionDecay; - - private ButtonSetting manual; - private ButtonSetting onlyWithVelocity; - private KeySetting disableKey, flatKey; - - private ButtonSetting allowStrafe; - private ButtonSetting invertYaw; - private ButtonSetting stopMovement; - private ButtonSetting hideExplosion; - public ButtonSetting spoofItem; - private ButtonSetting beginFlat; - private ButtonSetting silentSwing; - private ButtonSetting renderFloatProgress; - - private KeySetting verticalKey; - private SliderSetting pitchVal; - - public String[] modes = new String[]{"Float", "Boost"}; - - private boolean manualWasOn; - - private float yaw; - private float pitch; - - private boolean notMoving; - private boolean enabled, swapped; - public static boolean function; - - private int boostTicks = -1; - public int lastSlot = -1, spoofSlot = -1; - private int stopTime; - private int rotateTick; - private int motionDecayVal; - - private long fireballTime; - private long MAX_EXPLOSION_DIST_SQ = 9; - private long FIREBALL_TIMEOUT = 750L; - - public static boolean stopVelocity; - public static boolean stopModules; - public static boolean slotReset; - public static int slotResetTicks; - - private int firstSlot = -1; - - private int color = new Color(0, 187, 255, 255).getRGB(); - private float barWidth = 60; - private float barHeight = 4; - private float filledWidth; - private float barX; - private float barY; - - public LongJump() { - super("Long Jump", category.movement); - this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); - - this.registerSetting(manual = new ButtonSetting("Manual", false)); - this.registerSetting(onlyWithVelocity = new ButtonSetting("Only while velocity enabled", false)); - this.registerSetting(disableKey = new KeySetting("Disable key", Keyboard.KEY_SPACE)); - - this.registerSetting(boostSetting = new SliderSetting("Horizontal boost", 1.7, 0.0, 2.0, 0.05)); - this.registerSetting(verticalMotion = new SliderSetting("Vertical motion", 0, 0.4, 0.9, 0.01)); - this.registerSetting(motionDecay = new SliderSetting("Motion decay", 17, 1, 40, 1)); - this.registerSetting(allowStrafe = new ButtonSetting("Allow strafe", false)); - this.registerSetting(invertYaw = new ButtonSetting("Invert yaw", true)); - this.registerSetting(stopMovement = new ButtonSetting("Stop movement", false)); - this.registerSetting(hideExplosion = new ButtonSetting("Hide explosion", false)); - this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); - this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); - this.registerSetting(renderFloatProgress = new ButtonSetting("Render progress", false)); - - this.registerSetting(beginFlat = new ButtonSetting("Begin flat", false)); - this.registerSetting(verticalKey = new KeySetting("Vertical key", Keyboard.KEY_SPACE)); - this.registerSetting(flatKey = new KeySetting("Flat key", Keyboard.KEY_SPACE)); - } - - public void guiUpdate() { - this.onlyWithVelocity.setVisible(manual.isToggled(), this); - this.disableKey.setVisible(manual.isToggled(), this); - this.spoofItem.setVisible(!manual.isToggled(), this); - this.silentSwing.setVisible(!manual.isToggled(), this); - - //this.renderFloatProgress.setVisible(mode.getInput() == 0, this); - - this.verticalMotion.setVisible(mode.getInput() == 0, this); - this.motionDecay.setVisible(mode.getInput() == 0, this); - this.beginFlat.setVisible(mode.getInput() == 0, this); - this.verticalKey.setVisible(mode.getInput() == 0 && beginFlat.isToggled(), this); - this.flatKey.setVisible(mode.getInput() == 0 && !beginFlat.isToggled(), this); - } - - public void onEnable() { - if (ModuleUtils.profileTicks <= 1) { - return; - } - if (!manual.isToggled()) { - if (Utils.getTotalHealth(mc.thePlayer) <= 3) { - Utils.sendMessage("&cPrevented throwing fireball due to low health"); - disable(); - return; - } - enabled(); - } - filledWidth = 0; - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int[] disp = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; - barX = disp[0] / 2 - barWidth / 2; - barY = disp[1] / 2 + 12; - } - - public void onDisable() { - disabled(); - } - - /*public boolean onChat(String chatMessage) { - String msg = util.strip(chatMessage); - - if (msg.equals("Build height limit reached!")) { - client.print("fb fly build height"); - modules.disable(scriptName); - return false; - } - return true; - }*/ - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (manual.isToggled()) { - manualWasOn = true; - } - else { - if (manualWasOn) { - disabled(); - } - manualWasOn = false; - } - - if (manual.isToggled() && disableKey.isPressed() && Utils.jumpDown()) { - function = false; - disabled(); - } - - if (spoofItem.isToggled() && lastSlot != -1 && !manual.isToggled()) { - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); - } - - if (swapped && rotateTick == 0) { - resetSlot(); - swapped = false; - } - - if (!function) { - if (manual.isToggled() && !enabled && (!onlyWithVelocity.isToggled() || onlyWithVelocity.isToggled() && ModuleManager.velocity.isEnabled())) { - if (ModuleUtils.threwFireballLow) { - ModuleManager.velocity.disableVelo = true; - enabled(); - } - } - return; - } - - if (enabled) { - if (!Utils.isMoving() && mode.getInput() == 0) notMoving = true; - if (boostSetting.getInput() == 0 && verticalMotion.getInput() == 0) { - Utils.print("&cValues are set to 0!"); - disabled(); - return; - } - int fireballSlot = setupFireballSlot(true); - if (fireballSlot != -1) { - if (!manual.isToggled()) { - lastSlot = spoofSlot = mc.thePlayer.inventory.currentItem; - if (mc.thePlayer.inventory.currentItem != fireballSlot) { - mc.thePlayer.inventory.currentItem = fireballSlot; - swapped = true; - } - - } - //("Set fireball slot"); - rotateTick = 1; - if (stopMovement.isToggled()) { - stopTime = 1; - } - } // auto disables if -1 - enabled = false; - } - - if (notMoving) { - motionDecayVal = 21; - } else { - motionDecayVal = (int) motionDecay.getInput(); - } - if (stopTime == -1 && ++boostTicks > (!verticalKey() ? 33/*flat motion ticks*/ : (!notMoving ? 32/*normal motion ticks*/ : 33/*vertical motion ticks*/))) { - disabled(); - return; - } - - if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT) { - Utils.print("&cFireball timed out."); - disabled(); - return; - } - if (boostTicks > 0) { - if (mode.getInput() == 0) { - modifyVertical(); // has to be onPreUpdate - } - //Utils.print("Modifying vertical"); - if (allowStrafe.isToggled() && boostTicks < 32) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); - //Utils.print("Speed"); - } - } - - filledWidth = (barWidth * boostTicks / (!notMoving ? 32 : 33)); - - if (stopMovement.isToggled() && !notMoving) { - if (stopTime > 0) { - ++stopTime; - } - } - - if (mc.thePlayer.onGround && boostTicks > 2) { - disabled(); - } - - if (firstSlot != -1) { - mc.thePlayer.inventory.currentItem = firstSlot; - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck()) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null || !renderFloatProgress.isToggled() || mode.getInput() != 0 || !function) { - return; - } - } - color = Theme.getGradient((int) HUD.theme.getInput(), 0); - RenderUtils.drawRoundedRectangle(barX, barY, barX + barWidth, barY + barHeight, 3, 0xFF555555); - RenderUtils.drawRoundedRectangle(barX, barY, barX + filledWidth, barY + barHeight, 3, color); - } - - @SubscribeEvent - public void onSlotUpdate(SlotUpdateEvent e) { - if (lastSlot != -1) { - spoofSlot = e.slot; - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onPreMotion(PreMotionEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (rotateTick >= 3) { - rotateTick = 0; - } - if (rotateTick >= 1) { - if ((invertYaw.isToggled() || stopMovement.isToggled()) && !notMoving) { - if (!stopMovement.isToggled()) { - yaw = mc.thePlayer.rotationYaw - 180f; - pitch = 90f; - } else { - yaw = mc.thePlayer.rotationYaw - 180f; - pitch = 66.3f;//(float) pitchVal.getInput(); - } - } else { - yaw = mc.thePlayer.rotationYaw; - pitch = 90f; - } - e.setRotations(yaw, pitch); - } - if (rotateTick > 0 && ++rotateTick >= 3) { - int fireballSlot = setupFireballSlot(false); - if (fireballSlot != -1) { - fireballTime = System.currentTimeMillis(); - if (!manual.isToggled()) { - mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); - if (silentSwing.isToggled()) { - mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); - } - else { - mc.thePlayer.swingItem(); - if (!spoofItem.isToggled()) { - mc.getItemRenderer().resetEquippedProgress(); - } - } - } - stopVelocity = true; - //Utils.print("Right click"); - } - } - if (boostTicks == 1) { - if (invertYaw.isToggled()) { - //client.setMotion(client.getMotion().x, client.getMotion().y + 0.035d, client.getMotion().z); - } - modifyHorizontal(); - stopVelocity = false; - if (!manual.isToggled() && !allowStrafe.isToggled() && mode.getInput() == 1) { - disabled(); - } - } - } - - @SubscribeEvent - public void onPostPlayerInput(PostPlayerInputEvent e) { - if (!function) { - return; - } - mc.thePlayer.movementInput.jump = false; - } - - @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix - public void onMoveInput(PrePlayerInputEvent e) { - if (!function) { - return; - } - if (rotateTick > 0 || fireballTime > 0) { - if (Utils.isMoving()) e.setForward(1); - e.setStrafe(0); - } - if (notMoving && boostTicks < 3) { - e.setForward(0); - e.setStrafe(0); - Utils.setSpeed(0); - } - if (stopMovement.isToggled() && !notMoving && stopTime >= 1) { - e.setForward(0); - e.setStrafe(0); - Utils.setSpeed(0); - } - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (!function) { - return; - } - Packet packet = e.getPacket(); - if (packet instanceof S27PacketExplosion && boostTicks == -1) { - S27PacketExplosion s27 = (S27PacketExplosion) packet; - if (fireballTime == 0 || mc.thePlayer.getPosition().distanceSq(s27.getX(), s27.getY(), s27.getZ()) > MAX_EXPLOSION_DIST_SQ) { - e.setCanceled(true); - //Utils.print("0 fb time / out of dist"); - } - - stopTime = -1; - fireballTime = 0; - resetSlot(); - boostTicks = 0; // +1 on next pre update - //Utils.print("set start vals"); - - //client.print(client.getPlayer().getTicksExisted() + " s27 " + boostTicks + " " + client.getPlayer().getHurtTime() + " " + client.getPlayer().getSpeed()); - } else if (packet instanceof S08PacketPlayerPosLook) { - Utils.print("&cReceived setback, disabling."); - disabled(); - } - - if (hideExplosion.isToggled() && fireballTime != 0 && (packet instanceof S0EPacketSpawnObject || packet instanceof S2APacketParticles || packet instanceof S29PacketSoundEffect)) { - e.setCanceled(true); - } - } - - private int getFireballSlot() { - int n = -1; - for (int i = 0; i < 9; ++i) { - final ItemStack getStackInSlot = mc.thePlayer.inventory.getStackInSlot(i); - if (getStackInSlot != null && getStackInSlot.getItem() == Items.fire_charge) { - n = i; - break; - } - } - return n; - } - - private void enabled() { - slotReset = false; - slotResetTicks = 0; - enabled = function = true; - - stopModules = true; - } - - private void disabled() { - fireballTime = rotateTick = stopTime = 0; - boostTicks = -1; - resetSlot(); - enabled = function = notMoving = stopVelocity = stopModules = swapped = false; - filledWidth = 0; - if (!manual.isToggled()) { - disable(); - } - } - - private int setupFireballSlot(boolean pre) { - // only cancel bad packet right click on the tick we are sending it - int fireballSlot = getFireballSlot(); - if (fireballSlot == -1) { - Utils.print("&cFireball not found."); - disabled(); - } else if ((pre && Utils.distanceToGround(mc.thePlayer) > 3)/* || (!pre && !PacketUtil.canRightClickItem())*/) { //needs porting - Utils.print("&cCan't throw fireball right now."); - disabled(); - fireballSlot = -1; - } - return fireballSlot; - } - - private void resetSlot() { - if (lastSlot != -1 && !manual.isToggled()) { - mc.thePlayer.inventory.currentItem = lastSlot; - lastSlot = -1; - spoofSlot = -1; - firstSlot = -1; - if (spoofItem.isToggled()) { - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(false); - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(false); - } - } - slotReset = true; - stopModules = false; - } - - private int getSpeedLevel() { - for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { - if (potionEffect.getEffectName().equals("potion.moveSpeed")) { - return potionEffect.getAmplifier() + 1; - } - return 0; - } - return 0; - } - - // only apply horizontal boost once - void modifyHorizontal() { - if (boostSetting.getInput() != 0) { - - double speed = boostSetting.getInput() - Utils.randomizeDouble(0.0001, 0); - if (Utils.isMoving()) { - Utils.setSpeed(speed); - } - } - } - - private void modifyVertical() { - if (verticalMotion.getInput() != 0) { - double ver = ((!notMoving ? verticalMotion.getInput() : 1.16 /*vertical*/) * (1.0 / (1.0 + (0.05 * getSpeedLevel())))) + Utils.randomizeDouble(0.0001, 0.1); - double decay = motionDecay.getInput() / 1000; - if (mode.getInput() == 0) { - if (boostTicks > 1 && !verticalKey()) { - if (boostTicks > 1 || boostTicks <= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/)) { - mc.thePlayer.motionY = Utils.randomizeDouble(0.0101, 0.01); - } - } else { - if (boostTicks >= 1 && boostTicks <= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/)) { - mc.thePlayer.motionY = ver - boostTicks * decay; - } else if (boostTicks >= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/) + 3) { - mc.thePlayer.motionY = mc.thePlayer.motionY + 0.028; - Utils.print("?"); - } - } - - } - } - } - - private boolean verticalKey() { - if (notMoving) return true; - return beginFlat.isToggled() ? verticalKey.isPressed() : !flatKey.isPressed(); - } +package keystrokesmod.module.impl.movement; + +import keystrokesmod.Raven; +import keystrokesmod.event.PrePlayerInputEvent; +import keystrokesmod.event.*; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.mixin.interfaces.IMixinItemRenderer; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.KeySetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.server.*; +import net.minecraft.potion.PotionEffect; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.input.Keyboard; + +import java.awt.*; + +public class LongJump extends Module { + private SliderSetting mode; + + private SliderSetting boostSetting; + private SliderSetting verticalMotion; + private SliderSetting motionDecay; + + private ButtonSetting manual; + private ButtonSetting onlyWithVelocity; + private KeySetting disableKey, flatKey; + + private ButtonSetting allowStrafe; + private ButtonSetting invertYaw; + private ButtonSetting stopMovement; + private ButtonSetting hideExplosion; + public ButtonSetting spoofItem; + private ButtonSetting beginFlat; + private ButtonSetting silentSwing; + private ButtonSetting renderFloatProgress; + + private KeySetting verticalKey; + private SliderSetting pitchVal; + + public String[] modes = new String[]{"Float", "Boost"}; + + private boolean manualWasOn; + + private float yaw; + private float pitch; + + private boolean notMoving; + private boolean enabled, swapped; + public static boolean function; + + private int boostTicks = -1; + public int lastSlot = -1, spoofSlot = -1; + private int stopTime; + private int rotateTick; + private double motionDecayVal; + + private long fireballTime; + private long MAX_EXPLOSION_DIST_SQ = 9; + private long FIREBALL_TIMEOUT = 750L; + + public static boolean stopVelocity; + public static boolean stopModules; + public static boolean slotReset; + public static int slotResetTicks; + + private int firstSlot = -1; + + private int color = new Color(0, 187, 255, 255).getRGB(); + private float barWidth = 60; + private float barHeight = 4; + private float filledWidth; + private float barX; + private float barY; + + public LongJump() { + super("Long Jump", category.movement); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + + this.registerSetting(manual = new ButtonSetting("Manual", false)); + this.registerSetting(onlyWithVelocity = new ButtonSetting("Only while velocity enabled", false)); + this.registerSetting(disableKey = new KeySetting("Disable key", Keyboard.KEY_SPACE)); + + this.registerSetting(boostSetting = new SliderSetting("Horizontal boost", 1.7, 0.0, 2.0, 0.05)); + this.registerSetting(verticalMotion = new SliderSetting("Vertical motion", 0, 0.3, 1, 0.01)); + this.registerSetting(motionDecay = new SliderSetting("Motion decay", "%", 43, 1, 100, 1)); + this.registerSetting(allowStrafe = new ButtonSetting("Allow strafe", false)); + this.registerSetting(invertYaw = new ButtonSetting("Invert yaw", true)); + this.registerSetting(stopMovement = new ButtonSetting("Stop movement", false)); + this.registerSetting(hideExplosion = new ButtonSetting("Hide explosion", false)); + this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); + this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); + this.registerSetting(renderFloatProgress = new ButtonSetting("Render progress", false)); + + this.registerSetting(beginFlat = new ButtonSetting("Begin flat", false)); + this.registerSetting(verticalKey = new KeySetting("Vertical key", Keyboard.KEY_SPACE)); + this.registerSetting(flatKey = new KeySetting("Flat key", Keyboard.KEY_SPACE)); + } + + public void guiUpdate() { + this.onlyWithVelocity.setVisible(manual.isToggled(), this); + this.disableKey.setVisible(manual.isToggled(), this); + this.spoofItem.setVisible(!manual.isToggled(), this); + this.silentSwing.setVisible(!manual.isToggled(), this); + + //this.renderFloatProgress.setVisible(mode.getInput() == 0, this); + + this.verticalMotion.setVisible(mode.getInput() == 0, this); + this.motionDecay.setVisible(mode.getInput() == 0, this); + this.beginFlat.setVisible(mode.getInput() == 0, this); + this.verticalKey.setVisible(mode.getInput() == 0 && beginFlat.isToggled(), this); + this.flatKey.setVisible(mode.getInput() == 0 && !beginFlat.isToggled(), this); + } + + public void onEnable() { + if (ModuleUtils.profileTicks <= 1) { + return; + } + if (!manual.isToggled()) { + if (Utils.getTotalHealth(mc.thePlayer) <= 3) { + Utils.sendMessage("&cPrevented throwing fireball due to low health"); + disable(); + return; + } + enabled(); + } + filledWidth = 0; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] disp = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + barX = disp[0] / 2 - barWidth / 2; + barY = disp[1] / 2 + 12; + } + + public void onDisable() { + disabled(); + } + + /*public boolean onChat(String chatMessage) { + String msg = util.strip(chatMessage); + + if (msg.equals("Build height limit reached!")) { + client.print("fb fly build height"); + modules.disable(scriptName); + return false; + } + return true; + }*/ + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (manual.isToggled()) { + manualWasOn = true; + } + else { + if (manualWasOn) { + disabled(); + } + manualWasOn = false; + } + + if (manual.isToggled() && disableKey.isPressed() && Utils.jumpDown()) { + function = false; + disabled(); + } + + if (spoofItem.isToggled() && lastSlot != -1 && !manual.isToggled()) { + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); + } + + if (swapped && rotateTick == 0) { + resetSlot(); + swapped = false; + } + + if (!function) { + if (manual.isToggled() && !enabled && (!onlyWithVelocity.isToggled() || onlyWithVelocity.isToggled() && ModuleManager.velocity.isEnabled())) { + if (ModuleUtils.threwFireballLow) { + ModuleManager.velocity.disableVelo = true; + enabled(); + } + } + return; + } + + if (enabled) { + if (!Utils.isMoving() && mode.getInput() == 0) notMoving = true; + if (boostSetting.getInput() == 0 && verticalMotion.getInput() == 0) { + Utils.modulePrint("&cValues are set to 0!"); + disabled(); + return; + } + int fireballSlot = setupFireballSlot(true); + if (fireballSlot != -1) { + if (!manual.isToggled()) { + lastSlot = spoofSlot = mc.thePlayer.inventory.currentItem; + if (mc.thePlayer.inventory.currentItem != fireballSlot) { + mc.thePlayer.inventory.currentItem = fireballSlot; + swapped = true; + } + + } + //("Set fireball slot"); + rotateTick = 1; + if (stopMovement.isToggled()) { + stopTime = 1; + } + } // auto disables if -1 + enabled = false; + } + + if (notMoving) { + motionDecayVal = 21; + } else { + motionDecayVal = (motionDecay.getInput() / 2.5); + } + if (stopTime == -1 && ++boostTicks > (!verticalKey() ? 33/*flat motion ticks*/ : (!notMoving ? 32/*normal motion ticks*/ : 33/*vertical motion ticks*/))) { + disabled(); + return; + } + + if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT) { + Utils.modulePrint("&cFireball timed out."); + disabled(); + return; + } + if (boostTicks > 0) { + if (mode.getInput() == 0) { + modifyVertical(); // has to be onPreUpdate + } + if (allowStrafe.isToggled() && boostTicks < 32) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); + } + } + + filledWidth = (barWidth * boostTicks / (!notMoving ? 32 : 33)); + + if (stopMovement.isToggled() && !notMoving) { + if (stopTime > 0) { + ++stopTime; + } + } + + if (mc.thePlayer.onGround && boostTicks > 2) { + disabled(); + } + + if (firstSlot != -1) { + mc.thePlayer.inventory.currentItem = firstSlot; + } + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck()) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null || !renderFloatProgress.isToggled() || mode.getInput() != 0 || !function) { + return; + } + } + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + RenderUtils.drawRoundedRectangle(barX, barY, barX + barWidth, barY + barHeight, 3, 0xFF555555); + RenderUtils.drawRoundedRectangle(barX, barY, barX + filledWidth, barY + barHeight, 3, color); + } + + @SubscribeEvent + public void onSlotUpdate(SlotUpdateEvent e) { + if (lastSlot != -1) { + spoofSlot = e.slot; + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPreMotion(PreMotionEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (rotateTick >= 3) { + rotateTick = 0; + } + if (rotateTick >= 1) { + if ((invertYaw.isToggled() || stopMovement.isToggled()) && !notMoving) { + if (!stopMovement.isToggled()) { + yaw = mc.thePlayer.rotationYaw - 180f; + pitch = 90f; + } else { + yaw = mc.thePlayer.rotationYaw - 180f; + pitch = 66.3f;//(float) pitchVal.getInput(); + } + } else { + yaw = mc.thePlayer.rotationYaw; + pitch = 90f; + } + e.setRotations(yaw, pitch); + } + if (rotateTick > 0 && ++rotateTick >= 3) { + int fireballSlot = setupFireballSlot(false); + if (fireballSlot != -1) { + fireballTime = System.currentTimeMillis(); + if (!manual.isToggled()) { + mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); + if (silentSwing.isToggled()) { + mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); + } + else { + mc.thePlayer.swingItem(); + if (!spoofItem.isToggled()) { + mc.getItemRenderer().resetEquippedProgress(); + } + } + } + stopVelocity = true; + } + } + if (boostTicks == 1) { + modifyHorizontal(); + stopVelocity = false; + if (!manual.isToggled() && !allowStrafe.isToggled() && mode.getInput() == 1) { + disabled(); + } + } + } + + @SubscribeEvent + public void onPostPlayerInput(PostPlayerInputEvent e) { + if (!function) { + return; + } + mc.thePlayer.movementInput.jump = false; + } + + @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix + public void onMoveInput(PrePlayerInputEvent e) { + if (!function) { + return; + } + if (rotateTick > 0 || fireballTime > 0) { + if (Utils.isMoving()) e.setForward(1); + e.setStrafe(0); + } + if (notMoving && boostTicks < 3) { + e.setForward(0); + e.setStrafe(0); + Utils.setSpeed(0); + } + if (stopMovement.isToggled() && !notMoving && stopTime >= 1) { + e.setForward(0); + e.setStrafe(0); + Utils.setSpeed(0); + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (!function) { + return; + } + Packet packet = e.getPacket(); + if (packet instanceof S27PacketExplosion && boostTicks == -1) { + S27PacketExplosion s27 = (S27PacketExplosion) packet; + if (fireballTime == 0 || mc.thePlayer.getPosition().distanceSq(s27.getX(), s27.getY(), s27.getZ()) > MAX_EXPLOSION_DIST_SQ) { + e.setCanceled(true); + } + if (!mc.thePlayer.onGround) { + disabled(); + } + + stopTime = -1; + fireballTime = 0; + resetSlot(); + boostTicks = 0; // +1 on next pre update + } else if (packet instanceof S08PacketPlayerPosLook) { + Utils.modulePrint("&cReceived setback, disabling."); + disabled(); + } + + if (hideExplosion.isToggled() && fireballTime != 0 && (packet instanceof S0EPacketSpawnObject || packet instanceof S2APacketParticles || packet instanceof S29PacketSoundEffect)) { + e.setCanceled(true); + } + } + + private int getFireballSlot() { + int n = -1; + for (int i = 0; i < 9; ++i) { + final ItemStack getStackInSlot = mc.thePlayer.inventory.getStackInSlot(i); + if (getStackInSlot != null && getStackInSlot.getItem() == Items.fire_charge) { + n = i; + break; + } + } + return n; + } + + private void enabled() { + slotReset = false; + slotResetTicks = 0; + enabled = function = true; + + stopModules = true; + } + + private void disabled() { + fireballTime = rotateTick = stopTime = 0; + boostTicks = -1; + resetSlot(); + enabled = function = notMoving = stopVelocity = stopModules = swapped = false; + filledWidth = 0; + if (!manual.isToggled()) { + disable(); + } + } + + private int setupFireballSlot(boolean pre) { + // only cancel bad packet right click on the tick we are sending it + int fireballSlot = getFireballSlot(); + if (fireballSlot == -1) { + Utils.modulePrint("&cFireball not found."); + disabled(); + } else if ((pre && Utils.distanceToGround(mc.thePlayer) > 3)/* || (!pre && !PacketUtil.canRightClickItem())*/) { //needs porting + Utils.modulePrint("&cCan't throw fireball right now."); + disabled(); + fireballSlot = -1; + } + return fireballSlot; + } + + private void resetSlot() { + if (lastSlot != -1 && !manual.isToggled()) { + mc.thePlayer.inventory.currentItem = lastSlot; + lastSlot = -1; + spoofSlot = -1; + firstSlot = -1; + if (spoofItem.isToggled()) { + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(false); + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(false); + } + } + slotReset = true; + stopModules = false; + } + + private int getSpeedLevel() { + for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { + if (potionEffect.getEffectName().equals("potion.moveSpeed")) { + return potionEffect.getAmplifier() + 1; + } + return 0; + } + return 0; + } + + // only apply horizontal boost once + void modifyHorizontal() { + if (boostSetting.getInput() != 0) { + + double speed = boostSetting.getInput() - Utils.randomizeDouble(0.0001, 0); + if (Utils.isMoving()) { + Utils.setSpeed(speed); + } + } + } + + private void modifyVertical() { + if (verticalMotion.getInput() != 0) { + double ver = ((!notMoving ? verticalMotion.getInput() : 1.16 /*vertical*/) * (1.0 / (1.0 + (0.05 * getSpeedLevel())))) + Utils.randomizeDouble(0.0001, 0.1); + double decay = motionDecayVal / 1000; + if (mode.getInput() == 0) { + if (boostTicks > 1 && !verticalKey()) { + if (boostTicks > 1 || boostTicks <= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/)) { + mc.thePlayer.motionY = Utils.randomizeDouble(0.0101, 0.01); + } + } else { + if (boostTicks >= 1 && boostTicks <= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/)) { + mc.thePlayer.motionY = ver - boostTicks * decay; + } else if (boostTicks >= (!notMoving ? 32/*horizontal motion ticks*/ : 33/*vertical motion ticks*/) + 3) { + mc.thePlayer.motionY = mc.thePlayer.motionY + 0.028; + Utils.modulePrint("If you get this clip it & send in the raven bs v2 discord"); + } + } + + } + } + } + + private boolean verticalKey() { + if (notMoving) return true; + return beginFlat.isToggled() ? verticalKey.isPressed() : !flatKey.isPressed(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java index ab87dbc..70f763e 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java +++ b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java @@ -23,6 +23,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.client.*; import net.minecraft.util.BlockPos; import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Mouse; @@ -34,11 +35,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class NoSlow extends Module { public static SliderSetting sword, mode, blinkMode, vanillaMode; public static SliderSetting slowed; - public static ButtonSetting disableBow; + public static ButtonSetting disableBow, disableSword; public static ButtonSetting disablePotions; public static ButtonSetting swordOnly; - public static ButtonSetting disableSprintInAir; - private ButtonSetting renderTimer; + public ButtonSetting renderTimer; private String[] swordMode = new String[] { "Vanilla", "Item mode", "Fake" }; private String[] modes = new String[] { "Vanilla", "Pre", "Post", "Alpha", "Float", "Blink" }; @@ -47,19 +47,15 @@ public class NoSlow extends Module { private boolean postPlace; private boolean canFloat; - public boolean noSlowing, offset; - private int offsetDelay; - private boolean setJump; - private boolean bl; - private boolean blink, wentOffGround; - private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - private int color = new Color(0, 187, 255, 255).getRGB(); - private int blinkTicks, floatTicks; + public boolean noSlowing; + public boolean offset; + public boolean blockingClient; + public boolean blink; + private boolean wentOffGround; private boolean requireJump; private static boolean fix; - private boolean didC; - private boolean jumped, setCancelled; - public boolean fn; + private boolean didC, md; + private boolean jumped, setCancelled, setJump; public NoSlow() { super("NoSlow", category.movement, 0); @@ -70,10 +66,10 @@ public class NoSlow extends Module { this.registerSetting(blinkMode = new SliderSetting("Blink Mode", 0, blinkModes)); this.registerSetting(renderTimer = new ButtonSetting("Render timer", false)); this.registerSetting(slowed = new SliderSetting("Slow %", 80.0D, 0.0D, 80.0D, 1.0D)); + this.registerSetting(disableSword = new ButtonSetting("Disable sword", false)); this.registerSetting(disableBow = new ButtonSetting("Disable bow", false)); this.registerSetting(disablePotions = new ButtonSetting("Disable potions", false)); this.registerSetting(swordOnly = new ButtonSetting("Sword only", false)); - this.registerSetting(disableSprintInAir = new ButtonSetting("Disable sprint in air", false)); } public void guiUpdate() { @@ -85,19 +81,38 @@ public class NoSlow extends Module { @Override public void onDisable() { resetFloat(); - noSlowing = false; - if (bl) { - ReflectionUtils.setItemInUse(false); - bl = false; + if (blockingClient) { + ReflectionUtils.setItemInUse(blockingClient = false); } - release(); - fn = false; + blink = wentOffGround = false; + cantBlock = false; } - public void onUpdate() { + @SubscribeEvent + public void onMouse(MouseEvent e) { + if (e.button == 1 && e.buttonstate) { + handleFloatSetup(); + if (setCancelled) { + setCancelled = false; + e.setCanceled(true); + } + } + + if (sword.getInput() == 2 && Utils.tabbedIn() && !ModuleManager.killAura.blockingClient) { + if (e.button == 1) { + EntityLivingBase g = Utils.raytrace(4); + if (Utils.holdingSword() && g == null && !BlockUtils.isInteractable(mc.objectMouseOver)) { + e.setCanceled(true); + } + } + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { boolean apply = getSlowed() != 0.2f; if (!apply || !mc.thePlayer.isUsingItem()) { - release(); + blink = wentOffGround = false; return; } postPlace = false; @@ -119,7 +134,9 @@ public class NoSlow extends Module { } break; case 4: - handleFloatSetup(); + if (Mouse.isButtonDown(1)) { + handleFloatSetup(); + } if (!blockConditions()) { didC = true; requireJump = true; @@ -135,26 +152,12 @@ public class NoSlow extends Module { blink = true; } else { - release(); + blink = wentOffGround = false; } - if (blink) blinkTicks++; break; } } - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck() || !renderTimer.isToggled() || mode.getInput() != 5 || blinkTicks == 0 || blinkTicks >= 99999) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - } - Utils.handleTimer(color, blinkTicks); - } - @SubscribeEvent public void onPostMotion(PostMotionEvent e) { if (postPlace && mode.getInput() == 2) { @@ -165,48 +168,87 @@ public class NoSlow extends Module { } } + @SubscribeEvent + public void onPostPlayerInput(PostPlayerInputEvent e) { + if (setJump) { + mc.thePlayer.movementInput.jump = true; + setJump = false; + } + } + + private boolean blocking; + + public boolean cantBlock; + @SubscribeEvent public void onPreMotion(PreMotionEvent e) { - fn = false; - if (sword.getInput() == 2 && !ModuleManager.killAura.blockingClient) { - if (Utils.holdingSword() && Utils.tabbedIn() && Mouse.isButtonDown(1)) { - ReflectionUtils.setItemInUse(true); - bl = true; - if (Mouse.isButtonDown(0)) { - mc.thePlayer.swingItem(); + EntityLivingBase g = Utils.raytrace(4); + if (ModuleManager.killAura.blockingClient) { + blockingClient = false; + } + if (blockingClient && (!Mouse.isButtonDown(1) || !Utils.holdingSword())) { + ReflectionUtils.setItemInUse(blockingClient = false); + } + if (sword.getInput() == 2) { + if (blocking && (g == null && !BlockUtils.isInteractable(mc.objectMouseOver) || !Utils.holdingSword() && !Utils.keybinds.isMouseDown(1) || !Utils.tabbedIn())) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + blocking = false; + } + if (Utils.holdingSword()) { + if (g == null && !BlockUtils.isInteractable(mc.objectMouseOver)) { + cantBlock = true; + + if (Utils.tabbedIn() && Mouse.isButtonDown(1)) { + blockingClient = true; + } + } else { + blocking = true; + cantBlock = false; + } + if (blockingClient) { + ReflectionUtils.setItemInUse(blockingClient = true); + if (Mouse.isButtonDown(0)) { + mc.thePlayer.swingItem(); + } } } - else if (bl) { - ReflectionUtils.setItemInUse(false); - bl = false; + else { + cantBlock = false; } } + else { + cantBlock = false; + } + + if (!Mouse.isButtonDown(1)) { + md = false; + } + postPlace = false; if (mode.getInput() != 4) { return; } boolean apply = getSlowed() != 0.2f; - if (!Mouse.isButtonDown(1) || !apply || fix || didC || !holdingUsable(mc.thePlayer.getHeldItem())) { + if (!Mouse.isButtonDown(1) || !holdingUsable() || !Utils.tabbedIn()) { resetFloat(); - noSlowing = false; - offsetDelay = 0; - if (!Mouse.isButtonDown(1)) { - fix = didC = requireJump = false; - } + } + if (!apply || fix || didC) { return; } if (!canFloat && jumped && ModuleUtils.inAirTicks > 1) { KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true); canFloat = true; + setCancelled = false; } - else if (canFloat && canFloat() && !requireJump && (!jumped || ++offsetDelay > 1)) { - fn = true; + else if (canFloat && canFloat() && !requireJump) { + md = true; if (!mc.thePlayer.onGround) { - if (mc.thePlayer.motionY < -0.0784000015258789 && !(mc.thePlayer.posY % 1 == 0)) { - e.setPosY(e.getPosY() + 1e-3); - } else { + //-0.0784000015258789 ground value + //if (mc.thePlayer.motionY <= -0.1784000015258789) { + //e.setPosY(e.getPosY() + 1e-3); + //} else { e.setPosY(e.getPosY() - 1e-3); - } + //} } else { e.setPosY(e.getPosY() + 1e-3); @@ -214,37 +256,17 @@ public class NoSlow extends Module { } } - @SubscribeEvent - public void onMouse(MouseEvent e) { - if (sword.getInput() == 2 && Utils.tabbedIn() && !ModuleManager.killAura.blockingClient) { - if (e.button == 1) { - EntityLivingBase g = Utils.raytrace(4); - if (Utils.holdingSword() && g == null && !BlockUtils.isInteractable(mc.objectMouseOver)) { - e.setCanceled(true); - } - } - } - - handleFloatSetup(); - - if (setCancelled) { - if (e.button == 1) { - e.setCanceled(true); - } - setCancelled = false; - } - } - private void handleFloatSetup() { boolean apply = getSlowed() != 0.2f; if (mode.getInput() != 4) { return; } - if (!Mouse.isButtonDown(1) || !apply || fix || didC || !holdingUsable(mc.thePlayer.getHeldItem()) || canFloat || jumped) { + if (!apply || fix || didC || !holdingUsable() || canFloat || jumped || BlockUtils.isInteractable(mc.objectMouseOver) || md) { return; } if (mc.thePlayer.onGround) { - setJump = jumped = true; + setJump = true; + jumped = true; setCancelled = true; KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); } @@ -253,43 +275,6 @@ public class NoSlow extends Module { } } - @SubscribeEvent - public void onPostPlayerInput(PostPlayerInputEvent e) { - if (setJump) { - mc.thePlayer.movementInput.jump = true; - setJump = false; - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (blink) { - if (!e.isCanceled()) { - blinkedPackets.add(e.getPacket()); - e.setCanceled(true); - } - } - } - - private void release() { - if (!blink) { - return; - } - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - blinkedPackets.clear(); - blink = false; - blinkTicks = 0; - wentOffGround = false; - } - private boolean blinkConditions() { if (blinkMode.getInput() == 0) { return true; @@ -337,6 +322,9 @@ public class NoSlow extends Module { if (mc.thePlayer.getHeldItem().getItem() instanceof ItemBow && disableBow.isToggled()) { return 0.2f; } + if (mc.thePlayer.getHeldItem().getItem() instanceof ItemSword && disableSword.isToggled()) { + return 0.2f; + } else if (mc.thePlayer.getHeldItem().getItem() instanceof ItemPotion && !ItemPotion.isSplash(mc.thePlayer.getHeldItem().getItemDamage()) && disablePotions.isToggled()) { return 0.2f; } @@ -357,19 +345,23 @@ public class NoSlow extends Module { } private void resetFloat() { - jumped = false; - canFloat = false; - setJump = false; - offsetDelay = 0; - floatTicks = 0; + noSlowing = false; + fix = didC = requireJump = canFloat = jumped = md = setJump = setCancelled = false; } - private boolean holdingUsable(ItemStack itemStack) { + private boolean holdingUsable() { + ItemStack itemStack = mc.thePlayer.getHeldItem(); + if (itemStack == null) { + return false; + } Item heldItem = itemStack.getItem(); - if (heldItem instanceof ItemFood || heldItem instanceof ItemBucketMilk || (heldItem instanceof ItemBow && Utils.hasArrows(itemStack)) || (heldItem instanceof ItemPotion && !ItemPotion.isSplash(mc.thePlayer.getHeldItem().getItemDamage())) || (heldItem instanceof ItemSword && sword.getInput() == 1)) { + if (heldItem == null) { + return false; + } + if (heldItem instanceof ItemFood || heldItem instanceof ItemBucketMilk || (heldItem instanceof ItemBow && Utils.hasArrows(itemStack)) || (heldItem instanceof ItemPotion && !ItemPotion.isSplash(mc.thePlayer.getHeldItem().getItemDamage()))) { return true; } - if (sword.getInput() == 1 && Utils.holdingSword()) { + if (sword.getInput() == 1 && heldItem instanceof ItemSword) { return true; } return false; diff --git a/src/main/java/keystrokesmod/module/impl/movement/TargetStrafe.java b/src/main/java/keystrokesmod/module/impl/movement/TargetStrafe.java index 8de83f3..7e6580b 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/TargetStrafe.java +++ b/src/main/java/keystrokesmod/module/impl/movement/TargetStrafe.java @@ -1,85 +1,85 @@ -package keystrokesmod.module.impl.movement; - -import keystrokesmod.event.PostPlayerInputEvent; -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.event.PrePlayerInputEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.GroupSetting; -import keystrokesmod.module.setting.impl.KeySetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Mouse; - -public class TargetStrafe extends Module { - private ButtonSetting requireBhop; - private ButtonSetting requireJump; - private ButtonSetting requireRMB; - private SliderSetting radius; - - private double angle; - - public TargetStrafe() { - super("TargetStrafe", category.movement); - this.registerSetting(requireBhop = new ButtonSetting("Require bhop", false)); - this.registerSetting(requireJump = new ButtonSetting("Require jump key", false)); - this.registerSetting(requireRMB = new ButtonSetting("Require RMB", false)); - this.registerSetting(radius = new SliderSetting("Radius", 0.6, 0, 3, 0.1)); - } - - public void guiUpdate() { - - } - - /*@Override - public String getInfo() { - return modes[(int) mode.getInput()]; - }*/ - - @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix - public void onMoveInput(PrePlayerInputEvent e) { - if (requireBhop.isToggled() && !ModuleManager.bhop.isEnabled()) { - return; - } - if (requireJump.isToggled() && !Utils.jumpDown()) { - return; - } - if (requireRMB.isToggled() && !Mouse.isButtonDown(1)) { - return; - } - if (ModuleManager.scaffold.isEnabled) { - return; - } - if (KillAura.target == null) { - return; - } - EntityLivingBase targetPosition = KillAura.target; - angle += 1; - - double offsetX = ((float) radius.getInput()) * Math.cos(angle); - double offsetZ = ((float) radius.getInput()) * Math.sin(angle); - double directionX = targetPosition.getPosition().getX() + offsetX - mc.thePlayer.posX; - double directionZ = targetPosition.getPosition().getZ() + offsetZ - mc.thePlayer.posZ; - double magnitude = Math.sqrt(directionX * directionX + directionZ * directionZ); - if (magnitude > 0.01) { - directionX /= magnitude; - directionZ /= magnitude; - double yawRadians = Math.toRadians(-mc.thePlayer.rotationYaw); - double rotatedX = directionX * Math.cos(yawRadians) - directionZ * Math.sin(yawRadians); - double rotatedZ = directionX * Math.sin(yawRadians) + directionZ * Math.cos(yawRadians); - e.setStrafe((float) rotatedX); - e.setForward((float) rotatedZ); - } - } - - public void onDisable() { - - } +package keystrokesmod.module.impl.movement; + +import keystrokesmod.event.PostPlayerInputEvent; +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PrePlayerInputEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.KillAura; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.GroupSetting; +import keystrokesmod.module.setting.impl.KeySetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Mouse; + +public class TargetStrafe extends Module { + private ButtonSetting requireBhop; + private ButtonSetting requireJump; + private ButtonSetting requireRMB; + private SliderSetting radius; + + private double angle; + + public TargetStrafe() { + super("TargetStrafe", category.movement); + this.registerSetting(requireBhop = new ButtonSetting("Require bhop", false)); + this.registerSetting(requireJump = new ButtonSetting("Require jump key", false)); + this.registerSetting(requireRMB = new ButtonSetting("Require RMB", false)); + this.registerSetting(radius = new SliderSetting("Radius", 0.6, 0, 3, 0.1)); + } + + public void guiUpdate() { + + } + + /*@Override + public String getInfo() { + return modes[(int) mode.getInput()]; + }*/ + + @SubscribeEvent(priority = EventPriority.LOWEST) // called last in order to apply fix + public void onMoveInput(PrePlayerInputEvent e) { + if (requireBhop.isToggled() && !ModuleManager.bhop.isEnabled()) { + return; + } + if (requireJump.isToggled() && !Utils.jumpDown()) { + return; + } + if (requireRMB.isToggled() && !Mouse.isButtonDown(1)) { + return; + } + if (ModuleManager.scaffold.isEnabled) { + return; + } + if (KillAura.target == null) { + return; + } + EntityLivingBase targetPosition = KillAura.target; + angle += 1; + + double offsetX = ((float) radius.getInput()) * Math.cos(angle); + double offsetZ = ((float) radius.getInput()) * Math.sin(angle); + double directionX = targetPosition.getPosition().getX() + offsetX - mc.thePlayer.posX; + double directionZ = targetPosition.getPosition().getZ() + offsetZ - mc.thePlayer.posZ; + double magnitude = Math.sqrt(directionX * directionX + directionZ * directionZ); + if (magnitude > 0.01) { + directionX /= magnitude; + directionZ /= magnitude; + double yawRadians = Math.toRadians(-mc.thePlayer.rotationYaw); + double rotatedX = directionX * Math.cos(yawRadians) - directionZ * Math.sin(yawRadians); + double rotatedZ = directionX * Math.sin(yawRadians) + directionZ * Math.cos(yawRadians); + e.setStrafe((float) rotatedX); + e.setForward((float) rotatedZ); + } + } + + public void onDisable() { + + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/movement/Teleport.java b/src/main/java/keystrokesmod/module/impl/movement/Teleport.java index 0f39ac0..2ab965e 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Teleport.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Teleport.java @@ -1,112 +1,112 @@ -package keystrokesmod.module.impl.movement; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.awt.*; -import java.util.ArrayList; - -public class Teleport extends Module { - private ButtonSetting rightClick; - private ButtonSetting highlightTarget; - private ButtonSetting highlightPath; - private BlockPos targetPos; - private ArrayList path = new ArrayList<>(); - public Teleport() { - super("Teleport", category.movement); - this.registerSetting(rightClick = new ButtonSetting("Right click teleport", true)); - this.registerSetting(highlightTarget = new ButtonSetting("Highlight target", true)); - this.registerSetting(highlightPath = new ButtonSetting("Highlight path", false)); - } - - public void teleport(BlockPos targetBlock, boolean sendMessage) { - targetBlock = targetBlock.up(1); - ArrayList pathList = this.path = getPath(targetBlock); - int packetsSent = 0; - for (Vec3 pathPos : pathList) { - mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(pathPos.xCoord, pathPos.yCoord, pathPos.zCoord, true)); - if (++packetsSent >= 175) { - if (sendMessage) { - Utils.sendMessage("&eToo many packets, ending loop."); - break; - } - break; - } - } - mc.thePlayer.setPosition(targetBlock.getX(), targetBlock.getY(), targetBlock.getZ()); - if (sendMessage) { - Utils.sendMessage("&eTeleported to &d(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") &ewith &b" + packetsSent + " &epackets."); - } - } - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent e) { - if (!rightClick.isToggled() || !highlightTarget.isToggled() || this.targetPos == null || !Utils.nullCheck()) { - return; - } - RenderUtils.renderBlock(targetPos, Color.orange.getRGB(), true, true); - if (highlightPath.isToggled()) { - int positions = 0; - for (Vec3 pos : this.path) { - if (positions >= 175) { - break; - } - RenderUtils.renderBlock(new BlockPos(pos.xCoord, pos.yCoord, pos.zCoord), Color.yellow.getRGB(), false, true); - ++positions; - } - } - } - - private ArrayList getPath(BlockPos target) { - ArrayList path = new ArrayList<>(); - double newX = (double)target.getX() + 0.5; - double newY = target.getY() + 1; - double newZ = (double)target.getZ() + 0.5; - double distance = this.mc.thePlayer.getDistance(newX, newY, newZ); - double d = 0; - while (d < distance) { - path.add(new Vec3(this.mc.thePlayer.posX + (newX - (double)this.mc.thePlayer.getHorizontalFacing().getFrontOffsetX() - this.mc.thePlayer.posX) * d / distance, this.mc.thePlayer.posY + (newY - this.mc.thePlayer.posY) * d / distance, this.mc.thePlayer.posZ + (newZ - (double)this.mc.thePlayer.getHorizontalFacing().getFrontOffsetZ() - this.mc.thePlayer.posZ) * d / distance)); - d += 2.0; - } - return path; - } - - @SubscribeEvent - public void onMouse(MouseEvent mouseEvent) { - if (mouseEvent.button != 1 || !mouseEvent.buttonstate || !rightClick.isToggled() || !Utils.nullCheck()) { - return; - } - MovingObjectPosition rayCast = RotationUtils.rayCast(150.0, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); - if (rayCast == null || rayCast.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { - return; - } - final BlockPos getBlockPos = rayCast.getBlockPos(); - this.targetPos = getBlockPos; - teleport(getBlockPos, true); - } - - @Override - public void onEnable() { - this.targetPos = null; - this.path.clear(); - if (rightClick.isToggled()) { - return; - } - MovingObjectPosition rayCast = RotationUtils.rayCast(150.0, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); - if (rayCast == null || rayCast.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { - return; - } - teleport(rayCast.getBlockPos(), true); - this.disable(); - } -} +package keystrokesmod.module.impl.movement; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.awt.*; +import java.util.ArrayList; + +public class Teleport extends Module { + private ButtonSetting rightClick; + private ButtonSetting highlightTarget; + private ButtonSetting highlightPath; + private BlockPos targetPos; + private ArrayList path = new ArrayList<>(); + public Teleport() { + super("Teleport", category.movement); + this.registerSetting(rightClick = new ButtonSetting("Right click teleport", true)); + this.registerSetting(highlightTarget = new ButtonSetting("Highlight target", true)); + this.registerSetting(highlightPath = new ButtonSetting("Highlight path", false)); + } + + public void teleport(BlockPos targetBlock, boolean sendMessage) { + targetBlock = targetBlock.up(1); + ArrayList pathList = this.path = getPath(targetBlock); + int packetsSent = 0; + for (Vec3 pathPos : pathList) { + mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(pathPos.xCoord, pathPos.yCoord, pathPos.zCoord, true)); + if (++packetsSent >= 175) { + if (sendMessage) { + Utils.sendMessage("&eToo many packets, ending loop."); + break; + } + break; + } + } + mc.thePlayer.setPosition(targetBlock.getX(), targetBlock.getY(), targetBlock.getZ()); + if (sendMessage) { + Utils.sendMessage("&eTeleported to &d(" + targetBlock.getX() + ", " + targetBlock.getY() + ", " + targetBlock.getZ() + ") &ewith &b" + packetsSent + " &epackets."); + } + } + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent e) { + if (!rightClick.isToggled() || !highlightTarget.isToggled() || this.targetPos == null || !Utils.nullCheck()) { + return; + } + RenderUtils.renderBlock(targetPos, Color.orange.getRGB(), true, true); + if (highlightPath.isToggled()) { + int positions = 0; + for (Vec3 pos : this.path) { + if (positions >= 175) { + break; + } + RenderUtils.renderBlock(new BlockPos(pos.xCoord, pos.yCoord, pos.zCoord), Color.yellow.getRGB(), false, true); + ++positions; + } + } + } + + private ArrayList getPath(BlockPos target) { + ArrayList path = new ArrayList<>(); + double newX = (double)target.getX() + 0.5; + double newY = target.getY() + 1; + double newZ = (double)target.getZ() + 0.5; + double distance = this.mc.thePlayer.getDistance(newX, newY, newZ); + double d = 0; + while (d < distance) { + path.add(new Vec3(this.mc.thePlayer.posX + (newX - (double)this.mc.thePlayer.getHorizontalFacing().getFrontOffsetX() - this.mc.thePlayer.posX) * d / distance, this.mc.thePlayer.posY + (newY - this.mc.thePlayer.posY) * d / distance, this.mc.thePlayer.posZ + (newZ - (double)this.mc.thePlayer.getHorizontalFacing().getFrontOffsetZ() - this.mc.thePlayer.posZ) * d / distance)); + d += 2.0; + } + return path; + } + + @SubscribeEvent + public void onMouse(MouseEvent mouseEvent) { + if (mouseEvent.button != 1 || !mouseEvent.buttonstate || !rightClick.isToggled() || !Utils.nullCheck()) { + return; + } + MovingObjectPosition rayCast = RotationUtils.rayCast(150.0, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); + if (rayCast == null || rayCast.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + return; + } + final BlockPos getBlockPos = rayCast.getBlockPos(); + this.targetPos = getBlockPos; + teleport(getBlockPos, true); + } + + @Override + public void onEnable() { + this.targetPos = null; + this.path.clear(); + if (rightClick.isToggled()) { + return; + } + MovingObjectPosition rayCast = RotationUtils.rayCast(150.0, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); + if (rayCast == null || rayCast.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + return; + } + teleport(rayCast.getBlockPos(), true); + this.disable(); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/other/ChatBypass.java b/src/main/java/keystrokesmod/module/impl/other/ChatBypass.java index 8fa36e2..f411adb 100644 --- a/src/main/java/keystrokesmod/module/impl/other/ChatBypass.java +++ b/src/main/java/keystrokesmod/module/impl/other/ChatBypass.java @@ -1,116 +1,116 @@ -package keystrokesmod.module.impl.other; - -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.client.C01PacketChatMessage; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.Arrays; -import java.util.List; - -public class ChatBypass extends Module { - private ButtonSetting filterKnownWords; - private List filteredWords = Arrays.asList( - // blocked words - "kill", "retard", "anal", "beaner", "bestiality", "blowjob", "cameltoe", "chink", "clit", "cock", "coon", "cunnilingus", "cunt", "dick", "dildo", "dilf", "dyke", "ejaculate", "ejaculati" /*ing & ion*/, - "fag", "foreskin", "gilf", "hentai", "jerkoff", "jizz", "kike", "kill yourself", "kill urself", "kys", "loli", "masturbate", "masturbati" /*ing & ion*/, "milf", "nazi", "nigga", "nigger", - "orgy", "pedo", "penis", "porn", "pussy", "rape", "raping", "redtube", "retard", "schlong", "shemale", "sex", "swastika", "tits", "titties", "trannie", "tranny", "vagina", "whore", "xhamster", - "xvideos", "end", - // censored words - "arse", "ass", "bastard", "bitch", "boob", "douche", "fuck", "hitler", "shit", "twat", "wank" - ); - - private List allowedCommands = Arrays.asList( - "ac", "achat", "pc", "pchat", "gc", "gchat", "shout", "msg", "message", "r", "reply", "t", "tell", "w", "whisper" - ); - - private String replace_a = "\u00E1", replace_e = "\u00E9", replace_i = "\u00A1", replace_o = "\u00F3", replace_u = "\u00FA", replace_y = "\u00FF", replace_A = "\u00C1", replace_E = "\u00C9", replace_I = replace_i, replace_O = "\u00D3", replace_U = "\u00DA", replace_Y = replace_y; - - public ChatBypass() { - super("Chat Bypass", category.other); - this.registerSetting(filterKnownWords = new ButtonSetting("Only filter known words", true)); - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (!(e.getPacket() instanceof C01PacketChatMessage)) return; - C01PacketChatMessage c01 = (C01PacketChatMessage) e.getPacket(); - String msg = c01.getMessage(); - String[] split = splitCommand(msg); - - if (split == null || split[1].isEmpty()) { - return; // filter commands - } - - msg = split[1]; // set msg to just message to ignore command - - if (filterKnownWords.isToggled()) { - StringBuilder newMsg = new StringBuilder(); - String[] words = msg.split(" "); - for (String word : words) { - String lowerCaseWord = word.toLowerCase(); - for (String filteredWord : filteredWords) { - int index = lowerCaseWord.indexOf(filteredWord.toLowerCase()); - if (index != -1) { - String matched = word.substring(index, index + filteredWord.length()), - replaced = doReplace(matched); - word = word.substring(0, index) + replaced + word.substring(index + filteredWord.length()); - } - } - newMsg.append(word).append(" "); - } - msg = newMsg.toString().trim(); - } - else { - msg = doReplace(msg); - } - - if (split[0] != null) { // if command existed, re-add - msg = split[0] + " " + msg; - } - - PacketUtils.sendPacketNoEvent(new C01PacketChatMessage(msg)); - e.setCanceled(true); // cancel original packet - } - - private String[] splitCommand(String msg) { - if (msg.startsWith("/")) { - if (!isValidCommand(msg)) { - return null; - } - int spaceIndex = msg.indexOf(" "); - if (spaceIndex != -1) { // command arguments found - return new String[]{ - msg.substring(0, spaceIndex), // command - msg.substring(spaceIndex + 1) // args - }; - } - } - return new String[]{null, msg}; - } - - private String doReplace(String text) { - return text - .replace("a", replace_a).replace("e", replace_e).replace("i", replace_i) - .replace("o", replace_o).replace("u", replace_u).replace("y", replace_y) - .replace("A", replace_A).replace("E", replace_E).replace("I", replace_I) - .replace("O", replace_O).replace("U", replace_U).replace("Y", replace_Y); - } - - // assumes its already a command (starts with /) - private boolean isValidCommand(String msg) { - for (String cmd : allowedCommands) { - String _cmd = "/" + cmd + " "; - if (msg.startsWith(_cmd)) { - return true; - } - } - return false; - } -} +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.PacketUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Arrays; +import java.util.List; + +public class ChatBypass extends Module { + private ButtonSetting filterKnownWords; + private List filteredWords = Arrays.asList( + // blocked words + "kill", "retard", "anal", "beaner", "bestiality", "blowjob", "cameltoe", "chink", "clit", "cock", "coon", "cunnilingus", "cunt", "dick", "dildo", "dilf", "dyke", "ejaculate", "ejaculati" /*ing & ion*/, + "fag", "foreskin", "gilf", "hentai", "jerkoff", "jizz", "kike", "kill yourself", "kill urself", "kys", "loli", "masturbate", "masturbati" /*ing & ion*/, "milf", "nazi", "nigga", "nigger", + "orgy", "pedo", "penis", "porn", "pussy", "rape", "raping", "redtube", "retard", "schlong", "shemale", "sex", "swastika", "tits", "titties", "trannie", "tranny", "vagina", "whore", "xhamster", + "xvideos", "end", + // censored words + "arse", "ass", "bastard", "bitch", "boob", "douche", "fuck", "hitler", "shit", "twat", "wank" + ); + + private List allowedCommands = Arrays.asList( + "ac", "achat", "pc", "pchat", "gc", "gchat", "shout", "msg", "message", "r", "reply", "t", "tell", "w", "whisper" + ); + + private String replace_a = "\u00E1", replace_e = "\u00E9", replace_i = "\u00A1", replace_o = "\u00F3", replace_u = "\u00FA", replace_y = "\u00FF", replace_A = "\u00C1", replace_E = "\u00C9", replace_I = replace_i, replace_O = "\u00D3", replace_U = "\u00DA", replace_Y = replace_y; + + public ChatBypass() { + super("Chat Bypass", category.other); + this.registerSetting(filterKnownWords = new ButtonSetting("Only filter known words", true)); + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (!(e.getPacket() instanceof C01PacketChatMessage)) return; + C01PacketChatMessage c01 = (C01PacketChatMessage) e.getPacket(); + String msg = c01.getMessage(); + String[] split = splitCommand(msg); + + if (split == null || split[1].isEmpty()) { + return; // filter commands + } + + msg = split[1]; // set msg to just message to ignore command + + if (filterKnownWords.isToggled()) { + StringBuilder newMsg = new StringBuilder(); + String[] words = msg.split(" "); + for (String word : words) { + String lowerCaseWord = word.toLowerCase(); + for (String filteredWord : filteredWords) { + int index = lowerCaseWord.indexOf(filteredWord.toLowerCase()); + if (index != -1) { + String matched = word.substring(index, index + filteredWord.length()), + replaced = doReplace(matched); + word = word.substring(0, index) + replaced + word.substring(index + filteredWord.length()); + } + } + newMsg.append(word).append(" "); + } + msg = newMsg.toString().trim(); + } + else { + msg = doReplace(msg); + } + + if (split[0] != null) { // if command existed, re-add + msg = split[0] + " " + msg; + } + + PacketUtils.sendPacketNoEvent(new C01PacketChatMessage(msg)); + e.setCanceled(true); // cancel original packet + } + + private String[] splitCommand(String msg) { + if (msg.startsWith("/")) { + if (!isValidCommand(msg)) { + return null; + } + int spaceIndex = msg.indexOf(" "); + if (spaceIndex != -1) { // command arguments found + return new String[]{ + msg.substring(0, spaceIndex), // command + msg.substring(spaceIndex + 1) // args + }; + } + } + return new String[]{null, msg}; + } + + private String doReplace(String text) { + return text + .replace("a", replace_a).replace("e", replace_e).replace("i", replace_i) + .replace("o", replace_o).replace("u", replace_u).replace("y", replace_y) + .replace("A", replace_A).replace("E", replace_E).replace("I", replace_I) + .replace("O", replace_O).replace("U", replace_U).replace("Y", replace_Y); + } + + // assumes its already a command (starts with /) + private boolean isValidCommand(String msg) { + for (String cmd : allowedCommands) { + String _cmd = "/" + cmd + " "; + if (msg.startsWith(_cmd)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/other/DebugAC.java b/src/main/java/keystrokesmod/module/impl/other/DebugAC.java index 76d53f8..2e932d2 100644 --- a/src/main/java/keystrokesmod/module/impl/other/DebugAC.java +++ b/src/main/java/keystrokesmod/module/impl/other/DebugAC.java @@ -1,134 +1,134 @@ -package keystrokesmod.module.impl.other; - -import keystrokesmod.event.SendAllPacketsEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.Block; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityCreature; -import net.minecraft.init.Blocks; -import net.minecraft.network.play.client.*; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -public class DebugAC extends Module { - private ButtonSetting debugMob; - private ButtonSetting debugBlock; - private ButtonSetting alertPost; - public static long lastC03; - - public DebugAC() { - super("Debug AC", category.other); - this.registerSetting(debugBlock = new ButtonSetting("Debug block", true)); - this.registerSetting(debugMob = new ButtonSetting("Debug mob", true)); - this.registerSetting(alertPost = new ButtonSetting("Alert post", false)); - } - - public void onDisable() { - - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (ev.phase != TickEvent.Phase.END || !Utils.nullCheck()) { - return; - } - - if (debugBlock.isToggled()) { - MovingObjectPosition mouse = RotationUtils.rayCast(mc.playerController.getBlockReachDistance(), mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, false); - if (mouse == null || mouse.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mouse.getBlockPos() == null) { - return; - } - - BlockPos pos = mouse.getBlockPos(); - Block block = BlockUtils.getBlock(pos); - if (block == null || block == Blocks.air) { - return; - } - - IBlockState state = mc.theWorld.getBlockState(pos); - - mc.fontRendererObj.drawStringWithShadow("§7BlockPos: §b" + pos.getX() + "§7, §b" + pos.getY() + "§7, §b" + pos.getZ(), 30, 20, -1); - mc.fontRendererObj.drawStringWithShadow("§7HitVec: §b" + Utils.round(mouse.hitVec.xCoord, 3) + "§7, §b" + Utils.round(mouse.hitVec.yCoord, 3) + "§7, §b" + Utils.round(mouse.hitVec.zCoord, 3), 30, 30, -1); - mc.fontRendererObj.drawStringWithShadow("§7Face: §b" + mouse.sideHit.name(), 30, 40, -1); - mc.fontRendererObj.drawStringWithShadow("§7Unlocalized Name: §b" + block.getUnlocalizedName(), 30, 50, -1); - mc.fontRendererObj.drawStringWithShadow("§7Registry Name: §b" + block.getRegistryName(), 30, 60, -1); - - int y = 70; - - for (IProperty property : block.getBlockState().getProperties()) { - Class valueClass = property.getValueClass(); - String propName = property.getName(); - - Object currentValue = state.getValue(property); - - Collection allowedValues = property.getAllowedValues(); - - mc.fontRendererObj.drawStringWithShadow("§7Property Name: §b" + propName, 30, y, -1); - y += 10; - mc.fontRendererObj.drawStringWithShadow("§7Value Type: §b" + valueClass.getName(), 30, y, -1); - y += 10; - - if (currentValue != null) { - mc.fontRendererObj.drawStringWithShadow("§7Current Value: §b" + currentValue, 30, y, -1); - y += 10; - - if (valueClass.isEnum()) { - Enum enumValue = (Enum) currentValue; - mc.fontRendererObj.drawStringWithShadow("§7Current Enum Name: §b" + enumValue.name(), 30, y, -1); - y += 10; - mc.fontRendererObj.drawStringWithShadow("§7Current Enum Ordinal: §b" + enumValue.ordinal(), 30, y, -1); - y += 10; - } - } - - mc.fontRendererObj.drawStringWithShadow("§7Allowed Values: §b" + allowedValues, 30, y, -1); - y += 10; - - if (valueClass.isEnum()) { - Object[] enumConstants = valueClass.getEnumConstants(); - if (Arrays.toString(enumConstants).equals(allowedValues.toString())) { - break; - } - mc.fontRendererObj.drawStringWithShadow("§7Enum Constants: §b" + Arrays.toString(enumConstants), 30, y, -1); - y += 10; - } - - y += 5; - } - } - if (debugMob.isToggled()) { - MovingObjectPosition movingObjectPosition = mc.objectMouseOver; - if (movingObjectPosition == null || movingObjectPosition.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY || movingObjectPosition.entityHit == null || !(movingObjectPosition.entityHit instanceof EntityCreature)) { - return; - } - int xPos = 30; - int yPos = 20; - EntityCreature mob = (EntityCreature) movingObjectPosition.entityHit; - String mobName = mob.getName(); - String attackerName = mob.getAttackTarget() == null ? "&7null" : mob.getAttackTarget().getDisplayName().getFormattedText(); - List info = Arrays.asList(mobName, attackerName); - for (String data : info) { - mc.fontRendererObj.drawStringWithShadow(data, xPos, yPos, -1); - yPos += mc.fontRendererObj.FONT_HEIGHT + 3; - } - } - } - - @SubscribeEvent - public void onAllPacketSent(SendAllPacketsEvent e) { - if (e.getPacket() instanceof C03PacketPlayer) { - lastC03 = System.currentTimeMillis(); - } - } -} +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.SendAllPacketsEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityCreature; +import net.minecraft.init.Blocks; +import net.minecraft.network.play.client.*; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +public class DebugAC extends Module { + private ButtonSetting debugMob; + private ButtonSetting debugBlock; + private ButtonSetting alertPost; + public static long lastC03; + + public DebugAC() { + super("Debug AC", category.other); + this.registerSetting(debugBlock = new ButtonSetting("Debug block", true)); + this.registerSetting(debugMob = new ButtonSetting("Debug mob", true)); + this.registerSetting(alertPost = new ButtonSetting("Alert post", false)); + } + + public void onDisable() { + + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (ev.phase != TickEvent.Phase.END || !Utils.nullCheck()) { + return; + } + + if (debugBlock.isToggled()) { + MovingObjectPosition mouse = RotationUtils.rayCast(mc.playerController.getBlockReachDistance(), mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, false); + if (mouse == null || mouse.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mouse.getBlockPos() == null) { + return; + } + + BlockPos pos = mouse.getBlockPos(); + Block block = BlockUtils.getBlock(pos); + if (block == null || block == Blocks.air) { + return; + } + + IBlockState state = mc.theWorld.getBlockState(pos); + + mc.fontRendererObj.drawStringWithShadow("§7BlockPos: §b" + pos.getX() + "§7, §b" + pos.getY() + "§7, §b" + pos.getZ(), 30, 20, -1); + mc.fontRendererObj.drawStringWithShadow("§7HitVec: §b" + Utils.round(mouse.hitVec.xCoord, 3) + "§7, §b" + Utils.round(mouse.hitVec.yCoord, 3) + "§7, §b" + Utils.round(mouse.hitVec.zCoord, 3), 30, 30, -1); + mc.fontRendererObj.drawStringWithShadow("§7Face: §b" + mouse.sideHit.name(), 30, 40, -1); + mc.fontRendererObj.drawStringWithShadow("§7Unlocalized Name: §b" + block.getUnlocalizedName(), 30, 50, -1); + mc.fontRendererObj.drawStringWithShadow("§7Registry Name: §b" + block.getRegistryName(), 30, 60, -1); + + int y = 70; + + for (IProperty property : block.getBlockState().getProperties()) { + Class valueClass = property.getValueClass(); + String propName = property.getName(); + + Object currentValue = state.getValue(property); + + Collection allowedValues = property.getAllowedValues(); + + mc.fontRendererObj.drawStringWithShadow("§7Property Name: §b" + propName, 30, y, -1); + y += 10; + mc.fontRendererObj.drawStringWithShadow("§7Value Type: §b" + valueClass.getName(), 30, y, -1); + y += 10; + + if (currentValue != null) { + mc.fontRendererObj.drawStringWithShadow("§7Current Value: §b" + currentValue, 30, y, -1); + y += 10; + + if (valueClass.isEnum()) { + Enum enumValue = (Enum) currentValue; + mc.fontRendererObj.drawStringWithShadow("§7Current Enum Name: §b" + enumValue.name(), 30, y, -1); + y += 10; + mc.fontRendererObj.drawStringWithShadow("§7Current Enum Ordinal: §b" + enumValue.ordinal(), 30, y, -1); + y += 10; + } + } + + mc.fontRendererObj.drawStringWithShadow("§7Allowed Values: §b" + allowedValues, 30, y, -1); + y += 10; + + if (valueClass.isEnum()) { + Object[] enumConstants = valueClass.getEnumConstants(); + if (Arrays.toString(enumConstants).equals(allowedValues.toString())) { + break; + } + mc.fontRendererObj.drawStringWithShadow("§7Enum Constants: §b" + Arrays.toString(enumConstants), 30, y, -1); + y += 10; + } + + y += 5; + } + } + if (debugMob.isToggled()) { + MovingObjectPosition movingObjectPosition = mc.objectMouseOver; + if (movingObjectPosition == null || movingObjectPosition.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY || movingObjectPosition.entityHit == null || !(movingObjectPosition.entityHit instanceof EntityCreature)) { + return; + } + int xPos = 30; + int yPos = 20; + EntityCreature mob = (EntityCreature) movingObjectPosition.entityHit; + String mobName = mob.getName(); + String attackerName = mob.getAttackTarget() == null ? "&7null" : mob.getAttackTarget().getDisplayName().getFormattedText(); + List info = Arrays.asList(mobName, attackerName); + for (String data : info) { + mc.fontRendererObj.drawStringWithShadow(data, xPos, yPos, -1); + yPos += mc.fontRendererObj.FONT_HEIGHT + 3; + } + } + } + + @SubscribeEvent + public void onAllPacketSent(SendAllPacketsEvent e) { + if (e.getPacket() instanceof C03PacketPlayer) { + lastC03 = System.currentTimeMillis(); + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/other/LatencyAlerts.java b/src/main/java/keystrokesmod/module/impl/other/LatencyAlerts.java index 17295f9..1a192d3 100644 --- a/src/main/java/keystrokesmod/module/impl/other/LatencyAlerts.java +++ b/src/main/java/keystrokesmod/module/impl/other/LatencyAlerts.java @@ -1,66 +1,66 @@ -package keystrokesmod.module.impl.other; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.List; - -public class LatencyAlerts extends Module { - private SliderSetting interval; - private SliderSetting highLatency; - private ButtonSetting ignoreLimbo; - - private long lastPacket; - private long lastAlert; - - public LatencyAlerts() { - super("Latency Alerts", category.other); - this.registerSetting(new DescriptionSetting("Detects packet loss.")); - this.registerSetting(interval = new SliderSetting("Alert interval", " second", 3.0, 0.0, 5.0, 0.1)); - this.registerSetting(highLatency = new SliderSetting("High latency", " second", 0.5, 0.1, 5.0, 0.1)); - this.registerSetting(ignoreLimbo = new ButtonSetting("Ignore limbo", true)); - this.closetModule = true; - } - - @SubscribeEvent - public void onPacketReceive(ReceivePacketEvent e) { - lastPacket = System.currentTimeMillis(); - } - - public void onUpdate() { - if (mc.isSingleplayer() || (ignoreLimbo.isToggled() && inLimbo())) { - lastPacket = System.currentTimeMillis(); - lastAlert = System.currentTimeMillis(); - return; - } - long currentMs = System.currentTimeMillis(); - if (currentMs - lastPacket >= highLatency.getInput() * 1000 && currentMs - lastAlert >= interval.getInput() * 1000) { - Utils.sendMessage("&7Packet loss detected: " + "§c" + Math.abs(System.currentTimeMillis() - lastPacket) + "&7ms"); - lastAlert = System.currentTimeMillis(); - } - } - - public void onDisable() { - lastPacket = 0; - lastAlert = 0; - } - - public void onEnable() { - lastPacket = System.currentTimeMillis(); - } - - public boolean inLimbo() { - List scoreboard = Utils.getSidebarLines(); - if (scoreboard == null || scoreboard.isEmpty()) { - if (mc.theWorld.provider.getDimensionName().equals("The End")) { - return true; - } - } - return false; - } -} +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.List; + +public class LatencyAlerts extends Module { + private SliderSetting interval; + private SliderSetting highLatency; + private ButtonSetting ignoreLimbo; + + private long lastPacket; + private long lastAlert; + + public LatencyAlerts() { + super("Latency Alerts", category.other); + this.registerSetting(new DescriptionSetting("Detects packet loss.")); + this.registerSetting(interval = new SliderSetting("Alert interval", " second", 3.0, 0.0, 5.0, 0.1)); + this.registerSetting(highLatency = new SliderSetting("High latency", " second", 0.5, 0.1, 5.0, 0.1)); + this.registerSetting(ignoreLimbo = new ButtonSetting("Ignore limbo", true)); + this.closetModule = true; + } + + @SubscribeEvent + public void onPacketReceive(ReceivePacketEvent e) { + lastPacket = System.currentTimeMillis(); + } + + public void onUpdate() { + if (mc.isSingleplayer() || (ignoreLimbo.isToggled() && inLimbo())) { + lastPacket = System.currentTimeMillis(); + lastAlert = System.currentTimeMillis(); + return; + } + long currentMs = System.currentTimeMillis(); + if (currentMs - lastPacket >= highLatency.getInput() * 1000 && currentMs - lastAlert >= interval.getInput() * 1000) { + Utils.sendMessage("&7Packet loss detected: " + "§c" + Math.abs(System.currentTimeMillis() - lastPacket) + "&7ms"); + lastAlert = System.currentTimeMillis(); + } + } + + public void onDisable() { + lastPacket = 0; + lastAlert = 0; + } + + public void onEnable() { + lastPacket = System.currentTimeMillis(); + } + + public boolean inLimbo() { + List scoreboard = Utils.getSidebarLines(); + if (scoreboard == null || scoreboard.isEmpty()) { + if (mc.theWorld.provider.getDimensionName().equals("The End")) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/other/Spammer.java b/src/main/java/keystrokesmod/module/impl/other/Spammer.java index 321ad9f..d4d39a1 100644 --- a/src/main/java/keystrokesmod/module/impl/other/Spammer.java +++ b/src/main/java/keystrokesmod/module/impl/other/Spammer.java @@ -1,91 +1,86 @@ -package keystrokesmod.module.impl.other; - -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.C01PacketChatMessage; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.Arrays; -import java.util.List; - -public class Spammer extends Module { - private ButtonSetting spamBypass; - - private SliderSetting delay; - - public String message; - private String bypass; - private int delayTicks, half, uses; - - public Spammer() { - super("Spammer", category.other); - //this.registerSetting(new DescriptionSetting("Usage:\" .spammer \"")); - this.registerSetting(delay = new SliderSetting("Delay", "s", 3, 0.5, 30, 0.5)); - this.registerSetting(spamBypass = new ButtonSetting("Spam bypass", false)); - } - - @Override - public void onEnable() { - reset(); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - - if (uses == 0) { - bypass = "15L2QVJSHU95DPQZX3"; - } - else if (uses == 1) { - bypass = "LO4MDH1798JX5YQ935"; - } - else if (uses == 2) { - bypass = "987YQM6ND5AG01LFU3"; - } - else if (uses == 3) { - bypass = "83NMQJX5HQID83L32G"; - } - else if (uses == 4) { - bypass = "PL256GHBTNZQ38HJFM"; - } - else if (uses == 5) { - bypass = "LMP8B4GZ96BHMDU328"; - } - else if (uses >= 6) { - bypass = "OPF3HJ2K3J167YGUQW"; - uses = 0; - } - - if (!spamBypass.isToggled()) { - bypass = ""; - } - - if (!message.isEmpty()) { - ++delayTicks; - if (delayTicks >= 10) { - half++; - delayTicks = 0; - } - - if (half >= delay.getInput()) { - mc.thePlayer.sendChatMessage(message + " " + bypass); - half = delayTicks = 0; - uses++; - } - - - } - } - - public void reset() { - message = ""; - delayTicks = half = 0; - } - +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.PacketUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Arrays; +import java.util.List; + +public class Spammer extends Module { + private ButtonSetting spamBypass; + + private SliderSetting delay; + + public String message = ""; + private String bypass; + private int delayTicks, uses; + + public Spammer() { + super("Spammer", category.other); + //this.registerSetting(new DescriptionSetting("Usage:\" .spammer \"")); + this.registerSetting(delay = new SliderSetting("Delay", "s", 3, 0.5, 30, 0.5)); + this.registerSetting(spamBypass = new ButtonSetting("Spam bypass", false)); + } + + @Override + public void onEnable() { + reset(); + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + + if (uses == 0) { + bypass = "15L2QVJSHU95DPQZX3"; + } + else if (uses == 1) { + bypass = "LO4MDH1798JX5YQ935"; + } + else if (uses == 2) { + bypass = "987YQM6ND5AG01LFU3"; + } + else if (uses == 3) { + bypass = "83NMQJX5HQID83L32G"; + } + else if (uses == 4) { + bypass = "PL256GHBTNZQ38HJFM"; + } + else if (uses == 5) { + bypass = "LMP8B4GZ96BHMDU328"; + } + else if (uses >= 6) { + bypass = "OPF3HJ2K3J167YGUQW"; + uses = 0; + } + + if (!spamBypass.isToggled()) { + bypass = ""; + } + + if (!message.isEmpty()) { + ++delayTicks; + + if (delayTicks >= (delay.getInput() * 20)) { + mc.thePlayer.sendChatMessage(message + " " + bypass); + delayTicks = 0; + uses++; + } + + + } + } + + public void reset() { + delayTicks = 0; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/other/Test.java b/src/main/java/keystrokesmod/module/impl/other/Test.java index 24f7e14..4a7b8cd 100644 --- a/src/main/java/keystrokesmod/module/impl/other/Test.java +++ b/src/main/java/keystrokesmod/module/impl/other/Test.java @@ -1,47 +1,47 @@ -package keystrokesmod.module.impl.other; - -import com.mojang.authlib.GameProfile; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.GroupSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class Test extends Module { - public EntityOtherPlayerMP fakeEntity = null; - private ButtonSetting spawnDummy; - private GroupSetting groupSetting; - private SliderSetting testSlider; - private ButtonSetting test; - - public Test() { - super("Test", category.other); - this.registerSetting(spawnDummy = new ButtonSetting("Spawn dummy", true)); - this.registerSetting(groupSetting = new GroupSetting("Group")); - this.registerSetting(test = new ButtonSetting(groupSetting, "Test", true)); - this.registerSetting(testSlider = new SliderSetting(groupSetting, "Slider", 0, new String[] { "Option 1", "Option 2" } )); - } - - public void onEnable() { - if (spawnDummy.isToggled()) { - fakeEntity = new EntityOtherPlayerMP(mc.theWorld, new GameProfile(mc.thePlayer.getUniqueID(), "Dummy")); - fakeEntity.copyLocationAndAnglesFrom(mc.thePlayer); - mc.theWorld.addEntityToWorld(-8008, fakeEntity); - fakeEntity.inventory.armorInventory[0] = new ItemStack(Items.golden_helmet); - fakeEntity.setCurrentItemOrArmor(0, new ItemStack(Blocks.wool)); - } - } - - public void onDisable() { - if (fakeEntity != null) { - mc.theWorld.removeEntity(fakeEntity); - fakeEntity = null; - } - } -} +package keystrokesmod.module.impl.other; + +import com.mojang.authlib.GameProfile; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.GroupSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class Test extends Module { + public EntityOtherPlayerMP fakeEntity = null; + private ButtonSetting spawnDummy; + private GroupSetting groupSetting; + private SliderSetting testSlider; + private ButtonSetting test; + + public Test() { + super("Test", category.other); + this.registerSetting(spawnDummy = new ButtonSetting("Spawn dummy", true)); + this.registerSetting(groupSetting = new GroupSetting("Group")); + this.registerSetting(test = new ButtonSetting(groupSetting, "Test", true)); + this.registerSetting(testSlider = new SliderSetting(groupSetting, "Slider", 0, new String[] { "Option 1", "Option 2" } )); + } + + public void onEnable() { + if (spawnDummy.isToggled()) { + fakeEntity = new EntityOtherPlayerMP(mc.theWorld, new GameProfile(mc.thePlayer.getUniqueID(), "Dummy")); + fakeEntity.copyLocationAndAnglesFrom(mc.thePlayer); + mc.theWorld.addEntityToWorld(-8008, fakeEntity); + fakeEntity.inventory.armorInventory[0] = new ItemStack(Items.golden_helmet); + fakeEntity.setCurrentItemOrArmor(0, new ItemStack(Blocks.wool)); + } + } + + public void onDisable() { + if (fakeEntity != null) { + mc.theWorld.removeEntity(fakeEntity); + fakeEntity = null; + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/other/Timers.java b/src/main/java/keystrokesmod/module/impl/other/Timers.java new file mode 100644 index 0000000..c09d077 --- /dev/null +++ b/src/main/java/keystrokesmod/module/impl/other/Timers.java @@ -0,0 +1,167 @@ +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.*; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class Timers extends Module { + + private ButtonSetting consumables; + + public boolean isEnabled; + private int a, f1, f2; + private boolean d1, d2; + private int consumeTicks = -1, bot = -1; + private int consumeOffset, bo; + + public Timers() { + super("Timers", Module.category.other); + + this.registerSetting(consumables = new ButtonSetting("Consumables", true)); + + this.alwaysOn = true; + } + + + public void onEnable() { + isEnabled = true; + } + + public void onDisable() { + isEnabled = false; + } + + @SubscribeEvent + public void onPacketSent(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && isConsumable()) { + consumeTicks = 34; + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (mc.thePlayer.isUsingItem() && isConsumable()) { + if (f1 == 0) { + add(); + f1 = 1; + consumeOffset = handleX(); + } + if (consumeTicks > 1 && mc.thePlayer.ticksExisted % 2 == 0) { + consumeTicks = consumeTicks - 2; + } + d1 = true; + } + else if (d1) { + consumeTicks = -1; + resetA(); + f1 = 0; + d1 = false; + } + + /*if (ModuleManager.bhop.isEnabled()) { + if (f2 == 0) { + add(); + f2 = 1; + bo = handleX(); + } + if (bot <= 0) { + bot = 400; + } + if (bot > 1 && mc.thePlayer.ticksExisted % 2 == 0) { + bot = bot - 2; + } + d2 = true; + } + else if (d2) { + bot = -1; + resetA(); + f2 = 0; + d2 = false; + }*/ + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck() || !isEnabled) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + } + if (consumeTicks > -1 && consumables.isToggled()) { + handleTimer(consumeTicks, "6", consumeOffset); + } + if (bot > -1) { + handleTimer(bot, "c", bo); + } + } + + //(heldItem instanceof ItemBow && Utils.hasArrows(itemStack)) bow + + private boolean isConsumable() { + if (mc.thePlayer.getHeldItem() == null) { + return false; + } + Item heldItem = mc.thePlayer.getHeldItem().getItem(); + if (heldItem == null) { + return false; + } + if (heldItem instanceof ItemFood || heldItem instanceof ItemBucketMilk || (heldItem instanceof ItemPotion && !ItemPotion.isSplash(mc.thePlayer.getHeldItem().getItemDamage()))) { + return true; + } + return false; + } + + private void add() { + a++; + } + + private int handleX() { + int value = 0; + if (a == 1) { + value = 12; + } + else if (a == 2) { + value = 38; + } + return value; + } + + private void resetA() { + f1 = f2 = 0; + a = 0; + } + + private void handleTimer(int ticks, String colorcode, int wo) { + int color = Theme.getGradient((int) HUD.theme.getInput(), 0); + double s; + s = (double) ticks / 20; + int eo = (s >= 10 && wo == 12) ? 4 : 0; + int widthOffset = wo; + String text = ("§" + colorcode + s + "s"); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset + eo, display[1] / 2 + 8, color, true); + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/other/ViewPackets.java b/src/main/java/keystrokesmod/module/impl/other/ViewPackets.java index b0ee72b..14e0076 100644 --- a/src/main/java/keystrokesmod/module/impl/other/ViewPackets.java +++ b/src/main/java/keystrokesmod/module/impl/other/ViewPackets.java @@ -1,195 +1,195 @@ -package keystrokesmod.module.impl.other; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.SendAllPacketsEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.Entity; -import net.minecraft.event.HoverEvent; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.*; -import net.minecraft.util.*; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -public class ViewPackets extends Module { - private ButtonSetting includeCancelled; - private ButtonSetting singlePlayer; - private ButtonSetting sent; - private ButtonSetting ignoreC00; - private ButtonSetting ignoreC03; - private ButtonSetting compactC03; - private ButtonSetting ignoreC0F; - private ButtonSetting received; - private Packet packet; - public static long tick; - - public ViewPackets() { - super("View Packets", category.other); - this.registerSetting(includeCancelled = new ButtonSetting("Include cancelled", true)); - this.registerSetting(singlePlayer = new ButtonSetting("Singleplayer", false)); - this.registerSetting(sent = new ButtonSetting("Sent", false)); - this.registerSetting(ignoreC00 = new ButtonSetting("Ignore C00", false)); - this.registerSetting(ignoreC03 = new ButtonSetting("Ignore C03", false)); - this.registerSetting(compactC03 = new ButtonSetting("Compact C03", false)); - this.registerSetting(ignoreC0F = new ButtonSetting("Ignore C0F", false)); - this.registerSetting(received = new ButtonSetting("Received", false)); - } - - public void onDisable() { - packet = null; - tick = 0; - } - - private static String formatBoolean(final boolean b) { - return b ? "&atrue" : "&cfalse"; - } - - private void sendMessage(final Packet packet, final boolean b) { - if (!Utils.nullCheck()) { - return; - } - final String s = b ? ("&a" + packet.getClass().getSimpleName()) : applyInfo(packet); - final String string = ((compactC03.isToggled() && packet instanceof C03PacketPlayer) ? "&6" : "&d") + packet.getClass().getSimpleName(); - final ChatComponentText chatComponentText = new ChatComponentText(Utils.formatColor("&7[&dR&7]&r &7" + (b ? "Received" : "Sent") + " packet (t:&b" + mc.thePlayer.ticksExisted + "&7): ")); - final ChatStyle chatStyle = new ChatStyle(); - chatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(Utils.formatColor(s)))); - chatComponentText.appendSibling(new ChatComponentText(Utils.formatColor(string)).setChatStyle(chatStyle)); - mc.thePlayer.addChatMessage(chatComponentText); - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!sent.isToggled()) { - return; - } - if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'S') { - return; - } - if (e.isCanceled() && !includeCancelled.isToggled()) { - return; - } - if (ignoreC00.isToggled() && e.getPacket() instanceof C00PacketKeepAlive) { - return; - } - if (ignoreC0F.isToggled() && e.getPacket() instanceof C0FPacketConfirmTransaction) { - return; - } - if (e.getPacket() instanceof C03PacketPlayer && (ignoreC03.isToggled() || (compactC03.isToggled() && (packet == null || packet instanceof C03PacketPlayer)))) { - return; - } - sendMessage(packet = e.getPacket(), false); - } - - @SubscribeEvent - public void onSendAllPacketsEvent(SendAllPacketsEvent e) { - if (!sent.isToggled()) { - return; - } - if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'S') { - return; - } - if (e.isCanceled() && !includeCancelled.isToggled()) { - return; - } - if (ignoreC00.isToggled() && e.getPacket() instanceof C00PacketKeepAlive) { - return; - } - if (ignoreC0F.isToggled() && e.getPacket() instanceof C0FPacketConfirmTransaction) { - return; - } - if (e.getPacket() instanceof C03PacketPlayer && (ignoreC03.isToggled() || (compactC03.isToggled() && (packet == null || packet instanceof C03PacketPlayer)))) { - return; - } - sendMessage(packet = e.getPacket(), false); - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (!received.isToggled()) { - return; - } - if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'C') { - return; - } - sendMessage(e.getPacket(), true); - } - - private String applyInfo(final Packet packet) { - String s = "&a" + packet.getClass().getSimpleName(); - if (packet instanceof C07PacketPlayerDigging) { - final C07PacketPlayerDigging c07PacketPlayerDigging = (C07PacketPlayerDigging)packet; - final String string = s + "\n&7Status: &b" + c07PacketPlayerDigging.getStatus().name() + "\n&7Facing: &b" + c07PacketPlayerDigging.getFacing().name(); - final BlockPos getPosition = c07PacketPlayerDigging.getPosition(); - s = string + "\n&7Position: &b" + getPosition.getX() + "&7, &b" + getPosition.getY() + "&7, &b" + getPosition.getZ(); - } - else if (packet instanceof C09PacketHeldItemChange) { - s = s + "\n&7Swap to slot: &b" + ((C09PacketHeldItemChange)packet).getSlotId(); - } - else if (packet instanceof C0BPacketEntityAction) { - s = s + "\n&7Action: &b" + ((C0BPacketEntityAction)packet).getAction().name() + "\n&7Aux data: &b" + ((C0BPacketEntityAction)packet).getAuxData(); - } - else if (packet instanceof C08PacketPlayerBlockPlacement) { - final C08PacketPlayerBlockPlacement c08PacketPlayerBlockPlacement = (C08PacketPlayerBlockPlacement)packet; - final String string2 = s + "\n&7Item: &b" + ((c08PacketPlayerBlockPlacement.getStack() == null) ? "null" : c08PacketPlayerBlockPlacement.getStack().getItem().getRegistryName().replace("minecraft:", "")) + "\n&7Direction: &b" + c08PacketPlayerBlockPlacement.getPlacedBlockDirection(); - final BlockPos getPosition = c08PacketPlayerBlockPlacement.getPosition(); - s = string2 + "\n&7Position: &b" + getPosition.getX() + "&7, &b" + getPosition.getY() + "&7, &b" + getPosition.getZ() + "\n&7Offset: &b" + round((double)c08PacketPlayerBlockPlacement.getPlacedBlockOffsetX()) + "&7, &b" + round((double)c08PacketPlayerBlockPlacement.getPlacedBlockOffsetY()) + "&7, &b" + round(c08PacketPlayerBlockPlacement.getPlacedBlockOffsetZ()); - } - else if (packet instanceof C02PacketUseEntity) { - final C02PacketUseEntity c02PacketUseEntity = (C02PacketUseEntity)packet; - final String string3 = s + "\n&7Action: &b" + c02PacketUseEntity.getAction().name(); - final Entity getEntityFromWorld = c02PacketUseEntity.getEntityFromWorld(mc.theWorld); - final String string4 = string3 + "\n&7Target: &b" + ((getEntityFromWorld == null) ? "null" : getEntityFromWorld.getName()); - final Vec3 getHitVec = c02PacketUseEntity.getHitVec(); - if (getHitVec == null) { - s = string4 + "\n&7Hit vec: &bnull"; - } - else { - s = string4 + "\n&7Hit vec: &b" + round(getHitVec.xCoord) + "&7, &b" + round(getHitVec.yCoord) + "&7, &b" + round(getHitVec.zCoord); - } - } - else if (packet instanceof C01PacketChatMessage) { - s = s + "\n&7Length: &b" + ((C01PacketChatMessage)packet).getMessage().length(); - } - else if (packet instanceof C17PacketCustomPayload) { - s = s + "\n&7Channel: &b" + ((C17PacketCustomPayload)packet).getChannelName(); - } - else if (packet instanceof C15PacketClientSettings) { - s = s + "\n&7Language: &b" + ((C15PacketClientSettings)packet).getLang() + "\n&7Chat visibility: &b" + ((C15PacketClientSettings)packet).getChatVisibility().name(); - } - else if (packet instanceof C00PacketKeepAlive) { - s = s + "\n&7Key: &b" + ((C00PacketKeepAlive)packet).getKey(); - } - else if (packet instanceof C16PacketClientStatus) { - s = s + "\n&7Status: &b" + ((C16PacketClientStatus)packet).getStatus().name(); - } - else if (packet instanceof C10PacketCreativeInventoryAction) { - s = s + "\n&7Slot: &b" + ((C10PacketCreativeInventoryAction)packet).getSlotId() + "\n&7Item: &b" + ((((C10PacketCreativeInventoryAction)packet).getStack() == null) ? "null" : ((C10PacketCreativeInventoryAction)packet).getStack().getItem().getRegistryName().replace("minecraft:", "")); - } - else if (packet instanceof C0EPacketClickWindow) { - final C0EPacketClickWindow c0EPacketClickWindow = (C0EPacketClickWindow)packet; - s = s + "\n&7Window: &b" + c0EPacketClickWindow.getWindowId() + "\n&7Slot: &b" + c0EPacketClickWindow.getSlotId() + "\n&7Button: &b" + c0EPacketClickWindow.getUsedButton() + "\n&7Action: &b" + c0EPacketClickWindow.getActionNumber() + "\n&7Mode: &b" + c0EPacketClickWindow.getMode() + "\n&7Item: &b" + ((c0EPacketClickWindow.getClickedItem() == null) ? "null" : c0EPacketClickWindow.getClickedItem().getItem().getRegistryName().replace("minecraft:", "")); - } - else if (packet instanceof C0FPacketConfirmTransaction) { - s = s + "\n&7Window: &b" + ((C0FPacketConfirmTransaction)packet).getWindowId() + "\n&7Uid: &b" + ((C0FPacketConfirmTransaction)packet).getUid(); - } - else if (packet instanceof C03PacketPlayer) { - final C03PacketPlayer c03PacketPlayer = (C03PacketPlayer)packet; - s = s + "\n&7Position: &b" + round(c03PacketPlayer.getPositionX()) + "&7, &b" + round(c03PacketPlayer.getPositionY()) + "&7, &b" + round(c03PacketPlayer.getPositionZ()) + "\n&7Rotations: &b" + round((double)c03PacketPlayer.getYaw()) + "&7, &b" + round((double)c03PacketPlayer.getPitch()) + "\n&7Ground: " + formatBoolean(c03PacketPlayer.isOnGround()) + "\n&7Moving: " + formatBoolean(c03PacketPlayer.isMoving()) + "\n&7Rotating: " + formatBoolean(c03PacketPlayer.getRotating()); - } - return s + "\n&7Client tick: &e" + tick; - } - - private static double round(final double n) { - return Utils.round(n, 3); - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent e) { - if (e.phase == TickEvent.Phase.START) { - ++tick; - } - } +package keystrokesmod.module.impl.other; + +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.SendAllPacketsEvent; +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.Entity; +import net.minecraft.event.HoverEvent; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.*; +import net.minecraft.util.*; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class ViewPackets extends Module { + private ButtonSetting includeCancelled; + private ButtonSetting singlePlayer; + private ButtonSetting sent; + private ButtonSetting ignoreC00; + private ButtonSetting ignoreC03; + private ButtonSetting compactC03; + private ButtonSetting ignoreC0F; + private ButtonSetting received; + private Packet packet; + public static long tick; + + public ViewPackets() { + super("View Packets", category.other); + this.registerSetting(includeCancelled = new ButtonSetting("Include cancelled", true)); + this.registerSetting(singlePlayer = new ButtonSetting("Singleplayer", false)); + this.registerSetting(sent = new ButtonSetting("Sent", false)); + this.registerSetting(ignoreC00 = new ButtonSetting("Ignore C00", false)); + this.registerSetting(ignoreC03 = new ButtonSetting("Ignore C03", false)); + this.registerSetting(compactC03 = new ButtonSetting("Compact C03", false)); + this.registerSetting(ignoreC0F = new ButtonSetting("Ignore C0F", false)); + this.registerSetting(received = new ButtonSetting("Received", false)); + } + + public void onDisable() { + packet = null; + tick = 0; + } + + private static String formatBoolean(final boolean b) { + return b ? "&atrue" : "&cfalse"; + } + + private void sendMessage(final Packet packet, final boolean b) { + if (!Utils.nullCheck()) { + return; + } + final String s = b ? ("&a" + packet.getClass().getSimpleName()) : applyInfo(packet); + final String string = ((compactC03.isToggled() && packet instanceof C03PacketPlayer) ? "&6" : "&d") + packet.getClass().getSimpleName(); + final ChatComponentText chatComponentText = new ChatComponentText(Utils.formatColor("&7[&dR&7]&r &7" + (b ? "Received" : "Sent") + " packet (t:&b" + mc.thePlayer.ticksExisted + "&7): ")); + final ChatStyle chatStyle = new ChatStyle(); + chatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(Utils.formatColor(s)))); + chatComponentText.appendSibling(new ChatComponentText(Utils.formatColor(string)).setChatStyle(chatStyle)); + mc.thePlayer.addChatMessage(chatComponentText); + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (!sent.isToggled()) { + return; + } + if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'S') { + return; + } + if (e.isCanceled() && !includeCancelled.isToggled()) { + return; + } + if (ignoreC00.isToggled() && e.getPacket() instanceof C00PacketKeepAlive) { + return; + } + if (ignoreC0F.isToggled() && e.getPacket() instanceof C0FPacketConfirmTransaction) { + return; + } + if (e.getPacket() instanceof C03PacketPlayer && (ignoreC03.isToggled() || (compactC03.isToggled() && (packet == null || packet instanceof C03PacketPlayer)))) { + return; + } + sendMessage(packet = e.getPacket(), false); + } + + @SubscribeEvent + public void onSendAllPacketsEvent(SendAllPacketsEvent e) { + if (!sent.isToggled()) { + return; + } + if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'S') { + return; + } + if (e.isCanceled() && !includeCancelled.isToggled()) { + return; + } + if (ignoreC00.isToggled() && e.getPacket() instanceof C00PacketKeepAlive) { + return; + } + if (ignoreC0F.isToggled() && e.getPacket() instanceof C0FPacketConfirmTransaction) { + return; + } + if (e.getPacket() instanceof C03PacketPlayer && (ignoreC03.isToggled() || (compactC03.isToggled() && (packet == null || packet instanceof C03PacketPlayer)))) { + return; + } + sendMessage(packet = e.getPacket(), false); + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (!received.isToggled()) { + return; + } + if (singlePlayer.isToggled() && mc.isSingleplayer() && e.getPacket().getClass().getSimpleName().charAt(0) == 'C') { + return; + } + sendMessage(e.getPacket(), true); + } + + private String applyInfo(final Packet packet) { + String s = "&a" + packet.getClass().getSimpleName(); + if (packet instanceof C07PacketPlayerDigging) { + final C07PacketPlayerDigging c07PacketPlayerDigging = (C07PacketPlayerDigging)packet; + final String string = s + "\n&7Status: &b" + c07PacketPlayerDigging.getStatus().name() + "\n&7Facing: &b" + c07PacketPlayerDigging.getFacing().name(); + final BlockPos getPosition = c07PacketPlayerDigging.getPosition(); + s = string + "\n&7Position: &b" + getPosition.getX() + "&7, &b" + getPosition.getY() + "&7, &b" + getPosition.getZ(); + } + else if (packet instanceof C09PacketHeldItemChange) { + s = s + "\n&7Swap to slot: &b" + ((C09PacketHeldItemChange)packet).getSlotId(); + } + else if (packet instanceof C0BPacketEntityAction) { + s = s + "\n&7Action: &b" + ((C0BPacketEntityAction)packet).getAction().name() + "\n&7Aux data: &b" + ((C0BPacketEntityAction)packet).getAuxData(); + } + else if (packet instanceof C08PacketPlayerBlockPlacement) { + final C08PacketPlayerBlockPlacement c08PacketPlayerBlockPlacement = (C08PacketPlayerBlockPlacement)packet; + final String string2 = s + "\n&7Item: &b" + ((c08PacketPlayerBlockPlacement.getStack() == null) ? "null" : c08PacketPlayerBlockPlacement.getStack().getItem().getRegistryName().replace("minecraft:", "")) + "\n&7Direction: &b" + c08PacketPlayerBlockPlacement.getPlacedBlockDirection(); + final BlockPos getPosition = c08PacketPlayerBlockPlacement.getPosition(); + s = string2 + "\n&7Position: &b" + getPosition.getX() + "&7, &b" + getPosition.getY() + "&7, &b" + getPosition.getZ() + "\n&7Offset: &b" + round((double)c08PacketPlayerBlockPlacement.getPlacedBlockOffsetX()) + "&7, &b" + round((double)c08PacketPlayerBlockPlacement.getPlacedBlockOffsetY()) + "&7, &b" + round(c08PacketPlayerBlockPlacement.getPlacedBlockOffsetZ()); + } + else if (packet instanceof C02PacketUseEntity) { + final C02PacketUseEntity c02PacketUseEntity = (C02PacketUseEntity)packet; + final String string3 = s + "\n&7Action: &b" + c02PacketUseEntity.getAction().name(); + final Entity getEntityFromWorld = c02PacketUseEntity.getEntityFromWorld(mc.theWorld); + final String string4 = string3 + "\n&7Target: &b" + ((getEntityFromWorld == null) ? "null" : getEntityFromWorld.getName()); + final Vec3 getHitVec = c02PacketUseEntity.getHitVec(); + if (getHitVec == null) { + s = string4 + "\n&7Hit vec: &bnull"; + } + else { + s = string4 + "\n&7Hit vec: &b" + round(getHitVec.xCoord) + "&7, &b" + round(getHitVec.yCoord) + "&7, &b" + round(getHitVec.zCoord); + } + } + else if (packet instanceof C01PacketChatMessage) { + s = s + "\n&7Length: &b" + ((C01PacketChatMessage)packet).getMessage().length(); + } + else if (packet instanceof C17PacketCustomPayload) { + s = s + "\n&7Channel: &b" + ((C17PacketCustomPayload)packet).getChannelName(); + } + else if (packet instanceof C15PacketClientSettings) { + s = s + "\n&7Language: &b" + ((C15PacketClientSettings)packet).getLang() + "\n&7Chat visibility: &b" + ((C15PacketClientSettings)packet).getChatVisibility().name(); + } + else if (packet instanceof C00PacketKeepAlive) { + s = s + "\n&7Key: &b" + ((C00PacketKeepAlive)packet).getKey(); + } + else if (packet instanceof C16PacketClientStatus) { + s = s + "\n&7Status: &b" + ((C16PacketClientStatus)packet).getStatus().name(); + } + else if (packet instanceof C10PacketCreativeInventoryAction) { + s = s + "\n&7Slot: &b" + ((C10PacketCreativeInventoryAction)packet).getSlotId() + "\n&7Item: &b" + ((((C10PacketCreativeInventoryAction)packet).getStack() == null) ? "null" : ((C10PacketCreativeInventoryAction)packet).getStack().getItem().getRegistryName().replace("minecraft:", "")); + } + else if (packet instanceof C0EPacketClickWindow) { + final C0EPacketClickWindow c0EPacketClickWindow = (C0EPacketClickWindow)packet; + s = s + "\n&7Window: &b" + c0EPacketClickWindow.getWindowId() + "\n&7Slot: &b" + c0EPacketClickWindow.getSlotId() + "\n&7Button: &b" + c0EPacketClickWindow.getUsedButton() + "\n&7Action: &b" + c0EPacketClickWindow.getActionNumber() + "\n&7Mode: &b" + c0EPacketClickWindow.getMode() + "\n&7Item: &b" + ((c0EPacketClickWindow.getClickedItem() == null) ? "null" : c0EPacketClickWindow.getClickedItem().getItem().getRegistryName().replace("minecraft:", "")); + } + else if (packet instanceof C0FPacketConfirmTransaction) { + s = s + "\n&7Window: &b" + ((C0FPacketConfirmTransaction)packet).getWindowId() + "\n&7Uid: &b" + ((C0FPacketConfirmTransaction)packet).getUid(); + } + else if (packet instanceof C03PacketPlayer) { + final C03PacketPlayer c03PacketPlayer = (C03PacketPlayer)packet; + s = s + "\n&7Position: &b" + round(c03PacketPlayer.getPositionX()) + "&7, &b" + round(c03PacketPlayer.getPositionY()) + "&7, &b" + round(c03PacketPlayer.getPositionZ()) + "\n&7Rotations: &b" + round((double)c03PacketPlayer.getYaw()) + "&7, &b" + round((double)c03PacketPlayer.getPitch()) + "\n&7Ground: " + formatBoolean(c03PacketPlayer.isOnGround()) + "\n&7Moving: " + formatBoolean(c03PacketPlayer.isMoving()) + "\n&7Rotating: " + formatBoolean(c03PacketPlayer.getRotating()); + } + return s + "\n&7Client tick: &e" + tick; + } + + private static double round(final double n) { + return Utils.round(n, 3); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent e) { + if (e.phase == TickEvent.Phase.START) { + ++tick; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/AntiAFK.java b/src/main/java/keystrokesmod/module/impl/player/AntiAFK.java index 1e41271..4876275 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AntiAFK.java +++ b/src/main/java/keystrokesmod/module/impl/player/AntiAFK.java @@ -1,200 +1,219 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.settings.KeyBinding; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class AntiAFK extends Module { - private SliderSetting afk; - private ButtonSetting jump; - private ButtonSetting jumpWhenCollided; - private ButtonSetting randomClicks; - private ButtonSetting swapItem; - private SliderSetting spin; - private ButtonSetting randomizeDelta; - private ButtonSetting randomizePitch; - private SliderSetting minDelay; - private SliderSetting maxDelay; - private String[] afkModes = new String[]{"None", "Wander", "Lateral shuffle", "Forward", "Backward", "Lobby"}; - private String[] spinModes = new String[]{"None", "Random", "Right", "Left"}; - private int ticks, afkTicks; - private boolean c; - public boolean stop = false; - public AntiAFK() { - super("AntiAFK", category.player); - this.registerSetting(afk = new SliderSetting("AFK", 0, afkModes)); - this.registerSetting(jump = new ButtonSetting("Jump", false)); - this.registerSetting(jumpWhenCollided = new ButtonSetting("Jump only when collided", false)); - this.registerSetting(randomClicks = new ButtonSetting("Random clicks", false)); - this.registerSetting(swapItem = new ButtonSetting("Swap item", false)); - this.registerSetting(spin = new SliderSetting("Spin", 0, spinModes)); - this.registerSetting(randomizeDelta = new ButtonSetting("Randomize delta", true)); - this.registerSetting(randomizePitch = new ButtonSetting("Randomize pitch", true)); - this.registerSetting(minDelay = new SliderSetting("Minimum delay ticks", 10.0, 4.0, 160.0, 2.0)); - this.registerSetting(maxDelay = new SliderSetting("Maximum delay ticks", 80.0, 4.0, 160.0, 2.0)); - } - - public void onEnable() { - this.ticks = this.h(); - this.c = Utils.getRandom().nextBoolean(); - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!Utils.isMoving()) { - ++afkTicks; - } - else { - afkTicks = 0; - } - } - - public void onUpdate() { - if (stop) { - return; - } - if (mc.currentScreen != null && !(mc.currentScreen instanceof GuiChat)) { - return; - } - --this.ticks; - switch ((int) afk.getInput()) { - case 1: { - if (this.c) { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), Utils.getRandom().nextBoolean()); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), Utils.getRandom().nextBoolean()); - break; - } - KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), Utils.getRandom().nextBoolean()); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), Utils.getRandom().nextBoolean()); - break; - } - case 2: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), this.c); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), !this.c); - break; - } - case 3: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), true); - break; - } - case 4: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), true); - break; - } - case 5: { - if (afkTicks >= 1000) { - mc.thePlayer.capabilities.isFlying = false; - if (mc.thePlayer.onGround) { - mc.thePlayer.jump(); - } - afkTicks = 0; - } - break; - } - } - switch ((int) spin.getInput()) { - case 1: { - mc.thePlayer.rotationYaw += this.c(this.c); - this.d(); - break; - } - case 2: { - mc.thePlayer.rotationYaw += this.c(true); - this.d(); - break; - } - case 3: { - mc.thePlayer.rotationYaw += this.c(false); - this.d(); - break; - } - } - if (jump.isToggled() && mc.thePlayer.onGround && (!jumpWhenCollided.isToggled() || mc.thePlayer.isCollidedHorizontally)) { - mc.thePlayer.jump(); - } - if (this.ticks == 0) { - if (swapItem.isToggled()) { - mc.thePlayer.inventory.currentItem = Utils.randomizeInt(0, 8); - } - if (randomClicks.isToggled()) { - ((IAccessorMinecraft) mc).callClickMouse(); - } - this.ticks = this.h(); - this.c = !this.c; - } - } - - private double a() { - final int n = Utils.getRandom().nextBoolean() ? 1 : -1; - if (!randomizeDelta.isToggled()) { - return 2 * n; - } - double n2 = Utils.randomizeInt(100, 500) / 100.0; - if (n2 % 1.0 == 0.0) { - n2 += Utils.randomizeInt(1, 10) / 10.0 * n; - } - return n2 * n; - } - - public void onDisable() { - this.b(0); - stop = false; - } - - private void b(final int n) { - switch (n) { - case 1: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), false); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), false); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), false); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), false); - break; - } - case 2: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), false); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), false); - break; - } - case 3: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), false); - break; - } - case 4: { - KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), false); - break; - } - } - } - - private int h() { - if (minDelay.getInput() == maxDelay.getInput()) { - return (int)minDelay.getInput(); - } - return Utils.randomizeInt((int)minDelay.getInput(), (int) maxDelay.getInput()); - } - - private void d() { - if (randomizePitch.isToggled()) { - mc.thePlayer.rotationPitch = RotationUtils.clampPitch((float)(mc.thePlayer.rotationPitch + this.a())); - } - } - - private double c(final boolean b) { - final int n = b ? 1 : -1; - if (!randomizeDelta.isToggled()) { - return 3 * n; - } - double n2 = Utils.randomizeInt(100, 1000) / 100.0; - if (n2 % 1.0 == 0.0) { - n2 += Utils.randomizeInt(1, 10) / 10.0 * n; - } - return n2 * n; - } -} +package keystrokesmod.module.impl.player; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class AntiAFK extends Module { + private SliderSetting afk; + private ButtonSetting jump; + private ButtonSetting jumpWhenCollided; + private ButtonSetting randomClicks; + private ButtonSetting swapItem; + private SliderSetting spin; + private ButtonSetting randomizeDelta; + private ButtonSetting randomizePitch; + private SliderSetting minDelay; + private SliderSetting maxDelay; + private String[] afkModes = new String[]{"None", "Wander", "Lateral shuffle", "Forward", "Backward", "Lobby"}; + private String[] spinModes = new String[]{"None", "Random", "Right", "Left"}; + private int ticks, afkTicks; + private boolean c; + public boolean stop = false; + private boolean stopFlying; + private int sfTicks, randomDelay; + public AntiAFK() { + super("AntiAFK", category.player); + this.registerSetting(afk = new SliderSetting("AFK", 0, afkModes)); + this.registerSetting(jump = new ButtonSetting("Jump", false)); + this.registerSetting(jumpWhenCollided = new ButtonSetting("Jump only when collided", false)); + this.registerSetting(randomClicks = new ButtonSetting("Random clicks", false)); + this.registerSetting(swapItem = new ButtonSetting("Swap item", false)); + this.registerSetting(spin = new SliderSetting("Spin", 0, spinModes)); + this.registerSetting(randomizeDelta = new ButtonSetting("Randomize delta", true)); + this.registerSetting(randomizePitch = new ButtonSetting("Randomize pitch", true)); + this.registerSetting(minDelay = new SliderSetting("Minimum delay ticks", 10.0, 4.0, 160.0, 2.0)); + this.registerSetting(maxDelay = new SliderSetting("Maximum delay ticks", 80.0, 4.0, 160.0, 2.0)); + } + + public void onEnable() { + this.ticks = this.h(); + this.c = Utils.getRandom().nextBoolean(); + } + + public void onUpdate() { + if (stop) { + return; + } + if (mc.currentScreen != null && !(mc.currentScreen instanceof GuiChat)) { + return; + } + --this.ticks; + switch ((int) afk.getInput()) { + case 1: { + if (this.c) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), Utils.getRandom().nextBoolean()); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), Utils.getRandom().nextBoolean()); + break; + } + KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), Utils.getRandom().nextBoolean()); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), Utils.getRandom().nextBoolean()); + break; + } + case 2: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), this.c); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), !this.c); + break; + } + case 3: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), true); + break; + } + case 4: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), true); + break; + } + case 5: { + if (Utils.isMoving() || Utils.jumpDown()) { + if (sfTicks > 0 && !Utils.jumpDown()) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), false); + } + afkTicks = sfTicks = 0; + } + else { + ++afkTicks; + } + if (afkTicks >= 1000) { + if (mc.thePlayer.capabilities.isFlying) { + stopFlying = true; + } + else if (mc.thePlayer.onGround) { + mc.thePlayer.jump(); + } + afkTicks = 0; + } + if (stopFlying && ++sfTicks > -1) { + if (sfTicks == 1) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), true); + } + else if (sfTicks == 2) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), false); + } + else if (sfTicks == 4) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), true); + } + else if (sfTicks == 5) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKeyCode(), false); + sfTicks = 0; + stopFlying = false; + } + } + break; + } + } + switch ((int) spin.getInput()) { + case 1: { + mc.thePlayer.rotationYaw += this.c(this.c); + this.d(); + break; + } + case 2: { + mc.thePlayer.rotationYaw += this.c(true); + this.d(); + break; + } + case 3: { + mc.thePlayer.rotationYaw += this.c(false); + this.d(); + break; + } + } + if (jump.isToggled() && mc.thePlayer.onGround && (!jumpWhenCollided.isToggled() || mc.thePlayer.isCollidedHorizontally)) { + mc.thePlayer.jump(); + } + if (this.ticks == 0) { + if (swapItem.isToggled()) { + mc.thePlayer.inventory.currentItem = Utils.randomizeInt(0, 8); + } + if (randomClicks.isToggled()) { + ((IAccessorMinecraft) mc).callClickMouse(); + } + this.ticks = this.h(); + this.c = !this.c; + } + } + + private double a() { + final int n = Utils.getRandom().nextBoolean() ? 1 : -1; + if (!randomizeDelta.isToggled()) { + return 2 * n; + } + double n2 = Utils.randomizeInt(100, 500) / 100.0; + if (n2 % 1.0 == 0.0) { + n2 += Utils.randomizeInt(1, 10) / 10.0 * n; + } + return n2 * n; + } + + public void onDisable() { + this.b(0); + stop = false; + } + + private void b(final int n) { + switch (n) { + case 1: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), false); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), false); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), false); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), false); + break; + } + case 2: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), false); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindLeft.getKeyCode(), false); + break; + } + case 3: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), false); + break; + } + case 4: { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), false); + break; + } + } + } + + private int h() { + if (minDelay.getInput() == maxDelay.getInput()) { + return (int)minDelay.getInput(); + } + return Utils.randomizeInt((int)minDelay.getInput(), (int) maxDelay.getInput()); + } + + private void d() { + if (randomizePitch.isToggled()) { + mc.thePlayer.rotationPitch = RotationUtils.clampPitch((float)(mc.thePlayer.rotationPitch + this.a())); + } + } + + private double c(final boolean b) { + final int n = b ? 1 : -1; + if (!randomizeDelta.isToggled()) { + return 3 * n; + } + double n2 = Utils.randomizeInt(100, 1000) / 100.0; + if (n2 % 1.0 == 0.0) { + n2 += Utils.randomizeInt(1, 10) / 10.0 * n; + } + return n2 * n; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/player/AntiFireball.java b/src/main/java/keystrokesmod/module/impl/player/AntiFireball.java index 5390eb1..23ec2dc 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AntiFireball.java +++ b/src/main/java/keystrokesmod/module/impl/player/AntiFireball.java @@ -1,155 +1,155 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.event.ClientRotationEvent; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.entity.Entity; -import net.minecraft.entity.projectile.EntityFireball; -import net.minecraft.item.*; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Mouse; - -import java.util.HashSet; - -public class AntiFireball extends Module { - private SliderSetting fov; - private SliderSetting range; - private ButtonSetting disableWhileFlying; - private ButtonSetting disableWhileScaffold; - private ButtonSetting blocksRotate; - private ButtonSetting projectileRotate; - public ButtonSetting silentSwing; - - public EntityFireball fireball; - - private HashSet fireballs = new HashSet<>(); - - public boolean attack; - - public AntiFireball() { - super("AntiFireball", category.player); - this.registerSetting(fov = new SliderSetting("FOV", 360.0, 30.0, 360.0, 4.0)); - this.registerSetting(range = new SliderSetting("Range", 8.0, 3.0, 15.0, 0.5)); - this.registerSetting(disableWhileFlying = new ButtonSetting("Disable while flying", false)); - this.registerSetting(disableWhileScaffold = new ButtonSetting("Disable while scaffold", false)); - this.registerSetting(blocksRotate = new ButtonSetting("Rotate with blocks", false)); - this.registerSetting(projectileRotate = new ButtonSetting("Rotate with projectiles", false)); - this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void onClientRotation(ClientRotationEvent e) { - if (!condition() || stopAttack()) { - return; - } - if (fireball != null) { - final ItemStack getHeldItem = mc.thePlayer.getHeldItem(); - if (getHeldItem != null && getHeldItem.getItem() instanceof ItemBlock && !blocksRotate.isToggled() && Mouse.isButtonDown(1)) { - return; - } - if (getHeldItem != null && (getHeldItem.getItem() instanceof ItemBow || getHeldItem.getItem() instanceof ItemSnowball || getHeldItem.getItem() instanceof ItemEgg || getHeldItem.getItem() instanceof ItemFishingRod) && !projectileRotate.isToggled()) { - return; - } - if (ModuleManager.scaffold != null && ModuleManager.scaffold.stopRotation()) { - return; - } - float[] rotations = RotationUtils.getRotations(fireball, RotationUtils.prevRenderYaw, RotationUtils.prevRenderPitch); - e.setYaw(rotations[0]); - e.setPitch(rotations[1]); - } - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!condition() || stopAttack()) { - return; - } - if (fireball != null) { - if (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingServer && ModuleManager.killAura.blinkAutoBlock()) { - if (KillAura.target != null) { - attack = false; - return; - } - attack = true; - } - else { - Utils.attackEntity(fireball, !silentSwing.isToggled(), silentSwing.isToggled()); - } - } - } - - private EntityFireball getFireball() { - for (final Entity entity : mc.theWorld.loadedEntityList) { - if (!(entity instanceof EntityFireball)) { - continue; - } - if (!this.fireballs.contains(entity)) { - continue; - } - if (mc.thePlayer.getDistanceSqToEntity(entity) > range.getInput() * range.getInput()) { - continue; - } - final float n = (float) fov.getInput(); - if (n != 360.0f && !Utils.inFov(n, entity)) { - continue; - } - return (EntityFireball) entity; - } - return null; - } - - @SubscribeEvent - public void onEntityJoin(EntityJoinWorldEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (e.entity == mc.thePlayer) { - this.fireballs.clear(); - } else if (e.entity instanceof EntityFireball && mc.thePlayer.getDistanceSqToEntity(e.entity) > 16.0) { - this.fireballs.add(e.entity); - } - } - - public void onDisable() { - this.fireballs.clear(); - this.fireball = null; - this.attack = false; - } - - public void onUpdate() { - if (!condition()) { - return; - } - if (mc.currentScreen != null) { - attack = false; - fireball = null; - return; - } - fireball = this.getFireball(); - } - - private boolean stopAttack() { - return (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && ModuleManager.bedAura.currentBlock != null) || (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && KillAura.attackingEntity != null); - } - - private boolean condition() { - if (!Utils.nullCheck()) { - return false; - } - if (mc.thePlayer.capabilities.isFlying && disableWhileFlying.isToggled()) { - return false; - } - if (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled() && disableWhileScaffold.isToggled()) { - return false; - } - return true; - } +package keystrokesmod.module.impl.player; + +import keystrokesmod.event.ClientRotationEvent; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.KillAura; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.item.*; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Mouse; + +import java.util.HashSet; + +public class AntiFireball extends Module { + private SliderSetting fov; + private SliderSetting range; + private ButtonSetting disableWhileFlying; + private ButtonSetting disableWhileScaffold; + private ButtonSetting blocksRotate; + private ButtonSetting projectileRotate; + public ButtonSetting silentSwing; + + public EntityFireball fireball; + + private HashSet fireballs = new HashSet<>(); + + public boolean attack; + + public AntiFireball() { + super("AntiFireball", category.player); + this.registerSetting(fov = new SliderSetting("FOV", 360.0, 30.0, 360.0, 4.0)); + this.registerSetting(range = new SliderSetting("Range", 8.0, 3.0, 15.0, 0.5)); + this.registerSetting(disableWhileFlying = new ButtonSetting("Disable while flying", false)); + this.registerSetting(disableWhileScaffold = new ButtonSetting("Disable while scaffold", false)); + this.registerSetting(blocksRotate = new ButtonSetting("Rotate with blocks", false)); + this.registerSetting(projectileRotate = new ButtonSetting("Rotate with projectiles", false)); + this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onClientRotation(ClientRotationEvent e) { + if (!condition() || stopAttack()) { + return; + } + if (fireball != null) { + final ItemStack getHeldItem = mc.thePlayer.getHeldItem(); + if (getHeldItem != null && getHeldItem.getItem() instanceof ItemBlock && !blocksRotate.isToggled() && Mouse.isButtonDown(1)) { + return; + } + if (getHeldItem != null && (getHeldItem.getItem() instanceof ItemBow || getHeldItem.getItem() instanceof ItemSnowball || getHeldItem.getItem() instanceof ItemEgg || getHeldItem.getItem() instanceof ItemFishingRod) && !projectileRotate.isToggled()) { + return; + } + if (ModuleManager.scaffold != null && ModuleManager.scaffold.stopRotation()) { + return; + } + float[] rotations = RotationUtils.getRotations(fireball, RotationUtils.prevRenderYaw, RotationUtils.prevRenderPitch); + e.setYaw(rotations[0]); + e.setPitch(rotations[1]); + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!condition() || stopAttack()) { + return; + } + if (fireball != null) { + if (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blockingServer && ModuleManager.killAura.autoBlockOverride()) { + if (KillAura.target != null) { + attack = false; + return; + } + attack = true; + } + else { + Utils.attackEntity(fireball, !silentSwing.isToggled(), silentSwing.isToggled()); + } + } + } + + private EntityFireball getFireball() { + for (final Entity entity : mc.theWorld.loadedEntityList) { + if (!(entity instanceof EntityFireball)) { + continue; + } + if (!this.fireballs.contains(entity)) { + continue; + } + if (mc.thePlayer.getDistanceSqToEntity(entity) > range.getInput() * range.getInput()) { + continue; + } + final float n = (float) fov.getInput(); + if (n != 360.0f && !Utils.inFov(n, entity)) { + continue; + } + return (EntityFireball) entity; + } + return null; + } + + @SubscribeEvent + public void onEntityJoin(EntityJoinWorldEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.entity == mc.thePlayer) { + this.fireballs.clear(); + } else if (e.entity instanceof EntityFireball && mc.thePlayer.getDistanceSqToEntity(e.entity) > 16.0) { + this.fireballs.add(e.entity); + } + } + + public void onDisable() { + this.fireballs.clear(); + this.fireball = null; + this.attack = false; + } + + public void onUpdate() { + if (!condition()) { + return; + } + if (mc.currentScreen != null) { + attack = false; + fireball = null; + return; + } + fireball = this.getFireball(); + } + + private boolean stopAttack() { + return (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && ModuleManager.bedAura.currentBlock != null) || (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && KillAura.attackingEntity != null); + } + + private boolean condition() { + if (!Utils.nullCheck()) { + return false; + } + if (mc.thePlayer.capabilities.isFlying && disableWhileFlying.isToggled()) { + return false; + } + if (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled() && disableWhileScaffold.isToggled()) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/AntiVoid.java b/src/main/java/keystrokesmod/module/impl/player/AntiVoid.java index a75cfe0..1ecbff2 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AntiVoid.java +++ b/src/main/java/keystrokesmod/module/impl/player/AntiVoid.java @@ -1,564 +1,475 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.Raven; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.event.ReceiveAllPacketsEvent; -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.*; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.network.Packet; -import net.minecraft.network.handshake.client.C00Handshake; -import net.minecraft.network.login.client.C00PacketLoginStart; -import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.network.play.client.C0FPacketConfirmTransaction; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.concurrent.ConcurrentLinkedQueue; - -public class AntiVoid extends Module { - private static SliderSetting distance; - private ButtonSetting renderTimer, disableLJ, disablePractice; - public ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - private int color = new Color(0, 187, 255, 255).getRGB(); - public int blinkTicks; - public boolean started, wait; - public double y; - public AntiVoid() { - super("AntiVoid", category.player); - this.registerSetting(distance = new SliderSetting("Distance", "", 5, 1, 10, 0.5)); - this.registerSetting(renderTimer = new ButtonSetting("Render Timer", false)); - this.registerSetting(disableLJ = new ButtonSetting("Disable with Long Jump", false)); - this.registerSetting(disablePractice = new ButtonSetting("Disable in Practice", false)); - } - - @Override - public void onEnable() { - blinkedPackets.clear(); - } - - public void onDisable() { - release(); - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - Packet packet = e.getPacket(); - if (!started && (!Utils.overVoid() || mc.thePlayer.onGround)) { - y = mc.thePlayer.posY; - wait = false; - return; - } - if (!started && (Utils.isReplay() || Utils.spectatorCheck() || Utils.isBedwarsPractice() && disablePractice.isToggled())) { - return; - } - if (mc.thePlayer.ticksExisted <= 10) { - return; - } - if (packet.getClass().getSimpleName().startsWith("S")) { - return; - } - if (ModuleManager.noFall.isBlinking) { - return; - } - if (wait) { - return; - } - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { - return; - } - if (!e.isCanceled()) { - started = true; - - if (ModuleManager.blink.isEnabled()) { - return; - } - - blinkedPackets.add(packet); - KillAura.blinkOn = true; - e.setCanceled(true); - } - } - - @Override - public String getInfo() { - return blinkTicks + ""; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - - if (!Utils.overVoid() || mc.thePlayer.onGround) { - release(); - } - if (dist() && Utils.overVoid() || disableLJ.isToggled() && LongJump.function) { - release(); - wait = true; - } - else if (started) { - ++blinkTicks; - - if (ModuleManager.blink.isEnabled()) { - return; - } - - if (mc.thePlayer.posY <= y - distance.getInput()) { - posPacket(); - release(); - wait = true; - } - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck() || !renderTimer.isToggled() || blinkTicks == 0 || blinkTicks >= 99999 || ModuleManager.blink.isEnabled()) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - } - Utils.handleTimer(color, blinkTicks); - } - - public void posPacket() { - PacketUtils.sendPacketNoEvent(new C03PacketPlayer.C06PacketPlayerPosLook(mc.thePlayer.posX, -0.55, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, mc.thePlayer.onGround)); - } - - public void release() { - if (!ModuleManager.blink.isEnabled()) { - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } - blinkedPackets.clear(); - blinkTicks = 0; - started = false; - if (!ModuleManager.blink.isEnabled()) { - KillAura.blinkOn = KillAura.blinkChecked = false; - } - } - - public boolean dist() { - double minMotion = 0.1; - int dist1 = 4; - int dist2 = 6; - int dist3 = 7; - int dist4 = 9; - // 1x1 - - if (mc.thePlayer.isCollidedHorizontally) { - return false; - } - - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ) > dist1) { - return true; - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ) > dist1) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ) > dist1) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 1) > dist1) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 1) > dist1) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 1) > dist1) { - if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 1) > dist1) { - if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 1) > dist1) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 1) > dist1) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - - // 2x2 - - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ) > dist2) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ) > dist2) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 2) > dist2) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 2) > dist2) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 1) > dist2) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 2) > dist2) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 1) > dist2) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 2) > dist2) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 2) > dist2) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 2) > dist2) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 2) > dist2) { - if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 2) > dist2) { - if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - - // 3x3 - - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 1) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 2) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 1) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 2) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 1) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 2) > dist3) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 3) > dist3) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 1) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 2) > dist3) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 3) > dist3) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - - // 4x4 - - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 3) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 2) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 1) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 3) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 2) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 1) > dist4) { - if (mc.thePlayer.motionX >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 4) > dist4) { - if (mc.thePlayer.motionZ >= minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 3) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 2) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 1) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 3) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 2) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 1) > dist4) { - if (mc.thePlayer.motionX <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 4) > dist4) { - if (mc.thePlayer.motionZ <= -minMotion) { - return true; - } - } - - - - - - return false; - } - +package keystrokesmod.module.impl.player; + +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.movement.LongJump; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class AntiVoid extends Module { + private static SliderSetting distance; + private ButtonSetting disableLJ, disablePractice; + public ButtonSetting renderTimer; + public boolean wait; + public double y; + + public boolean blink, setPos; + + public AntiVoid() { + super("AntiVoid", category.player); + this.registerSetting(distance = new SliderSetting("Distance", "", 5, 1, 10, 0.5)); + this.registerSetting(renderTimer = new ButtonSetting("Render Timer", false)); + this.registerSetting(disableLJ = new ButtonSetting("Disable with Long Jump", false)); + this.registerSetting(disablePractice = new ButtonSetting("Disable in Practice", false)); + } + + public void onDisable() { + blink = setPos = false; + } + + @Override + public String getInfo() { + return BlinkHandler.blinkTicks + ""; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + + handle(); + + if (!Utils.overVoid() || mc.thePlayer.onGround) { + setPos = false; + blink = false; + } + if (dist() && Utils.overVoid() || disableLJ.isToggled() && LongJump.function) { + setPos = false; + blink = false; + wait = true; + } + else if (blink) { + if (mc.thePlayer.posY <= y - distance.getInput()) { + setPos = true; + blink = false; + wait = true; + } + } + } + + private void handle() { + if (!blink && (!Utils.overVoid() || mc.thePlayer.onGround)) { + y = mc.thePlayer.posY; + wait = false; + return; + } + if (!blink && (Utils.isReplay() || Utils.spectatorCheck() || Utils.isBedwarsPractice() && disablePractice.isToggled())) { + return; + } + if (mc.thePlayer.ticksExisted <= 10) { + return; + } + if (wait) { + return; + } + blink = true; + } + + public boolean dist() { + double minMotion = 0.12; + int dist1 = 4; + int dist2 = 6; + int dist3 = 7; + int dist4 = 9; + // 1x1 + + if (mc.thePlayer.isCollidedHorizontally) { + return false; + } + + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ) > dist1) { + return true; + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ) > dist1) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ) > dist1) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 1) > dist1) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 1) > dist1) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 1) > dist1) { + if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 1) > dist1) { + if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 1) > dist1) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 1) > dist1) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + + // 2x2 + + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ) > dist2) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ) > dist2) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 2) > dist2) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 2) > dist2) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 1) > dist2) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 2) > dist2) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 1) > dist2) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 2) > dist2) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 2) > dist2) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 2) > dist2) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 2) > dist2) { + if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 2) > dist2) { + if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + + // 3x3 + + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 1) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 2) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 1) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 2) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 1) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ - 2) > dist3) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ - 3) > dist3) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 1) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 2) > dist3) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 3) > dist3) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + + // 4x4 + + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionX >= minMotion && mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionX <= -minMotion && mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 3) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 2) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ + 1) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 3, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 2, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 1, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 3) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 2) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX + 4, (int) mc.thePlayer.posZ - 1) > dist4) { + if (mc.thePlayer.motionX >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ + 4) > dist4) { + if (mc.thePlayer.motionZ >= minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 3) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 2) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ + 1) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 3) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 2) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 4, (int) mc.thePlayer.posZ - 1) > dist4) { + if (mc.thePlayer.motionX <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 3, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 2, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + if (Utils.distanceToGround(mc.thePlayer, (int) mc.thePlayer.posX - 1, (int) mc.thePlayer.posZ - 4) > dist4) { + if (mc.thePlayer.motionZ <= -minMotion) { + return true; + } + } + + + + + + return false; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/AutoPlace.java b/src/main/java/keystrokesmod/module/impl/player/AutoPlace.java index bde9209..64bd16b 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AutoPlace.java +++ b/src/main/java/keystrokesmod/module/impl/player/AutoPlace.java @@ -1,5 +1,6 @@ package keystrokesmod.module.impl.player; +import keystrokesmod.event.PreUpdateEvent; import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; @@ -23,13 +24,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.input.Mouse; public class AutoPlace extends Module { + private SliderSetting mode; private SliderSetting frameDelay; private SliderSetting minPlaceDelay; private ButtonSetting disableLeft; private ButtonSetting holdRight; private ButtonSetting fastPlaceOnJump; private ButtonSetting pitchCheck; - private ButtonSetting silentSwing; private double cachedFrameDelay = 0.0D; private long lastPlace = 0L; @@ -37,16 +38,18 @@ public class AutoPlace extends Module { private MovingObjectPosition lastRayTrace = null; private BlockPos lastBlockPos = null; + private String[] modes = new String[] { "Post", "Multi-place" }; + public AutoPlace() { super("AutoPlace", category.player); this.registerSetting(new DescriptionSetting("Best with safewalk.")); + //this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); this.registerSetting(frameDelay = new SliderSetting("Frame delay", 8.0D, 0.0D, 30.0D, 1.0D)); this.registerSetting(minPlaceDelay = new SliderSetting("Min place delay", 60.0, 25.0, 500.0, 5.0)); - this.registerSetting(disableLeft = new ButtonSetting("Disable left", false)); - this.registerSetting(holdRight = new ButtonSetting("Hold right", true)); + this.registerSetting(disableLeft = new ButtonSetting("Disable if LMB down", false)); + this.registerSetting(holdRight = new ButtonSetting("RMB required", true)); this.registerSetting(fastPlaceOnJump = new ButtonSetting("Fast place on jump", true)); this.registerSetting(pitchCheck = new ButtonSetting("Pitch check", false)); - this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); } public void guiUpdate() { @@ -88,25 +91,19 @@ public class AutoPlace extends Module { if (!Utils.nullCheck()) { return; } - if (mc.currentScreen != null || mc.thePlayer.capabilities.isFlying) { - return; - } - ItemStack heldItem = mc.thePlayer.getHeldItem(); - if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock)) { - return; - } - if (disableLeft.isToggled() && Mouse.isButtonDown(0)) { - return; - } - MovingObjectPosition mouseOverResult = mc.objectMouseOver; - if (mouseOverResult == null || mouseOverResult.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mouseOverResult.sideHit == EnumFacing.UP || mouseOverResult.sideHit == EnumFacing.DOWN) { + if (!conditions()) { return; } + //if (mode.getInput() != 0) { + //return; + //} if (this.lastRayTrace != null && (double) this.frameCount < frameDelay.getInput()) { this.frameCount++; return; } + MovingObjectPosition mouseOverResult = mc.objectMouseOver; + ItemStack heldItem = mc.thePlayer.getHeldItem(); this.lastRayTrace = mouseOverResult; BlockPos currentBlockPosition = mouseOverResult.getBlockPos(); @@ -118,9 +115,6 @@ public class AutoPlace extends Module { if (targetBlock == null || targetBlock == Blocks.air || targetBlock instanceof BlockLiquid) { return; } - if (holdRight.isToggled() && !Mouse.isButtonDown(1)) { - return; - } long currentTime = System.currentTimeMillis(); if (currentTime - this.lastPlace < minPlaceDelay.getInput()) { return; @@ -128,13 +122,8 @@ public class AutoPlace extends Module { this.lastPlace = currentTime; if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, heldItem, currentBlockPosition, mouseOverResult.sideHit, mouseOverResult.hitVec)) { ReflectionUtils.setButton(1, true); - if (silentSwing.isToggled()) { - mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); - } - else { - mc.thePlayer.swingItem(); - mc.getItemRenderer().resetEquippedProgress(); - } + mc.thePlayer.swingItem(); + mc.getItemRenderer().resetEquippedProgress(); ReflectionUtils.setButton(1, false); this.lastBlockPos = currentBlockPosition; @@ -150,4 +139,28 @@ public class AutoPlace extends Module { this.lastRayTrace = null; this.frameCount = 0; } + + private boolean conditions() { + MovingObjectPosition mouseOverResult = mc.objectMouseOver; + ItemStack heldItem = mc.thePlayer.getHeldItem(); + if (mc.currentScreen != null || mc.thePlayer.capabilities.isFlying) { + return false; + } + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock)) { + return false; + } + if (disableLeft.isToggled() && Mouse.isButtonDown(0)) { + return false; + } + if (mouseOverResult == null || mouseOverResult.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mouseOverResult.sideHit == EnumFacing.UP || mouseOverResult.sideHit == EnumFacing.DOWN) { + return false; + } + if (holdRight.isToggled() && !Mouse.isButtonDown(1)) { + return false; + } + if (ModuleManager.scaffold.isEnabled) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/AutoSwap.java b/src/main/java/keystrokesmod/module/impl/player/AutoSwap.java index a17fac4..9b2ea0b 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AutoSwap.java +++ b/src/main/java/keystrokesmod/module/impl/player/AutoSwap.java @@ -1,27 +1,29 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; - -public class AutoSwap extends Module { - public ButtonSetting sameType; - public ButtonSetting spoofItem; - public ButtonSetting swapToGreaterStack; - public SliderSetting swapAt; - - public AutoSwap() { - super("AutoSwap", category.player); - this.registerSetting(new DescriptionSetting("Automatically swaps blocks.")); - this.registerSetting(sameType = new ButtonSetting("Only same type", false)); - this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); - this.registerSetting(swapToGreaterStack = new ButtonSetting("Swap to greater stack", true)); - this.registerSetting(swapAt = new SliderSetting("Swap at", " blocks", 3, 1, 7, 1)); - this.canBeEnabled = false; - } - - public void guiUpdate() { - this.swapAt.setVisible(!swapToGreaterStack.isToggled(), this); - } +package keystrokesmod.module.impl.player; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; + +public class AutoSwap extends Module { + public ButtonSetting sameType; + public ButtonSetting spoofItem; + public ButtonSetting swapToGreaterStack; + public SliderSetting swapAt; + public ButtonSetting legit; + + public AutoSwap() { + super("AutoSwap", category.player); + this.registerSetting(new DescriptionSetting("Automatically swaps blocks.")); + this.registerSetting(sameType = new ButtonSetting("Only same type", false)); + this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); + this.registerSetting(swapToGreaterStack = new ButtonSetting("Swap to greater stack", true)); + this.registerSetting(swapAt = new SliderSetting("Swap at", " blocks", 3, 1, 7, 1)); + this.registerSetting(legit = new ButtonSetting("Legit", false)); + this.canBeEnabled = false; + } + + public void guiUpdate() { + this.swapAt.setVisible(!swapToGreaterStack.isToggled(), this); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/AutoTool.java b/src/main/java/keystrokesmod/module/impl/player/AutoTool.java index 63ccc99..3bb40ad 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AutoTool.java +++ b/src/main/java/keystrokesmod/module/impl/player/AutoTool.java @@ -1,122 +1,122 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.Raven; -import keystrokesmod.mixin.interfaces.IMixinItemRenderer; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.util.MovingObjectPosition; -import org.lwjgl.input.Mouse; - -public class AutoTool extends Module { - private SliderSetting hoverDelay; - private SliderSetting swapDelay; - - private ButtonSetting rightDisable; - private ButtonSetting requireCrouch; - private ButtonSetting requireMouse; - public ButtonSetting spoofItem; - private ButtonSetting swapBack; - - private boolean hasSwapped = false; - private int swapDelayTick = 0; - public int previousSlot = -1; - private long ticksHovered; - - public AutoTool() { - super("AutoTool", category.player); - this.registerSetting(hoverDelay = new SliderSetting("Hover delay", 0.0, 0.0, 20.0, 1.0)); - this.registerSetting(swapDelay = new SliderSetting("Swap delay", 0, 0, 20, 1)); - this.registerSetting(rightDisable = new ButtonSetting("Disable while right click", true)); - this.registerSetting(requireCrouch = new ButtonSetting("Only while crouching", false)); - this.registerSetting(requireMouse = new ButtonSetting("Require mouse down", true)); - this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); - this.registerSetting(swapBack = new ButtonSetting("Swap to previous slot", true)); - this.closetModule = true; - } - - public void onDisable() { - resetVariables(true); - } - - public void setSlot(int currentItem) { - if (currentItem == -1 || currentItem == mc.thePlayer.inventory.currentItem) { - return; - } - mc.thePlayer.inventory.currentItem = currentItem; - hasSwapped = true; - swapDelayTick = (int) swapDelay.getInput(); - } - - - public void onUpdate() { - if (spoofItem.isToggled() && previousSlot != mc.thePlayer.inventory.currentItem && previousSlot != -1) { - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7Modifying held item renderer"); - } - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); - } - if (!mc.inGameHasFocus || mc.currentScreen != null || (rightDisable.isToggled() && Mouse.isButtonDown(1)) || !mc.thePlayer.capabilities.allowEdit || (requireCrouch.isToggled() && !mc.thePlayer.isSneaking())) { - resetVariables(false); - return; - } - if (!Mouse.isButtonDown(0) && requireMouse.isToggled()) { - resetSlot(); - return; - } - MovingObjectPosition over = mc.objectMouseOver; - if (over == null || over.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { - resetSlot(); - resetVariables(true); - return; - } - if (hoverDelay.getInput() != 0) { - long ticks = this.ticksHovered + 1L; - this.ticksHovered = ticks; - if (ticks < hoverDelay.getInput()) { - return; - } - } - int slot = Utils.getTool(BlockUtils.getBlock(over.getBlockPos())); - if (slot == -1) { - return; - } - if (previousSlot == -1) { - previousSlot = mc.thePlayer.inventory.currentItem; - } - if (!hasSwapped) { - setSlot(slot); - } - else if (slot != mc.thePlayer.inventory.currentItem) { - if (swapDelayTick-- <= 0) { - if (mc.thePlayer.inventory.currentItem != slot) { - setSlot(slot); - swapDelayTick = (int) swapDelay.getInput(); - } - } - } - } - - private void resetVariables(boolean resetHover) { - if (resetHover) { - ticksHovered = 0; - } - resetSlot(); - previousSlot = -1; - hasSwapped = false; - swapDelayTick = 0; - } - - private void resetSlot() { - if (previousSlot == -1 || !swapBack.isToggled()) { - return; - } - setSlot(previousSlot); - previousSlot = -1; - hasSwapped = false; - swapDelayTick = 0; - } -} +package keystrokesmod.module.impl.player; + +import keystrokesmod.Raven; +import keystrokesmod.mixin.interfaces.IMixinItemRenderer; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.util.MovingObjectPosition; +import org.lwjgl.input.Mouse; + +public class AutoTool extends Module { + private SliderSetting hoverDelay; + private SliderSetting swapDelay; + + private ButtonSetting rightDisable; + private ButtonSetting requireCrouch; + private ButtonSetting requireMouse; + public ButtonSetting spoofItem; + private ButtonSetting swapBack; + + private boolean hasSwapped = false; + private int swapDelayTick = 0; + public int previousSlot = -1; + private long ticksHovered; + + public AutoTool() { + super("AutoTool", category.player); + this.registerSetting(hoverDelay = new SliderSetting("Hover delay", 0.0, 0.0, 20.0, 1.0)); + this.registerSetting(swapDelay = new SliderSetting("Swap delay", 0, 0, 20, 1)); + this.registerSetting(rightDisable = new ButtonSetting("Disable while right click", true)); + this.registerSetting(requireCrouch = new ButtonSetting("Only while crouching", false)); + this.registerSetting(requireMouse = new ButtonSetting("Require mouse down", true)); + this.registerSetting(spoofItem = new ButtonSetting("Spoof item", false)); + this.registerSetting(swapBack = new ButtonSetting("Swap to previous slot", true)); + this.closetModule = true; + } + + public void onDisable() { + resetVariables(true); + } + + public void setSlot(int currentItem) { + if (currentItem == -1 || currentItem == mc.thePlayer.inventory.currentItem) { + return; + } + mc.thePlayer.inventory.currentItem = currentItem; + hasSwapped = true; + swapDelayTick = (int) swapDelay.getInput(); + } + + + public void onUpdate() { + if (spoofItem.isToggled() && previousSlot != mc.thePlayer.inventory.currentItem && previousSlot != -1) { + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7Modifying held item renderer"); + } + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); + } + if (!mc.inGameHasFocus || mc.currentScreen != null || (rightDisable.isToggled() && Mouse.isButtonDown(1)) || !mc.thePlayer.capabilities.allowEdit || (requireCrouch.isToggled() && !mc.thePlayer.isSneaking())) { + resetVariables(false); + return; + } + if (!Mouse.isButtonDown(0) && requireMouse.isToggled()) { + resetSlot(); + return; + } + MovingObjectPosition over = mc.objectMouseOver; + if (over == null || over.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + resetSlot(); + resetVariables(true); + return; + } + if (hoverDelay.getInput() != 0) { + long ticks = this.ticksHovered + 1L; + this.ticksHovered = ticks; + if (ticks < hoverDelay.getInput()) { + return; + } + } + int slot = Utils.getTool(BlockUtils.getBlock(over.getBlockPos())); + if (slot == -1) { + return; + } + if (previousSlot == -1) { + previousSlot = mc.thePlayer.inventory.currentItem; + } + if (!hasSwapped) { + setSlot(slot); + } + else if (slot != mc.thePlayer.inventory.currentItem) { + if (swapDelayTick-- <= 0) { + if (mc.thePlayer.inventory.currentItem != slot) { + setSlot(slot); + swapDelayTick = (int) swapDelay.getInput(); + } + } + } + } + + private void resetVariables(boolean resetHover) { + if (resetHover) { + ticksHovered = 0; + } + resetSlot(); + previousSlot = -1; + hasSwapped = false; + swapDelayTick = 0; + } + + private void resetSlot() { + if (previousSlot == -1 || !swapBack.isToggled()) { + return; + } + setSlot(previousSlot); + previousSlot = -1; + hasSwapped = false; + swapDelayTick = 0; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/player/BedAura.java b/src/main/java/keystrokesmod/module/impl/player/BedAura.java index 68e49a1..d77206e 100644 --- a/src/main/java/keystrokesmod/module/impl/player/BedAura.java +++ b/src/main/java/keystrokesmod/module/impl/player/BedAura.java @@ -5,6 +5,7 @@ import keystrokesmod.event.*; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.impl.minigames.BedWars; +import keystrokesmod.module.impl.movement.LongJump; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.utility.*; @@ -14,6 +15,7 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.network.Packet; import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; import net.minecraft.network.play.client.C0APacketAnimation; @@ -65,6 +67,7 @@ public class BedAura extends Module { private BlockPos rotateLastBlock; private boolean spoofGround, firstStop; private boolean isBreaking, startPacket, stopPacket, ignoreSlow, delayStop; + private boolean ra; public BedAura() { super("BedAura", category.player, 0); @@ -93,11 +96,7 @@ public class BedAura extends Module { public void onDisable() { reset(true, true); bedPos = null; - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) // takes priority over ka & antifireball - public void onPreUpdate(PreUpdateEvent e) { - + ra = false; } @SubscribeEvent @@ -128,6 +127,10 @@ public class BedAura extends Module { if (!Utils.nullCheck()) { return; } + if (ra) { + //setRots(e); + ra = false; + } if (delayStop) { delayStop = false; } else { @@ -177,7 +180,7 @@ public class BedAura extends Module { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPreMotion(PreMotionEvent e) { if (stopAutoblock) { @@ -186,13 +189,18 @@ public class BedAura extends Module { } } - if (groundSpoof.isToggled() && !mc.thePlayer.isInWater() && spoofGround) { + if (!mc.thePlayer.isInWater() && spoofGround) { e.setOnGround(true); if (Raven.debug) { Utils.sendModuleMessage(this, "&7ground spoof (&3" + mc.thePlayer.ticksExisted + "&7)."); } } + spoofGround = false; + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onPreUpdate(PreUpdateEvent e) { if (startPacket) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, packetPos, EnumFacing.UP)); swing(); @@ -211,7 +219,7 @@ public class BedAura extends Module { swing(); } - startPacket = stopPacket = spoofGround = false; + startPacket = stopPacket = false; } @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -244,6 +252,18 @@ public class BedAura extends Module { return cancelKnockback.isToggled() && currentBlock != null && RotationUtils.inRange(currentBlock, range.getInput()); } + @SubscribeEvent + public void onReceivePacketAll(ReceiveAllPacketsEvent e) { + if (!cancelKnockback() || e.isCanceled()) { + return; + } + if (e.getPacket() instanceof S12PacketEntityVelocity) { + if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { + e.setCanceled(true); + } + } + } + private BlockPos[] getBedPos() { int range; priority: @@ -393,7 +413,11 @@ public class BedAura extends Module { isBreaking = true; breakTick = true; - ignoreSlow = true; + if (mc.thePlayer.motionY >= -0.4D && groundSpoof.isToggled()) { + ignoreSlow = true; + spoofGround = true; + } + ra = true; } private void stopBreak(ClientRotationEvent e, BlockPos blockPos) { @@ -406,6 +430,7 @@ public class BedAura extends Module { spoofGround = true; } ignoreSlow = false; + ra = true; } private void swing() { diff --git a/src/main/java/keystrokesmod/module/impl/player/Blink.java b/src/main/java/keystrokesmod/module/impl/player/Blink.java index 33e15d3..a4cae39 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Blink.java +++ b/src/main/java/keystrokesmod/module/impl/player/Blink.java @@ -1,208 +1,79 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.Raven; -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.ModuleUtils; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.network.Packet; -import net.minecraft.network.handshake.client.C00Handshake; -import net.minecraft.network.login.client.C00PacketLoginStart; -import net.minecraft.network.login.client.C01PacketEncryptionResponse; -import net.minecraft.network.play.client.C00PacketKeepAlive; -import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.client.C0FPacketConfirmTransaction; -import net.minecraft.network.play.server.*; -import net.minecraft.network.status.client.C00PacketServerQuery; -import net.minecraft.network.status.client.C01PacketPing; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.Objects; -import java.util.concurrent.ConcurrentLinkedQueue; - -import static keystrokesmod.module.impl.render.HUD.theme; - -public class Blink extends Module { - private static SliderSetting maximumBlinkTicks; - private ButtonSetting initialPosition; - private ButtonSetting renderTimer; - private ButtonSetting disableOnBreak, disableOnAttack; - public ButtonSetting cancelKnockback; - private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - private Vec3 pos; - //final private int color = Theme.getGradient((int) theme.getInput(), 255); - private int color = new Color(0, 187, 255, 255).getRGB(); - private int blinkTicks; - public boolean started; - - public Blink() { - super("Blink", category.player); - this.registerSetting(maximumBlinkTicks = new SliderSetting("Max Blink Ticks", "", 0, 0, 40, 1)); - this.registerSetting(new DescriptionSetting("0 = no max")); - this.registerSetting(initialPosition = new ButtonSetting("Show initial position", true)); - this.registerSetting(renderTimer = new ButtonSetting("Render Timer", false)); - this.registerSetting(disableOnBreak = new ButtonSetting("Disable on Break", false)); - this.registerSetting(disableOnAttack = new ButtonSetting("Disable on Attack", false)); - this.registerSetting(cancelKnockback = new ButtonSetting("Cancel knockback", false)); - } - - @Override - public void onEnable() { - blinkedPackets.clear(); - pos = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); - } - - public void onDisable() { - if (ModuleManager.antiVoid.started) { - if (mc.thePlayer.posY <= ModuleManager.antiVoid.y - 3) { - ModuleManager.antiVoid.posPacket(); - } - ModuleManager.antiVoid.wait = true; - ModuleManager.antiVoid.started = false; - ModuleManager.antiVoid.blinkedPackets.clear(); - ModuleManager.antiVoid.blinkTicks = 0; - } - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - blinkedPackets.clear(); - pos = null; - blinkTicks = 0; - started = false; - - KillAura.blinkOn = KillAura.blinkChecked = false; - } - - @SubscribeEvent - public void onSendPacketAll(SendAllPacketsEvent e) { - if (!Utils.nullCheck()) { - this.disable(); - return; - } - if (disableOnBreak.isToggled() && (Utils.usingBedAura() || ModuleUtils.isBreaking)) { - disable(); - return; - } - Packet packet = e.getPacket(); - if (packet.getClass().getSimpleName().startsWith("S")) { - return; - } - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { - return; - } - if (disableOnAttack.isToggled() && packet instanceof C02PacketUseEntity || blinkTicks >= 99999) { - blinkTicks = 99999; - return; - } - if (!e.isCanceled()) { - started = true; - blinkedPackets.add(packet); - KillAura.blinkOn = true; - e.setCanceled(true); - } - } - - - @SubscribeEvent - public void onReceivePacketAll(ReceiveAllPacketsEvent e) { - if (!Utils.nullCheck() || e.isCanceled() || !cancelKnockback.isToggled()) { - return; - } - if (e.getPacket() instanceof S12PacketEntityVelocity) { - if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { - blinkedPackets.add(e.getPacket()); - e.setCanceled(true); - } - } - } - - @Override - public String getInfo() { - return blinkTicks + ""; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (started) ++blinkTicks; - - if (maximumBlinkTicks.getInput() != 0) { - if (blinkTicks >= maximumBlinkTicks.getInput()) { - disable(); - } - } - if (blinkTicks >= 99999) { - disable(); - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck() || !renderTimer.isToggled() || blinkTicks == 0 || blinkTicks >= 99999) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - } - Utils.handleTimer(color, blinkTicks); - } - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent e) { - if (!Utils.nullCheck() || pos == null || !initialPosition.isToggled()) { - return; - } - drawBox(pos); - } - - private void drawBox(Vec3 pos) { - GlStateManager.pushMatrix(); - color = Theme.getGradient((int) HUD.theme.getInput(), 0); - double x = pos.xCoord - mc.getRenderManager().viewerPosX; - double y = pos.yCoord - mc.getRenderManager().viewerPosY; - double z = pos.zCoord - mc.getRenderManager().viewerPosZ; - AxisAlignedBB bbox = mc.thePlayer.getEntityBoundingBox().expand(0.1D, 0.1, 0.1); - AxisAlignedBB axis = new AxisAlignedBB(bbox.minX - mc.thePlayer.posX + x, bbox.minY - mc.thePlayer.posY + y, bbox.minZ - mc.thePlayer.posZ + z, bbox.maxX - mc.thePlayer.posX + x, bbox.maxY - mc.thePlayer.posY + y, bbox.maxZ - mc.thePlayer.posZ + z); - float a = (float) (color >> 24 & 255) / 255.0F; - float r = (float) (color >> 16 & 255) / 255.0F; - float g = (float) (color >> 8 & 255) / 255.0F; - float b = (float) (color & 255) / 255.0F; - GL11.glBlendFunc(770, 771); - GL11.glEnable(3042); - GL11.glDisable(3553); - GL11.glDisable(2929); - GL11.glDepthMask(false); - GL11.glLineWidth(2.0F); - GL11.glColor4f(r, g, b, a); - RenderUtils.drawBoundingBox(axis, r, g, b); - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDepthMask(true); - GL11.glDisable(3042); - GlStateManager.popMatrix(); - } -} - +package keystrokesmod.module.impl.player; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.KillAura; +import keystrokesmod.module.impl.movement.LongJump; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.network.Packet; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.login.client.C01PacketEncryptionResponse; +import net.minecraft.network.play.client.C00PacketKeepAlive; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; +import net.minecraft.network.play.server.*; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Objects; +import java.util.concurrent.ConcurrentLinkedQueue; + +import static keystrokesmod.module.impl.render.HUD.theme; + +public class Blink extends Module { + private static SliderSetting inf, maximumBlinkTicks; + public ButtonSetting renderTimer, initialPosition; + private ButtonSetting disableOnBreak, disableOnAttack; + private int color = new Color(0, 187, 255, 255).getRGB(); + public boolean blink; + + public Blink() { + super("Blink", category.player); + this.registerSetting(maximumBlinkTicks = new SliderSetting("Maximum duration", "s", 0.00, 0.00, 10.00, 0.1)); + this.registerSetting(initialPosition = new ButtonSetting("Show initial position", true)); + this.registerSetting(renderTimer = new ButtonSetting("Render Timer", false)); + this.registerSetting(disableOnBreak = new ButtonSetting("Disable on Break", false)); + this.registerSetting(disableOnAttack = new ButtonSetting("Disable on Attack", false)); + } + + public void onDisable() { + blink = false; + } + + @SubscribeEvent + public void onSendPacketAll(SendAllPacketsEvent e) { + if (disableOnBreak.isToggled() && (Utils.usingBedAura() || ModuleUtils.isBreaking)) { + disable(); + } + if (disableOnAttack.isToggled() && e.getPacket() instanceof C02PacketUseEntity) { + disable(); + } + if (maximumBlinkTicks.getInput() != 0 && BlinkHandler.blinkTicks > (maximumBlinkTicks.getInput() * 20)) { + disable(); + } + blink = true; + } + + @Override + public String getInfo() { + return BlinkHandler.blinkTicks + ""; + } +} + diff --git a/src/main/java/keystrokesmod/module/impl/player/Disabler.java b/src/main/java/keystrokesmod/module/impl/player/Disabler.java index bfc960c..5dec76d 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Disabler.java +++ b/src/main/java/keystrokesmod/module/impl/player/Disabler.java @@ -1,218 +1,218 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.Utils; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.network.play.client.C0BPacketEntityAction; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.awt.*; -import java.util.Objects; - -public class Disabler extends Module { - private SliderSetting disablerTicks; - private SliderSetting activationDelay; - private ButtonSetting resetDisabler; - - int tickCounter = 0; - boolean waitingForGround = false; - boolean applyingMotion = false; - int stateTickCounter = 0; - boolean warningDisplayed = false; - int sprintToggleTick = 0; - boolean shouldRun = false; - long lobbyTime = 0; - long finished = 0; - long activationDelayMillis; - final long checkDisabledTime = 4000; - private int color = new Color(0, 187, 255, 255).getRGB(); - private float barWidth = 60; - private float barHeight = 4; - private float filledWidth; - private float barX; - private float barY; - private boolean shouldRender; - private double firstY; - private boolean reset; - private float savedYaw, savedPitch; - private boolean worldJoin; - private int wDelay; - - public boolean disablerLoaded, running; - - public Disabler() { - super("Disabler", category.player); - this.registerSetting(disablerTicks = new SliderSetting("Ticks", "", 100, 85, 150, 5)); - this.registerSetting(activationDelay = new SliderSetting("Activation delay", " seconds", 0, 0, 4, 0.5)); - this.registerSetting(resetDisabler = new ButtonSetting("§cReset", false)); - } - - public void onEnable() { - if (!disablerLoaded) { - resetState(); - } - } - - public void onDisable() { - shouldRun = false; - running = false; - } - - private void resetState() { - savedYaw = mc.thePlayer.rotationYaw; - savedPitch = mc.thePlayer.rotationPitch; - shouldRun = true; - tickCounter = 0; - applyingMotion = false; - waitingForGround = true; - stateTickCounter = 0; - warningDisplayed = false; - running = false; - sprintToggleTick = 0; - lobbyTime = Utils.time(); - finished = 0; - shouldRender = false; - reset = false; - worldJoin = false; - activationDelayMillis = (long)(activationDelay.getInput() * 1000); - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - resetState(); - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onPreMotion(PreMotionEvent e) { - if (resetDisabler.isToggled()) { - Utils.print("&7[&dR&7] &cdisabler resetting..."); - resetState(); - disablerLoaded = false; - resetDisabler.disable(); - } - if (Utils.getLobbyStatus() == 1 || Utils.hypixelStatus() != 1 || Utils.isReplay()) { - return; - } - long now = System.currentTimeMillis(); - if (finished != 0 && mc.thePlayer.onGround && now - finished > checkDisabledTime) { - Utils.print("&7[&dR&7] &adisabler enabled"); - finished = 0; - filledWidth = 0; - disablerLoaded = true; - } - if (!shouldRun) { - return; - } - - if ((now - lobbyTime) < activationDelayMillis) { - return; - } - running = true; - e.setRotations(0, savedPitch); - - if (waitingForGround) { - /*if (mc.thePlayer.ticksExisted <= 3) { - waitingForGround = false; - worldJoin = true; - wDelay = 0; - } - else */if (mc.thePlayer.onGround) { - mc.thePlayer.motionY = 0.42f; - waitingForGround = false; - worldJoin = false; - } - return; - } - - if (ModuleUtils.inAirTicks >= 10 || worldJoin && ++wDelay >= 3) { - if (!applyingMotion) { - applyingMotion = true; - firstY = mc.thePlayer.posY; - } - - if (tickCounter < disablerTicks.getInput()) { - shouldRender = true; - - mc.thePlayer.motionX = 0; - mc.thePlayer.motionY = 0; - mc.thePlayer.motionZ = 0; - - if (mc.thePlayer.posY != firstY) { - if (!reset) { - resetState(); - activationDelayMillis = 2000; - reset = true; - Utils.print("&7[&dR&7] &adisabler reset, wait 2s"); - } - else { - shouldRun = false; - applyingMotion = false; - running = false; - Utils.print("&7[&dR&7] &cfailed to reset disabler, re-enable to try again"); - } - } - - if (mc.thePlayer.ticksExisted % 2 == 0) { - e.setPosZ(e.getPosZ() + 0.075); - e.setPosX(e.getPosX() + 0.075); - } - - tickCounter++; - } else if (!warningDisplayed) { - double totalTimeSeconds = (now - lobbyTime) / 1000.0; - warningDisplayed = true; - finished = now; - shouldRender = false; - shouldRun = false; - applyingMotion = false; - running = false; - } - } - - filledWidth = (float)(barWidth * tickCounter / disablerTicks.getInput()); - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int[] disp = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; - barX = disp[0] / 2 - barWidth / 2; - barY = disp[1] / 2 + 12; - } - - @SubscribeEvent() - public void onMoveInput(PrePlayerInputEvent e) { - if (!running || Utils.isReplay() || Utils.spectatorCheck()) { - return; - } - e.setForward(0); - e.setStrafe(0); - mc.thePlayer.movementInput.jump = false; - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck()) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null || !shouldRun || !shouldRender) { - return; - } - } - color = Theme.getGradient((int) HUD.theme.getInput(), 0); - RenderUtils.drawRoundedRectangle(barX, barY, barX + barWidth, barY + barHeight, 3, 0xFF555555); - RenderUtils.drawRoundedRectangle(barX, barY, barX + filledWidth, barY + barHeight, 3, color); - } +package keystrokesmod.module.impl.player; + +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.awt.*; +import java.util.Objects; + +public class Disabler extends Module { + private SliderSetting disablerTicks; + private SliderSetting activationDelay; + private ButtonSetting resetDisabler; + + int tickCounter = 0; + boolean waitingForGround = false; + boolean applyingMotion = false; + int stateTickCounter = 0; + boolean warningDisplayed = false; + int sprintToggleTick = 0; + boolean shouldRun = false; + long lobbyTime = 0; + long finished = 0; + long activationDelayMillis; + final long checkDisabledTime = 4000; + private int color = new Color(0, 187, 255, 255).getRGB(); + private float barWidth = 60; + private float barHeight = 4; + private float filledWidth; + private float barX; + private float barY; + private boolean shouldRender; + private double firstY; + private boolean reset; + private float savedYaw, savedPitch; + private boolean worldJoin; + private int wDelay; + + public boolean disablerLoaded, running; + + public Disabler() { + super("Disabler", category.player); + this.registerSetting(disablerTicks = new SliderSetting("Ticks", "", 100, 85, 150, 5)); + this.registerSetting(activationDelay = new SliderSetting("Activation delay", " seconds", 0, 0, 4, 0.5)); + this.registerSetting(resetDisabler = new ButtonSetting("§cReset", false)); + } + + public void onEnable() { + if (!disablerLoaded) { + resetState(); + } + } + + public void onDisable() { + shouldRun = false; + running = false; + } + + private void resetState() { + savedYaw = mc.thePlayer.rotationYaw; + savedPitch = mc.thePlayer.rotationPitch; + shouldRun = true; + tickCounter = 0; + applyingMotion = false; + waitingForGround = true; + stateTickCounter = 0; + warningDisplayed = false; + running = false; + sprintToggleTick = 0; + lobbyTime = Utils.time(); + finished = 0; + shouldRender = false; + reset = false; + worldJoin = false; + activationDelayMillis = (long)(activationDelay.getInput() * 1000); + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + resetState(); + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPreMotion(PreMotionEvent e) { + if (resetDisabler.isToggled()) { + Utils.modulePrint("&7[&dR&7] &cdisabler resetting..."); + resetState(); + disablerLoaded = false; + resetDisabler.disable(); + } + if (Utils.getLobbyStatus() == 1 || Utils.hypixelStatus() != 1 || Utils.isReplay()) { + return; + } + long now = System.currentTimeMillis(); + if (finished != 0 && mc.thePlayer.onGround && now - finished > checkDisabledTime) { + Utils.modulePrint("&7[&dR&7] &adisabler enabled"); + finished = 0; + filledWidth = 0; + disablerLoaded = true; + } + if (!shouldRun) { + return; + } + + if ((now - lobbyTime) < activationDelayMillis) { + return; + } + running = true; + e.setRotations(0, savedPitch); + + if (waitingForGround) { + /*if (mc.thePlayer.ticksExisted <= 3) { + waitingForGround = false; + worldJoin = true; + wDelay = 0; + } + else */if (mc.thePlayer.onGround) { + mc.thePlayer.motionY = 0.42f; + waitingForGround = false; + worldJoin = false; + } + return; + } + + if (ModuleUtils.inAirTicks >= 10 || worldJoin && ++wDelay >= 3) { + if (!applyingMotion) { + applyingMotion = true; + firstY = mc.thePlayer.posY; + } + + if (tickCounter < disablerTicks.getInput()) { + shouldRender = true; + + mc.thePlayer.motionX = 0; + mc.thePlayer.motionY = 0; + mc.thePlayer.motionZ = 0; + + if (mc.thePlayer.posY != firstY) { + if (!reset) { + resetState(); + activationDelayMillis = 2000; + reset = true; + Utils.modulePrint("&7[&dR&7] &adisabler reset, wait 2s"); + } + else { + shouldRun = false; + applyingMotion = false; + running = false; + Utils.modulePrint("&7[&dR&7] &cfailed to reset disabler, re-enable to try again"); + } + } + + if (mc.thePlayer.ticksExisted % 2 == 0) { + e.setPosZ(e.getPosZ() + 0.075); + e.setPosX(e.getPosX() + 0.075); + } + + tickCounter++; + } else if (!warningDisplayed) { + double totalTimeSeconds = (now - lobbyTime) / 1000.0; + warningDisplayed = true; + finished = now; + shouldRender = false; + shouldRun = false; + applyingMotion = false; + running = false; + } + } + + filledWidth = (float)(barWidth * tickCounter / disablerTicks.getInput()); + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] disp = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + barX = disp[0] / 2 - barWidth / 2; + barY = disp[1] / 2 + 12; + } + + @SubscribeEvent() + public void onMoveInput(PrePlayerInputEvent e) { + if (!running || Utils.isReplay() || Utils.spectatorCheck()) { + return; + } + e.setForward(0); + e.setStrafe(0); + mc.thePlayer.movementInput.jump = false; + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck()) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null || !shouldRun || !shouldRender) { + return; + } + } + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + RenderUtils.drawRoundedRectangle(barX, barY, barX + barWidth, barY + barHeight, 3, 0xFF555555); + RenderUtils.drawRoundedRectangle(barX, barY, barX + filledWidth, barY + barHeight, 3, color); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/FakeLag.java b/src/main/java/keystrokesmod/module/impl/player/FakeLag.java index a8ba4b9..f84d617 100644 --- a/src/main/java/keystrokesmod/module/impl/player/FakeLag.java +++ b/src/main/java/keystrokesmod/module/impl/player/FakeLag.java @@ -1,123 +1,123 @@ -package keystrokesmod.module.impl.player; - -import java.util.*; -import java.util.concurrent.*; - -import keystrokesmod.event.SendPacketEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.network.Packet; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -public class FakeLag extends Module { - public SliderSetting packetDelaySlider; - private ConcurrentSkipListMap>> packetQueue = new ConcurrentSkipListMap<>(); - private Timer timer; - private long packetDelay; - - public FakeLag() { - super("Fake Lag", category.player, 0); - this.registerSetting(packetDelaySlider = new SliderSetting("Packet delay", "ms", 0.0, 0.0, 1500.0, 20.0)); - } - - @Override - public String getInfo() { - return packetDelay + "ms"; - } - - @Override - public void guiUpdate() { - if (packetDelay != packetDelaySlider.getInput()) { - if (this.isEnabled()) { - this.onDisable(); - } - packetDelay = (int) packetDelaySlider.getInput(); - } - } - - @Override - public void onEnable() { - if (mc.isSingleplayer()) { - Utils.sendMessage("&cFake lag cannot be enabled in singleplayer."); - this.disable(); - return; - } - if (ModuleManager.blink.isEnabled()) { - Utils.sendMessage("&cCannot use fake lag with blink!"); - this.disable(); - return; - } - (timer = new Timer()).scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - updatePacketQueue(false); - } - }, 0L, 10L); - } - - @Override - public void onDisable() { - if (timer != null) { - timer.cancel(); - timer.purge(); - timer = null; - } - updatePacketQueue(true); - } - - private void updatePacketQueue(boolean flush) { - if (packetQueue.isEmpty()) { - return; - } - if (flush) { - for (Map.Entry>> entry : packetQueue.entrySet()) { - for (Packet packet : entry.getValue()) { - PacketUtils.sendPacketNoEvent(packet); - } - } - packetQueue.clear(); - } - else { - long now = System.currentTimeMillis(); - Iterator>>> it = packetQueue.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry>> entry2 = it.next(); - if (now < entry2.getKey()) { - break; - } - for (Packet packet2 : entry2.getValue()) { - PacketUtils.sendPacketNoEvent(packet2); - } - it.remove(); - } - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPacketSent(SendPacketEvent e) { - if (!Utils.nullCheck() || mc.isSingleplayer() || (int) packetDelaySlider.getInput() == 0 || e.isCanceled()) { - return; - } - long time = System.currentTimeMillis() + (int) packetDelaySlider.getInput(); - List> packetList = packetQueue.get(time); - if (packetList == null) { - packetList = new ArrayList<>(); - } - packetList.add(e.getPacket()); - packetQueue.put(time, packetList); - e.setCanceled(true); - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent e) { - if (mc.theWorld == null) { - packetQueue.clear(); - this.disable(); - } - } +package keystrokesmod.module.impl.player; + +import java.util.*; +import java.util.concurrent.*; + +import keystrokesmod.event.SendPacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.PacketUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.network.Packet; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class FakeLag extends Module { + public SliderSetting packetDelaySlider; + private ConcurrentSkipListMap>> packetQueue = new ConcurrentSkipListMap<>(); + private Timer timer; + private long packetDelay; + + public FakeLag() { + super("Fake Lag", category.player, 0); + this.registerSetting(packetDelaySlider = new SliderSetting("Packet delay", "ms", 0.0, 0.0, 1500.0, 20.0)); + } + + @Override + public String getInfo() { + return packetDelay + "ms"; + } + + @Override + public void guiUpdate() { + if (packetDelay != packetDelaySlider.getInput()) { + if (this.isEnabled()) { + this.onDisable(); + } + packetDelay = (int) packetDelaySlider.getInput(); + } + } + + @Override + public void onEnable() { + if (mc.isSingleplayer()) { + Utils.sendMessage("&cFake lag cannot be enabled in singleplayer."); + this.disable(); + return; + } + if (ModuleManager.blink.isEnabled()) { + Utils.sendMessage("&cCannot use fake lag with blink!"); + this.disable(); + return; + } + (timer = new Timer()).scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + updatePacketQueue(false); + } + }, 0L, 10L); + } + + @Override + public void onDisable() { + if (timer != null) { + timer.cancel(); + timer.purge(); + timer = null; + } + updatePacketQueue(true); + } + + private void updatePacketQueue(boolean flush) { + if (packetQueue.isEmpty()) { + return; + } + if (flush) { + for (Map.Entry>> entry : packetQueue.entrySet()) { + for (Packet packet : entry.getValue()) { + PacketUtils.sendPacketNoEvent(packet); + } + } + packetQueue.clear(); + } + else { + long now = System.currentTimeMillis(); + Iterator>>> it = packetQueue.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry>> entry2 = it.next(); + if (now < entry2.getKey()) { + break; + } + for (Packet packet2 : entry2.getValue()) { + PacketUtils.sendPacketNoEvent(packet2); + } + it.remove(); + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPacketSent(SendPacketEvent e) { + if (!Utils.nullCheck() || mc.isSingleplayer() || (int) packetDelaySlider.getInput() == 0 || e.isCanceled()) { + return; + } + long time = System.currentTimeMillis() + (int) packetDelaySlider.getInput(); + List> packetList = packetQueue.get(time); + if (packetList == null) { + packetList = new ArrayList<>(); + } + packetList.add(e.getPacket()); + packetQueue.put(time, packetList); + e.setCanceled(true); + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent e) { + if (mc.theWorld == null) { + packetQueue.clear(); + this.disable(); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/FastMine.java b/src/main/java/keystrokesmod/module/impl/player/FastMine.java index b59fded..d0b9952 100644 --- a/src/main/java/keystrokesmod/module/impl/player/FastMine.java +++ b/src/main/java/keystrokesmod/module/impl/player/FastMine.java @@ -1,92 +1,92 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.mixin.impl.accessor.IAccessorPlayerControllerMP; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.input.Mouse; - -public class FastMine extends Module { - private SliderSetting delay; - public SliderSetting multiplier; - private SliderSetting mode; - private ButtonSetting creativeDisable; - private float lastCurBlockDamageMP; - private String[] modes = new String[] { "Pre", "Post", "Increment" }; - - public FastMine() { - super("FastMine", category.player); - this.registerSetting(new DescriptionSetting("Vanilla is 5 delay & 1x speed.")); - this.registerSetting(delay = new SliderSetting("Break delay", " tick", 5.0, 0.0, 5.0, 1.0)); - this.registerSetting(multiplier = new SliderSetting("Break speed", "x", 1.0, 1.0, 2.0, 0.02)); - this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); - this.registerSetting(creativeDisable = new ButtonSetting("Disable in creative", true)); - this.closetModule = true; - } - - @Override - public String getInfo() { - return ((int) multiplier.getInput() == multiplier.getInput() ? (int) multiplier.getInput() + "" : multiplier.getInput()) + multiplier.getSuffix(); - } - - @SubscribeEvent - public void onPlayerTick(TickEvent.PlayerTickEvent e) { - if (e.phase != TickEvent.Phase.END || !mc.inGameHasFocus || !Utils.nullCheck()) { - return; - } - if (creativeDisable.isToggled() && mc.thePlayer.capabilities.isCreativeMode) { - return; - } - int delay = (int) this.delay.getInput(); - if (delay < 5.0) { - if (delay == 0) { - ((IAccessorPlayerControllerMP) mc.playerController).setBlockHitDelay(0); - } - else if (((IAccessorPlayerControllerMP) mc.playerController).getBlockHitDelay() > delay) { - ((IAccessorPlayerControllerMP) mc.playerController).setBlockHitDelay(delay); - } - } - double multiplierInput = multiplier.getInput(); - if (multiplierInput > 1.0) { - if (!mc.thePlayer.capabilities.isCreativeMode && Mouse.isButtonDown(0)) { - float curBlockDamage = ((IAccessorPlayerControllerMP) mc.playerController).getCurBlockDamageMP(); - switch ((int) mode.getInput()) { - case 0: - float damage = (float) (1.0 - 1.0 / multiplierInput); - if (curBlockDamage > 0.0f && curBlockDamage < damage) { - ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(damage); - break; - } - break; - case 1: - double extra = 1.0 / multiplierInput; - if (curBlockDamage < 1.0f && curBlockDamage >= extra) { - ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(1); - break; - } - break; - case 2: - float damage2 = -1.0f; - if (curBlockDamage < 1.0f) { - if (mc.objectMouseOver != null && curBlockDamage > this.lastCurBlockDamageMP) { - damage2 = (float) (this.lastCurBlockDamageMP + BlockUtils.getBlockHardness(mc.theWorld.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock(), mc.thePlayer.inventory.getStackInSlot(mc.thePlayer.inventory.currentItem), false, false) * (multiplierInput - 0.2152857 * (multiplierInput - 1.0))); - } - if (damage2 != -1.0f && curBlockDamage > 0.0f) { - ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(damage2); - } - } - this.lastCurBlockDamageMP = curBlockDamage; - break; - } - } - else if (mode.getInput() == 2) { - this.lastCurBlockDamageMP = 0.0f; - } - } - } -} +package keystrokesmod.module.impl.player; + +import keystrokesmod.mixin.impl.accessor.IAccessorPlayerControllerMP; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.input.Mouse; + +public class FastMine extends Module { + private SliderSetting delay; + public SliderSetting multiplier; + private SliderSetting mode; + private ButtonSetting creativeDisable; + private float lastCurBlockDamageMP; + private String[] modes = new String[] { "Pre", "Post", "Increment" }; + + public FastMine() { + super("FastMine", category.player); + this.registerSetting(new DescriptionSetting("Vanilla is 5 delay & 1x speed.")); + this.registerSetting(delay = new SliderSetting("Break delay", " tick", 5.0, 0.0, 5.0, 1.0)); + this.registerSetting(multiplier = new SliderSetting("Break speed", "x", 1.0, 1.0, 2.0, 0.02)); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + this.registerSetting(creativeDisable = new ButtonSetting("Disable in creative", true)); + this.closetModule = true; + } + + @Override + public String getInfo() { + return ((int) multiplier.getInput() == multiplier.getInput() ? (int) multiplier.getInput() + "" : multiplier.getInput()) + multiplier.getSuffix(); + } + + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent e) { + if (e.phase != TickEvent.Phase.END || !mc.inGameHasFocus || !Utils.nullCheck()) { + return; + } + if (creativeDisable.isToggled() && mc.thePlayer.capabilities.isCreativeMode) { + return; + } + int delay = (int) this.delay.getInput(); + if (delay < 5.0) { + if (delay == 0) { + ((IAccessorPlayerControllerMP) mc.playerController).setBlockHitDelay(0); + } + else if (((IAccessorPlayerControllerMP) mc.playerController).getBlockHitDelay() > delay) { + ((IAccessorPlayerControllerMP) mc.playerController).setBlockHitDelay(delay); + } + } + double multiplierInput = multiplier.getInput(); + if (multiplierInput > 1.0) { + if (!mc.thePlayer.capabilities.isCreativeMode && Mouse.isButtonDown(0)) { + float curBlockDamage = ((IAccessorPlayerControllerMP) mc.playerController).getCurBlockDamageMP(); + switch ((int) mode.getInput()) { + case 0: + float damage = (float) (1.0 - 1.0 / multiplierInput); + if (curBlockDamage > 0.0f && curBlockDamage < damage) { + ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(damage); + break; + } + break; + case 1: + double extra = 1.0 / multiplierInput; + if (curBlockDamage < 1.0f && curBlockDamage >= extra) { + ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(1); + break; + } + break; + case 2: + float damage2 = -1.0f; + if (curBlockDamage < 1.0f) { + if (mc.objectMouseOver != null && curBlockDamage > this.lastCurBlockDamageMP) { + damage2 = (float) (this.lastCurBlockDamageMP + BlockUtils.getBlockHardness(mc.theWorld.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock(), mc.thePlayer.inventory.getStackInSlot(mc.thePlayer.inventory.currentItem), false, false) * (multiplierInput - 0.2152857 * (multiplierInput - 1.0))); + } + if (damage2 != -1.0f && curBlockDamage > 0.0f) { + ((IAccessorPlayerControllerMP) mc.playerController).setCurBlockDamageMP(damage2); + } + } + this.lastCurBlockDamageMP = curBlockDamage; + break; + } + } + else if (mode.getInput() == 2) { + this.lastCurBlockDamageMP = 0.0f; + } + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/player/InvManager.java b/src/main/java/keystrokesmod/module/impl/player/InvManager.java index c7f4916..e6182d9 100644 --- a/src/main/java/keystrokesmod/module/impl/player/InvManager.java +++ b/src/main/java/keystrokesmod/module/impl/player/InvManager.java @@ -1,575 +1,575 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.init.Items; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.*; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; -import org.lwjgl.input.Mouse; - -import java.util.ArrayList; -import java.util.List; - -public class InvManager extends Module { - private static SliderSetting stealerDelay; - private static SliderSetting sortDelay; - private static SliderSetting armorDelay; - private static SliderSetting cleanerDelay; - - private SliderSetting swordSlot; - private SliderSetting blocksSlot; - private SliderSetting goldenAppleSlot; - private SliderSetting projectileSlot; - private SliderSetting speedSlot; - private SliderSetting pearlSlot; - private ButtonSetting autoArmor; - private ButtonSetting autoSort; - private ButtonSetting customChests; - private ButtonSetting chestSteal; - private ButtonSetting closeAfterStealing; - private ButtonSetting invCleaner; - private ButtonSetting clickToClean; - - private long ticks = 0l; - private long nextDelay = 0l; - private boolean closeGui = false; - private double[] currentSword = new double[] { -1.0, -1.0 }; - - private CurrentArmor[] armorArr = CurrentArmor.values(); - - public InvManager() { - super("InvManager", category.player); - this.registerSetting(autoArmor = new ButtonSetting("Auto armor", false)); - this.registerSetting(armorDelay = new SliderSetting("Auto armor delay", 3.0, 1.0, 20.0, 1.0)); - - this.registerSetting(autoSort = new ButtonSetting("Auto sort", false)); - this.registerSetting(sortDelay = new SliderSetting("Sort delay", 3.0, 1.0, 20.0, 1.0)); - - this.registerSetting(chestSteal = new ButtonSetting("Steal chests", false)); - this.registerSetting(customChests = new ButtonSetting("Custom chest", false)); - this.registerSetting(closeAfterStealing = new ButtonSetting("Close after stealing", false)); - this.registerSetting(stealerDelay = new SliderSetting("Stealer delay", 3.0, 1.0, 20.0, 1.0)); - - this.registerSetting(invCleaner = new ButtonSetting("Inventory cleaner", false)); - this.registerSetting(clickToClean = new ButtonSetting("Middle click to clean", false)); - - this.registerSetting(cleanerDelay = new SliderSetting("Cleaner delay", 5.0, 1.0, 20.0, 1.0)); - this.registerSetting(swordSlot = new SliderSetting("Sword slot", true, -1, 1, 9, 1)); - this.registerSetting(blocksSlot = new SliderSetting("Blocks slot", true, -1, 1, 9, 1)); - this.registerSetting(goldenAppleSlot = new SliderSetting("Golden apple slot", true, -1, 1, 9, 1)); - this.registerSetting(projectileSlot = new SliderSetting("Projectile slot", true,-1, 1, 9, 1)); - this.registerSetting(speedSlot = new SliderSetting("Speed potion slot", true,-1, 1, 9, 1)); - this.registerSetting(pearlSlot = new SliderSetting("Pearl slot", true,-1, 1, 9, 1)); - } - - @Override - public void onDisable() { - this.nextDelay = 0L; - this.ticks = 0L; - this.closeGui = false; - } - - @Override - public void onUpdate() { - if (mc.currentScreen == null) { - return; - } - if (closeAfterStealing.isToggled() && this.closeGui) { - this.closeGui = false; - mc.thePlayer.closeScreen(); - return; - } - long ticks = this.ticks + 1L; - this.ticks = ticks; - if (ticks < this.nextDelay) { - return; - } - this.ticks = 0L; - if (mc.currentScreen instanceof GuiInventory) { - if (autoArmor.isToggled() || autoSort.isToggled() || invCleaner.isToggled()) { - this.updateCurrentArmor(); - InventoryData data = new InventoryData(mc.thePlayer.inventory, true, !autoSort.isToggled()); - if (autoArmor.isToggled()) { - for (int i = 0; i < data.armorData[0].length; ++i) { - if (data.armorData[1][i] != -1) { - CurrentArmor currentArmor = this.armorArr[i]; - if (data.armorData[1][i] > currentArmor.defenceLevel) { - if (currentArmor.getItemStack() != null) { - this.guiClick(currentArmor.invSlot, 0, 4, Delay.AUTOARMOR); - } - int slot = data.armorData[0][i]; - this.guiClick((slot < 9) ? (slot + 36) : slot, 0, 1, Delay.AUTOARMOR); - return; - } - } - } - } - if (autoSort.isToggled()) { - if (this.fixSwordSlot(data, true)) { - return; - } - for (int i = 0; i < data.size; ++i) { - ItemStack itemStack = data.inventory.getStackInSlot(i); - if (itemStack != null && !this.isSword(itemStack)) { - if (!this.isArmor(itemStack)) { - if (itemStack.getItem() instanceof ItemBlock) { - int slot = (int)(blocksSlot.getInput() - 1.0); - if (slot <= -1) { - if (i != slot) { - ItemStack currentBlocks = data.inventory.getStackInSlot(slot); - int i2 = (i < 9) ? (i + 36) : i; - if (currentBlocks == null || !(currentBlocks.getItem() instanceof ItemBlock)) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - if (currentBlocks.stackSize < 64) { - if (itemStack.getItem() == currentBlocks.getItem() && itemStack.getMetadata() == currentBlocks.getMetadata()) { - if (itemStack.stackSize == 64) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - if (data.emptyWithoutHotbar != 0 || i == i2) { - this.guiClick(i2, 0, 1, Delay.SORT); - return; - } - } - else if (itemStack.stackSize > currentBlocks.stackSize) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - } - } - } - else if (itemStack.getItem() instanceof ItemAppleGold) { - int slot = (int)(goldenAppleSlot.getInput() - 1.0); - if (slot <= -1) { - if (i != slot) { - ItemStack currentGoldenApple = data.inventory.getStackInSlot(slot); - if (currentGoldenApple == null || !(currentGoldenApple.getItem() instanceof ItemAppleGold)) { - int i2 = (i < 9) ? (i + 36) : i; - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - } - } - else if (itemStack.getItem() instanceof ItemSnowball || itemStack.getItem() instanceof ItemEgg) { - int slot = (int)(projectileSlot.getInput() - 1.0); - if (slot <= -1) { - if (i != slot) { - ItemStack currentProjectile = data.inventory.getStackInSlot(slot); - int i2 = (i < 9) ? (i + 36) : i; - if (currentProjectile == null || (!(currentProjectile.getItem() instanceof ItemSnowball) && !(currentProjectile.getItem() instanceof ItemEgg))) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - if (itemStack.stackSize >= 16) { - if (itemStack.stackSize > currentProjectile.stackSize) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - else if (currentProjectile.stackSize < 16) { - if (itemStack.getItem() == currentProjectile.getItem()) { - if (data.emptyWithoutHotbar != 0 || i == i2) { - this.guiClick(i2, 0, 1, Delay.SORT); - return; - } - } - else if (itemStack.stackSize > currentProjectile.stackSize) { - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - } - } - } - else if (itemStack.getItem() instanceof ItemPotion) { - int slot = (int)(speedSlot.getInput() - 1.0); - if (slot <= -1) { - if (i != slot) { - if (this.isSpeedPotion(itemStack)) { - ItemStack currentPotion = data.inventory.getStackInSlot(slot); - if (!this.isSpeedPotion(currentPotion)) { - int i2 = (i < 9) ? (i + 36) : i; - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - } - } - } - else if (itemStack.getItem() instanceof ItemEnderPearl) { - int slot = (int)(pearlSlot.getInput() - 1.0); - if (slot <= -1) { - if (i != slot) { - ItemStack currentPearl = data.inventory.getStackInSlot(slot); - if (currentPearl == null || !(currentPearl.getItem() instanceof ItemEnderPearl)) { - int i2 = (i < 9) ? (i + 36) : i; - this.guiClick(i2, slot, 2, Delay.SORT); - return; - } - } - } - } - } - } - } - } - if (invCleaner.isToggled()) { - if (clickToClean.isToggled() && !Mouse.isButtonDown(2)) { - return; - } - List duplicateItems = new ArrayList<>(); - for (int j = 0; j < data.size; ++j) { - ItemStack itemStack2 = data.inventory.getStackInSlot(j); - if (itemStack2 != null) { - Item item = itemStack2.getItem(); - int slot2 = (j < 9) ? (j + 36) : j; - if (this.isSword(itemStack2)) { - if (this.currentSword[1] <= Utils.getDamageLevel(itemStack2)) { - continue; - } - } - else if (this.isArmor(itemStack2)) { - ItemArmor armor = (ItemArmor)item; - int armorSlot = 3 - armor.armorType; - int defenceLevel = this.getDefenceLevel(itemStack2); - if (this.armorArr[armorSlot].defenceLevel <= defenceLevel) { - continue; - } - } - else { - if (item instanceof ItemBlock || item instanceof ItemAppleGold || item instanceof ItemSnowball || item instanceof ItemEgg || item instanceof ItemEnderPearl || item == Items.arrow) { - continue; - } - if (item == Items.spawn_egg) { - continue; - } - if (item instanceof ItemPotion) { - boolean shitPotion = false; - for (PotionEffect effect : ((ItemPotion)item).getEffects(itemStack2)) { - String desc = effect.toString(); - if (desc.contains("poison")) { - shitPotion = true; - break; - } - } - if (!shitPotion) { - continue; - } - } - else if (itemStack2.getMaxStackSize() == 1) { - int id = Item.getIdFromItem(item); - if (!duplicateItems.contains(id)) { - duplicateItems.add(id); - continue; - } - } - } - this.guiClick(slot2, 1, 4, Delay.CLEANER); - return; - } - } - } - } - } - else if (mc.currentScreen instanceof GuiChest && chestSteal.isToggled()) { - IInventory chestInventory = ((ContainerChest)mc.thePlayer.openContainer).getLowerChestInventory(); - if (!customChests.isToggled() && !chestInventory.getName().contains("Chest")) { - return; - } - this.updateCurrentArmor(); - InventoryData chestData = new InventoryData(chestInventory, false, false); - InventoryData playerData = new InventoryData(mc.thePlayer.inventory, true, false); - chestData.compareAndRemove(playerData); - if (playerData.size != playerData.filled) { - if (this.fixSwordSlot(chestData, false)) { - return; - } - for (int k = 0; k < chestData.armorData[0].length; ++k) { - if (chestData.armorData[1][k] != -1) { - CurrentArmor currentArmor2 = this.armorArr[k]; - if (chestData.armorData[1][k] > currentArmor2.defenceLevel) { - this.guiClick(chestData.armorData[0][k], 0, 1, Delay.STEALER); - return; - } - } - } - for (int k = 0; k < chestData.size; ++k) { - ItemStack itemStack3 = chestData.inventory.getStackInSlot(k); - if (itemStack3 != null && !this.isSword(itemStack3) && !this.isArmor(itemStack3)) { - if (itemStack3.getItem() instanceof ItemBlock) { - int slot2 = (int)(blocksSlot.getInput() - 1.0); - if (slot2 <= -1) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - ItemStack currentBlocks2 = playerData.inventory.getStackInSlot(slot2); - if (currentBlocks2 == null || !(currentBlocks2.getItem() instanceof ItemBlock) || (((ItemBlock)itemStack3.getItem()).getBlock() != ((ItemBlock)currentBlocks2.getItem()).getBlock() && itemStack3.stackSize > currentBlocks2.stackSize)) { - this.guiClick(k, slot2, 2, Delay.STEALER); - return; - } - } - else if (itemStack3.getItem() instanceof ItemAppleGold) { - int slot2 = (int)(goldenAppleSlot.getInput() - 1.0); - if (slot2 <= -1) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - ItemStack currentGoldenApple2 = playerData.inventory.getStackInSlot(slot2); - if (currentGoldenApple2 == null || !(currentGoldenApple2.getItem() instanceof ItemAppleGold)) { - this.guiClick(k, slot2, 2, Delay.STEALER); - return; - } - } - else if (itemStack3.getItem() instanceof ItemSnowball || itemStack3.getItem() instanceof ItemEgg) { - int slot2 = (int)(projectileSlot.getInput() - 1.0); - if (slot2 <= -1) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - ItemStack currentProjectile2 = playerData.inventory.getStackInSlot(slot2); - if (currentProjectile2 == null || (!(currentProjectile2.getItem() instanceof ItemSnowball) && !(currentProjectile2.getItem() instanceof ItemEgg))) { - this.guiClick(k, slot2, 2, Delay.STEALER); - return; - } - if (itemStack3.stackSize > currentProjectile2.stackSize) { - if (itemStack3.getItem() == currentProjectile2.getItem()) { - if (itemStack3.stackSize <= 16) { - this.guiClick(k, 0, 1, Delay.STEALER); - } - else { - this.guiClick(k, slot2, 2, Delay.STEALER); - } - } - else { - this.guiClick(k, slot2, 2, Delay.STEALER); - } - return; - } - } - else if (itemStack3.getItem() instanceof ItemPotion) { - if (this.isSpeedPotion(itemStack3)) { - int slot2 = (int)(speedSlot.getInput() - 1.0); - if (slot2 <= -1) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - ItemStack currentPotion2 = playerData.inventory.getStackInSlot(slot2); - if (!this.isSpeedPotion(currentPotion2)) { - this.guiClick(k, slot2, 2, Delay.STEALER); - return; - } - } - } - else if (itemStack3.getItem() instanceof ItemEnderPearl) { - int slot2 = (int)(pearlSlot.getInput() - 1.0); - if (slot2 <= -1) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - ItemStack currentPearl2 = playerData.inventory.getStackInSlot(slot2); - if (currentPearl2 == null || !(currentPearl2.getItem() instanceof ItemEnderPearl)) { - this.guiClick(k, slot2, 2, Delay.STEALER); - return; - } - } - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - } - } - else { - for (int k = 0; k < chestData.size; ++k) { - ItemStack itemStack3 = chestData.inventory.getStackInSlot(k); - if (itemStack3 != null) { - if (itemStack3.getItem() instanceof ItemBlock || itemStack3.getItem() instanceof ItemAppleGold || itemStack3.getItem() instanceof ItemSnowball || itemStack3.getItem() instanceof ItemEgg || itemStack3.getItem() instanceof ItemEnderPearl) { - for (int l = 0; l < playerData.size; ++l) { - ItemStack itemStack4 = playerData.inventory.getStackInSlot(l); - if (itemStack4 != null && itemStack3.getItem() == itemStack4.getItem()) { - if (itemStack4.stackSize < itemStack4.getMaxStackSize()) { - if (!(itemStack3.getItem() instanceof ItemBlock) || ((ItemBlock)itemStack3.getItem()).getBlock() == ((ItemBlock)itemStack4.getItem()).getBlock()) { - this.guiClick(k, 0, 1, Delay.STEALER); - return; - } - } - } - } - } - } - } - } - if (closeAfterStealing.isToggled()) { - this.closeGui = true; - } - } - } - - private boolean isSword(ItemStack itemStack) { - return itemStack.getItem() instanceof ItemSword; - } - - private boolean fixSwordSlot(InventoryData data, boolean playerInventory) { - if (swordSlot.getInput() != 0.0 && data.swordData[1] != -1.0 && data.swordData[1] > this.currentSword[1]) { - int slot = (int)data.swordData[0]; - if (playerInventory) { - slot = ((slot < 9) ? (slot + 36) : slot); - } - this.guiClick(slot, (int)(swordSlot.getInput() - 1.0), 2, Delay.SORT); - return true; - } - return false; - } - - private boolean isArmor(ItemStack itemStack) { - return itemStack.getItem() instanceof ItemArmor; - } - - private int getDefenceLevel(ItemStack itemStack) { - return ((ItemArmor)itemStack.getItem()).damageReduceAmount + EnchantmentHelper.getEnchantmentModifierDamage(new ItemStack[] { itemStack }, DamageSource.generic); - } - - private void updateCurrentArmor() { - for (CurrentArmor armor : this.armorArr) { - ItemStack itemStack = armor.getItemStack(); - if (itemStack != null && this.isArmor(itemStack)) { - armor.defenceLevel = this.getDefenceLevel(itemStack); - } - else { - armor.defenceLevel = 0; - } - } - } - - private boolean isSpeedPotion(ItemStack itemStack) { - if (itemStack != null && itemStack.getItem() instanceof ItemPotion) { - for (PotionEffect effect : ((ItemPotion)itemStack.getItem()).getEffects(itemStack)) { - String desc = effect.toString(); - if (desc.contains("moveSpeed")) { - return true; - } - } - } - return false; - } - - private void guiClick(int slot, int mouse, int mode, Delay delayType) { - this.nextDelay = (long)delayType.slider.getInput(); - guiClick(slot, mouse, mode); - } - - public static void guiClick(int slot, int mouse, int mode) { - mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot, mouse, mode, mc.thePlayer); - } - - enum CurrentArmor - { - BOOTS(0, 8), - LEGGINGS(1, 7), - CHESTPLATE(2, 6), - HELMET(3, 5); - - int slot; - int invSlot; - int defenceLevel; - - CurrentArmor(int slot, int invSlot) { - this.slot = slot; - this.invSlot = invSlot; - } - - public ItemStack getItemStack() { - return mc.thePlayer.inventory.armorItemInSlot(this.slot); - } - } - - class InventoryData - { - IInventory inventory; - int size; - int filled; - int emptyWithoutHotbar; - double[] swordData; - int[][] armorData; - - InventoryData(IInventory inventory, boolean playerInventory, boolean armorOnly) { - super(); - this.swordData = new double[] { -1.0, -1.0 }; - this.armorData = new int[][] { { -1, -1, -1, -1 }, { -1, -1, -1, -1 } }; - this.inventory = inventory; - this.size = (playerInventory ? (inventory.getSizeInventory() - 4) : inventory.getSizeInventory()); - int currentSwordSlot = (int)(swordSlot.getInput() - 1.0) + (playerInventory ? 0 : ((this.size == 54) ? 81 : 54)); - for (int i = 0; i < this.size; ++i) { - ItemStack itemStack = inventory.getStackInSlot(i); - if (itemStack != null) { - ++this.filled; - } - else if (i >= 9) { - ++this.emptyWithoutHotbar; - } - if (!armorOnly) { - if (i == currentSwordSlot) { - if (itemStack != null && isSword(itemStack)) { - currentSword[1] = Utils.getDamageLevel(itemStack); - currentSword[0] = i; - continue; - } - currentSword[0] = (currentSword[1] = -1.0); - } - else if (itemStack != null && isSword(itemStack)) { - double damageLevel = Utils.getDamageLevel(itemStack); - if (damageLevel > this.swordData[1]) { - this.swordData[1] = damageLevel; - this.swordData[0] = i; - } - continue; - } - } - if (itemStack != null && isArmor(itemStack)) { - ItemArmor armor = (ItemArmor)itemStack.getItem(); - int slot = 3 - armor.armorType; - int defenceLevel = getDefenceLevel(itemStack); - if (defenceLevel > this.armorData[1][slot]) { - this.armorData[1][slot] = defenceLevel; - this.armorData[0][slot] = i; - } - } - } - } - - void compareAndRemove(InventoryData data) { - if (data.swordData[1] > this.swordData[1]) { - this.swordData[1] = -1.0; - } - for (int i = 0; i < this.armorData[0].length; ++i) { - if (data.armorData[1][i] > this.armorData[1][i]) { - this.armorData[1][i] = -1; - } - } - } - } - - enum Delay - { - AUTOARMOR(armorDelay), - SORT(sortDelay), - STEALER(stealerDelay), - CLEANER(cleanerDelay); - - SliderSetting slider; - - Delay(SliderSetting slider) { - this.slider = slider; - } - } +package keystrokesmod.module.impl.player; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.*; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import org.lwjgl.input.Mouse; + +import java.util.ArrayList; +import java.util.List; + +public class InvManager extends Module { + private static SliderSetting stealerDelay; + private static SliderSetting sortDelay; + private static SliderSetting armorDelay; + private static SliderSetting cleanerDelay; + + private SliderSetting swordSlot; + private SliderSetting blocksSlot; + private SliderSetting goldenAppleSlot; + private SliderSetting projectileSlot; + private SliderSetting speedSlot; + private SliderSetting pearlSlot; + private ButtonSetting autoArmor; + private ButtonSetting autoSort; + private ButtonSetting customChests; + private ButtonSetting chestSteal; + private ButtonSetting closeAfterStealing; + private ButtonSetting invCleaner; + private ButtonSetting clickToClean; + + private long ticks = 0l; + private long nextDelay = 0l; + private boolean closeGui = false; + private double[] currentSword = new double[] { -1.0, -1.0 }; + + private CurrentArmor[] armorArr = CurrentArmor.values(); + + public InvManager() { + super("InvManager", category.player); + this.registerSetting(autoArmor = new ButtonSetting("Auto armor", false)); + this.registerSetting(armorDelay = new SliderSetting("Auto armor delay", 3.0, 1.0, 20.0, 1.0)); + + this.registerSetting(autoSort = new ButtonSetting("Auto sort", false)); + this.registerSetting(sortDelay = new SliderSetting("Sort delay", 3.0, 1.0, 20.0, 1.0)); + + this.registerSetting(chestSteal = new ButtonSetting("Steal chests", false)); + this.registerSetting(customChests = new ButtonSetting("Custom chest", false)); + this.registerSetting(closeAfterStealing = new ButtonSetting("Close after stealing", false)); + this.registerSetting(stealerDelay = new SliderSetting("Stealer delay", 3.0, 1.0, 20.0, 1.0)); + + this.registerSetting(invCleaner = new ButtonSetting("Inventory cleaner", false)); + this.registerSetting(clickToClean = new ButtonSetting("Middle click to clean", false)); + + this.registerSetting(cleanerDelay = new SliderSetting("Cleaner delay", 5.0, 1.0, 20.0, 1.0)); + this.registerSetting(swordSlot = new SliderSetting("Sword slot", true, -1, 1, 9, 1)); + this.registerSetting(blocksSlot = new SliderSetting("Blocks slot", true, -1, 1, 9, 1)); + this.registerSetting(goldenAppleSlot = new SliderSetting("Golden apple slot", true, -1, 1, 9, 1)); + this.registerSetting(projectileSlot = new SliderSetting("Projectile slot", true,-1, 1, 9, 1)); + this.registerSetting(speedSlot = new SliderSetting("Speed potion slot", true,-1, 1, 9, 1)); + this.registerSetting(pearlSlot = new SliderSetting("Pearl slot", true,-1, 1, 9, 1)); + } + + @Override + public void onDisable() { + this.nextDelay = 0L; + this.ticks = 0L; + this.closeGui = false; + } + + @Override + public void onUpdate() { + if (mc.currentScreen == null) { + return; + } + if (closeAfterStealing.isToggled() && this.closeGui) { + this.closeGui = false; + mc.thePlayer.closeScreen(); + return; + } + long ticks = this.ticks + 1L; + this.ticks = ticks; + if (ticks < this.nextDelay) { + return; + } + this.ticks = 0L; + if (mc.currentScreen instanceof GuiInventory) { + if (autoArmor.isToggled() || autoSort.isToggled() || invCleaner.isToggled()) { + this.updateCurrentArmor(); + InventoryData data = new InventoryData(mc.thePlayer.inventory, true, !autoSort.isToggled()); + if (autoArmor.isToggled()) { + for (int i = 0; i < data.armorData[0].length; ++i) { + if (data.armorData[1][i] != -1) { + CurrentArmor currentArmor = this.armorArr[i]; + if (data.armorData[1][i] > currentArmor.defenceLevel) { + if (currentArmor.getItemStack() != null) { + this.guiClick(currentArmor.invSlot, 0, 4, Delay.AUTOARMOR); + } + int slot = data.armorData[0][i]; + this.guiClick((slot < 9) ? (slot + 36) : slot, 0, 1, Delay.AUTOARMOR); + return; + } + } + } + } + if (autoSort.isToggled()) { + if (this.fixSwordSlot(data, true)) { + return; + } + for (int i = 0; i < data.size; ++i) { + ItemStack itemStack = data.inventory.getStackInSlot(i); + if (itemStack != null && !this.isSword(itemStack)) { + if (!this.isArmor(itemStack)) { + if (itemStack.getItem() instanceof ItemBlock) { + int slot = (int)(blocksSlot.getInput() - 1.0); + if (slot <= -1) { + if (i != slot) { + ItemStack currentBlocks = data.inventory.getStackInSlot(slot); + int i2 = (i < 9) ? (i + 36) : i; + if (currentBlocks == null || !(currentBlocks.getItem() instanceof ItemBlock)) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + if (currentBlocks.stackSize < 64) { + if (itemStack.getItem() == currentBlocks.getItem() && itemStack.getMetadata() == currentBlocks.getMetadata()) { + if (itemStack.stackSize == 64) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + if (data.emptyWithoutHotbar != 0 || i == i2) { + this.guiClick(i2, 0, 1, Delay.SORT); + return; + } + } + else if (itemStack.stackSize > currentBlocks.stackSize) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + } + } + } + else if (itemStack.getItem() instanceof ItemAppleGold) { + int slot = (int)(goldenAppleSlot.getInput() - 1.0); + if (slot <= -1) { + if (i != slot) { + ItemStack currentGoldenApple = data.inventory.getStackInSlot(slot); + if (currentGoldenApple == null || !(currentGoldenApple.getItem() instanceof ItemAppleGold)) { + int i2 = (i < 9) ? (i + 36) : i; + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + } + } + else if (itemStack.getItem() instanceof ItemSnowball || itemStack.getItem() instanceof ItemEgg) { + int slot = (int)(projectileSlot.getInput() - 1.0); + if (slot <= -1) { + if (i != slot) { + ItemStack currentProjectile = data.inventory.getStackInSlot(slot); + int i2 = (i < 9) ? (i + 36) : i; + if (currentProjectile == null || (!(currentProjectile.getItem() instanceof ItemSnowball) && !(currentProjectile.getItem() instanceof ItemEgg))) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + if (itemStack.stackSize >= 16) { + if (itemStack.stackSize > currentProjectile.stackSize) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + else if (currentProjectile.stackSize < 16) { + if (itemStack.getItem() == currentProjectile.getItem()) { + if (data.emptyWithoutHotbar != 0 || i == i2) { + this.guiClick(i2, 0, 1, Delay.SORT); + return; + } + } + else if (itemStack.stackSize > currentProjectile.stackSize) { + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + } + } + } + else if (itemStack.getItem() instanceof ItemPotion) { + int slot = (int)(speedSlot.getInput() - 1.0); + if (slot <= -1) { + if (i != slot) { + if (this.isSpeedPotion(itemStack)) { + ItemStack currentPotion = data.inventory.getStackInSlot(slot); + if (!this.isSpeedPotion(currentPotion)) { + int i2 = (i < 9) ? (i + 36) : i; + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + } + } + } + else if (itemStack.getItem() instanceof ItemEnderPearl) { + int slot = (int)(pearlSlot.getInput() - 1.0); + if (slot <= -1) { + if (i != slot) { + ItemStack currentPearl = data.inventory.getStackInSlot(slot); + if (currentPearl == null || !(currentPearl.getItem() instanceof ItemEnderPearl)) { + int i2 = (i < 9) ? (i + 36) : i; + this.guiClick(i2, slot, 2, Delay.SORT); + return; + } + } + } + } + } + } + } + } + if (invCleaner.isToggled()) { + if (clickToClean.isToggled() && !Mouse.isButtonDown(2)) { + return; + } + List duplicateItems = new ArrayList<>(); + for (int j = 0; j < data.size; ++j) { + ItemStack itemStack2 = data.inventory.getStackInSlot(j); + if (itemStack2 != null) { + Item item = itemStack2.getItem(); + int slot2 = (j < 9) ? (j + 36) : j; + if (this.isSword(itemStack2)) { + if (this.currentSword[1] <= Utils.getDamageLevel(itemStack2)) { + continue; + } + } + else if (this.isArmor(itemStack2)) { + ItemArmor armor = (ItemArmor)item; + int armorSlot = 3 - armor.armorType; + int defenceLevel = this.getDefenceLevel(itemStack2); + if (this.armorArr[armorSlot].defenceLevel <= defenceLevel) { + continue; + } + } + else { + if (item instanceof ItemBlock || item instanceof ItemAppleGold || item instanceof ItemSnowball || item instanceof ItemEgg || item instanceof ItemEnderPearl || item == Items.arrow) { + continue; + } + if (item == Items.spawn_egg) { + continue; + } + if (item instanceof ItemPotion) { + boolean shitPotion = false; + for (PotionEffect effect : ((ItemPotion)item).getEffects(itemStack2)) { + String desc = effect.toString(); + if (desc.contains("poison")) { + shitPotion = true; + break; + } + } + if (!shitPotion) { + continue; + } + } + else if (itemStack2.getMaxStackSize() == 1) { + int id = Item.getIdFromItem(item); + if (!duplicateItems.contains(id)) { + duplicateItems.add(id); + continue; + } + } + } + this.guiClick(slot2, 1, 4, Delay.CLEANER); + return; + } + } + } + } + } + else if (mc.currentScreen instanceof GuiChest && chestSteal.isToggled()) { + IInventory chestInventory = ((ContainerChest)mc.thePlayer.openContainer).getLowerChestInventory(); + if (!customChests.isToggled() && !chestInventory.getName().contains("Chest")) { + return; + } + this.updateCurrentArmor(); + InventoryData chestData = new InventoryData(chestInventory, false, false); + InventoryData playerData = new InventoryData(mc.thePlayer.inventory, true, false); + chestData.compareAndRemove(playerData); + if (playerData.size != playerData.filled) { + if (this.fixSwordSlot(chestData, false)) { + return; + } + for (int k = 0; k < chestData.armorData[0].length; ++k) { + if (chestData.armorData[1][k] != -1) { + CurrentArmor currentArmor2 = this.armorArr[k]; + if (chestData.armorData[1][k] > currentArmor2.defenceLevel) { + this.guiClick(chestData.armorData[0][k], 0, 1, Delay.STEALER); + return; + } + } + } + for (int k = 0; k < chestData.size; ++k) { + ItemStack itemStack3 = chestData.inventory.getStackInSlot(k); + if (itemStack3 != null && !this.isSword(itemStack3) && !this.isArmor(itemStack3)) { + if (itemStack3.getItem() instanceof ItemBlock) { + int slot2 = (int)(blocksSlot.getInput() - 1.0); + if (slot2 <= -1) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + ItemStack currentBlocks2 = playerData.inventory.getStackInSlot(slot2); + if (currentBlocks2 == null || !(currentBlocks2.getItem() instanceof ItemBlock) || (((ItemBlock)itemStack3.getItem()).getBlock() != ((ItemBlock)currentBlocks2.getItem()).getBlock() && itemStack3.stackSize > currentBlocks2.stackSize)) { + this.guiClick(k, slot2, 2, Delay.STEALER); + return; + } + } + else if (itemStack3.getItem() instanceof ItemAppleGold) { + int slot2 = (int)(goldenAppleSlot.getInput() - 1.0); + if (slot2 <= -1) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + ItemStack currentGoldenApple2 = playerData.inventory.getStackInSlot(slot2); + if (currentGoldenApple2 == null || !(currentGoldenApple2.getItem() instanceof ItemAppleGold)) { + this.guiClick(k, slot2, 2, Delay.STEALER); + return; + } + } + else if (itemStack3.getItem() instanceof ItemSnowball || itemStack3.getItem() instanceof ItemEgg) { + int slot2 = (int)(projectileSlot.getInput() - 1.0); + if (slot2 <= -1) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + ItemStack currentProjectile2 = playerData.inventory.getStackInSlot(slot2); + if (currentProjectile2 == null || (!(currentProjectile2.getItem() instanceof ItemSnowball) && !(currentProjectile2.getItem() instanceof ItemEgg))) { + this.guiClick(k, slot2, 2, Delay.STEALER); + return; + } + if (itemStack3.stackSize > currentProjectile2.stackSize) { + if (itemStack3.getItem() == currentProjectile2.getItem()) { + if (itemStack3.stackSize <= 16) { + this.guiClick(k, 0, 1, Delay.STEALER); + } + else { + this.guiClick(k, slot2, 2, Delay.STEALER); + } + } + else { + this.guiClick(k, slot2, 2, Delay.STEALER); + } + return; + } + } + else if (itemStack3.getItem() instanceof ItemPotion) { + if (this.isSpeedPotion(itemStack3)) { + int slot2 = (int)(speedSlot.getInput() - 1.0); + if (slot2 <= -1) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + ItemStack currentPotion2 = playerData.inventory.getStackInSlot(slot2); + if (!this.isSpeedPotion(currentPotion2)) { + this.guiClick(k, slot2, 2, Delay.STEALER); + return; + } + } + } + else if (itemStack3.getItem() instanceof ItemEnderPearl) { + int slot2 = (int)(pearlSlot.getInput() - 1.0); + if (slot2 <= -1) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + ItemStack currentPearl2 = playerData.inventory.getStackInSlot(slot2); + if (currentPearl2 == null || !(currentPearl2.getItem() instanceof ItemEnderPearl)) { + this.guiClick(k, slot2, 2, Delay.STEALER); + return; + } + } + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + } + } + else { + for (int k = 0; k < chestData.size; ++k) { + ItemStack itemStack3 = chestData.inventory.getStackInSlot(k); + if (itemStack3 != null) { + if (itemStack3.getItem() instanceof ItemBlock || itemStack3.getItem() instanceof ItemAppleGold || itemStack3.getItem() instanceof ItemSnowball || itemStack3.getItem() instanceof ItemEgg || itemStack3.getItem() instanceof ItemEnderPearl) { + for (int l = 0; l < playerData.size; ++l) { + ItemStack itemStack4 = playerData.inventory.getStackInSlot(l); + if (itemStack4 != null && itemStack3.getItem() == itemStack4.getItem()) { + if (itemStack4.stackSize < itemStack4.getMaxStackSize()) { + if (!(itemStack3.getItem() instanceof ItemBlock) || ((ItemBlock)itemStack3.getItem()).getBlock() == ((ItemBlock)itemStack4.getItem()).getBlock()) { + this.guiClick(k, 0, 1, Delay.STEALER); + return; + } + } + } + } + } + } + } + } + if (closeAfterStealing.isToggled()) { + this.closeGui = true; + } + } + } + + private boolean isSword(ItemStack itemStack) { + return itemStack.getItem() instanceof ItemSword; + } + + private boolean fixSwordSlot(InventoryData data, boolean playerInventory) { + if (swordSlot.getInput() != 0.0 && data.swordData[1] != -1.0 && data.swordData[1] > this.currentSword[1]) { + int slot = (int)data.swordData[0]; + if (playerInventory) { + slot = ((slot < 9) ? (slot + 36) : slot); + } + this.guiClick(slot, (int)(swordSlot.getInput() - 1.0), 2, Delay.SORT); + return true; + } + return false; + } + + private boolean isArmor(ItemStack itemStack) { + return itemStack.getItem() instanceof ItemArmor; + } + + private int getDefenceLevel(ItemStack itemStack) { + return ((ItemArmor)itemStack.getItem()).damageReduceAmount + EnchantmentHelper.getEnchantmentModifierDamage(new ItemStack[] { itemStack }, DamageSource.generic); + } + + private void updateCurrentArmor() { + for (CurrentArmor armor : this.armorArr) { + ItemStack itemStack = armor.getItemStack(); + if (itemStack != null && this.isArmor(itemStack)) { + armor.defenceLevel = this.getDefenceLevel(itemStack); + } + else { + armor.defenceLevel = 0; + } + } + } + + private boolean isSpeedPotion(ItemStack itemStack) { + if (itemStack != null && itemStack.getItem() instanceof ItemPotion) { + for (PotionEffect effect : ((ItemPotion)itemStack.getItem()).getEffects(itemStack)) { + String desc = effect.toString(); + if (desc.contains("moveSpeed")) { + return true; + } + } + } + return false; + } + + private void guiClick(int slot, int mouse, int mode, Delay delayType) { + this.nextDelay = (long)delayType.slider.getInput(); + guiClick(slot, mouse, mode); + } + + public static void guiClick(int slot, int mouse, int mode) { + mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot, mouse, mode, mc.thePlayer); + } + + enum CurrentArmor + { + BOOTS(0, 8), + LEGGINGS(1, 7), + CHESTPLATE(2, 6), + HELMET(3, 5); + + int slot; + int invSlot; + int defenceLevel; + + CurrentArmor(int slot, int invSlot) { + this.slot = slot; + this.invSlot = invSlot; + } + + public ItemStack getItemStack() { + return mc.thePlayer.inventory.armorItemInSlot(this.slot); + } + } + + class InventoryData + { + IInventory inventory; + int size; + int filled; + int emptyWithoutHotbar; + double[] swordData; + int[][] armorData; + + InventoryData(IInventory inventory, boolean playerInventory, boolean armorOnly) { + super(); + this.swordData = new double[] { -1.0, -1.0 }; + this.armorData = new int[][] { { -1, -1, -1, -1 }, { -1, -1, -1, -1 } }; + this.inventory = inventory; + this.size = (playerInventory ? (inventory.getSizeInventory() - 4) : inventory.getSizeInventory()); + int currentSwordSlot = (int)(swordSlot.getInput() - 1.0) + (playerInventory ? 0 : ((this.size == 54) ? 81 : 54)); + for (int i = 0; i < this.size; ++i) { + ItemStack itemStack = inventory.getStackInSlot(i); + if (itemStack != null) { + ++this.filled; + } + else if (i >= 9) { + ++this.emptyWithoutHotbar; + } + if (!armorOnly) { + if (i == currentSwordSlot) { + if (itemStack != null && isSword(itemStack)) { + currentSword[1] = Utils.getDamageLevel(itemStack); + currentSword[0] = i; + continue; + } + currentSword[0] = (currentSword[1] = -1.0); + } + else if (itemStack != null && isSword(itemStack)) { + double damageLevel = Utils.getDamageLevel(itemStack); + if (damageLevel > this.swordData[1]) { + this.swordData[1] = damageLevel; + this.swordData[0] = i; + } + continue; + } + } + if (itemStack != null && isArmor(itemStack)) { + ItemArmor armor = (ItemArmor)itemStack.getItem(); + int slot = 3 - armor.armorType; + int defenceLevel = getDefenceLevel(itemStack); + if (defenceLevel > this.armorData[1][slot]) { + this.armorData[1][slot] = defenceLevel; + this.armorData[0][slot] = i; + } + } + } + } + + void compareAndRemove(InventoryData data) { + if (data.swordData[1] > this.swordData[1]) { + this.swordData[1] = -1.0; + } + for (int i = 0; i < this.armorData[0].length; ++i) { + if (data.armorData[1][i] > this.armorData[1][i]) { + this.armorData[1][i] = -1; + } + } + } + } + + enum Delay + { + AUTOARMOR(armorDelay), + SORT(sortDelay), + STEALER(stealerDelay), + CLEANER(cleanerDelay); + + SliderSetting slider; + + Delay(SliderSetting slider) { + this.slider = slider; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/NoFall.java b/src/main/java/keystrokesmod/module/impl/player/NoFall.java index 5767d22..69f9d56 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoFall.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoFall.java @@ -38,7 +38,9 @@ public class NoFall extends Module { private SliderSetting minFallDistance; private ButtonSetting disableAdventure; private ButtonSetting ignoreVoid, voidC; - private ButtonSetting hideSound, renderTimer; + private ButtonSetting hideSound; + public ButtonSetting renderTimer; + private ButtonSetting disableTp; private String[] modes = new String[]{"Spoof", "NoGround", "Packet A", "Packet B", "CTW Packet", "Prediction", "Blink"}; private int color = new Color(0, 187, 255, 255).getRGB(); @@ -50,15 +52,13 @@ public class NoFall extends Module { private int n; - private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - private ConcurrentLinkedQueue regularPackets = new ConcurrentLinkedQueue<>(); - public boolean isBlinking; - public boolean bnFalling, start; - - private int blinkTicks; + public boolean bnFalling, blink; private int y; + private boolean tp; + private double lastX, lastY, lastZ; + public NoFall() { super("NoFall", category.player); this.registerSetting(mode = new SliderSetting("Mode", 2, modes)); @@ -67,6 +67,7 @@ public class NoFall extends Module { this.registerSetting(ignoreVoid = new ButtonSetting("Ignore void", false)); this.registerSetting(voidC = new ButtonSetting("Experimental void check", true)); this.registerSetting(renderTimer = new ButtonSetting("Render Blink Timer", true)); + this.registerSetting(disableTp = new ButtonSetting("Disable on teleport", true)); //this.registerSetting(hideSound = new ButtonSetting("Hide fall damage sound", false)); } @@ -76,37 +77,22 @@ public class NoFall extends Module { public void onDisable() { Utils.resetTimer(); - - if (mc.thePlayer.onGround) { - finishBlink(); - } else { - finishBlinkRegular(); - } + blink = false; + tp = false; } - /*@SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S29PacketSoundEffect) { - S29PacketSoundEffect s29 = (S29PacketSoundEffect) e.getPacket(); - /*if (!Objects.equals(String.valueOf(s29.getSoundName()), "random.explode")) { - - }*/ - /*Utils.print("" + s29.getSoundName()); - } - }*/ - /*@SubscribeEvent public void onSoundEvent(SoundEvent.SoundSourceEvent e) { if (e.name.startsWith("game.player.hurt.fall")) { - Utils.print("Fall dmg sound"); + } }*/ @SubscribeEvent public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S08PacketPlayerPosLook && n > 0) { - n = 34; + if (e.getPacket() instanceof S08PacketPlayerPosLook) { + if (n > 0) n = 34; } } @@ -115,31 +101,39 @@ public class NoFall extends Module { public void onPreUpdate(PreUpdateEvent e) { if (mode.getInput() == 6) { if (Utils.fallDist() >= minFallDistance.getInput() && Utils.isEdgeOfBlock() && mc.thePlayer.onGround && !Utils.jumpDown() && !ModuleManager.scaffold.isEnabled && !ModuleManager.bhop.isEnabled() && !LongJump.function) { - start = true; + blink = true; y = (int) mc.thePlayer.posY; } - else if (start && !bnFalling && mc.thePlayer.posY > y) { - finishBlinkRegular(); + else if (blink && !bnFalling && mc.thePlayer.posY > y) { + blink = false; } - if (isBlinking) { - ++blinkTicks; - } - if (mc.thePlayer.posY < y && !mc.thePlayer.onGround && start) { + if (mc.thePlayer.posY < y && !mc.thePlayer.onGround && blink) { bnFalling = true; } else if (bnFalling) { - finishBlink(); + blink = false; } - if (mc.thePlayer.posY <= y - 31 && start) { - finishBlinkRegular(); + if (mc.thePlayer.posY <= y - 31 && blink) { + blink = false; } } + if (mc.thePlayer.posY >= lastY + 3.5D && !(mc.thePlayer.posY >= lastY + 10.0D) && ModuleUtils.hasTeleported && !ModuleUtils.worldChange) { + if (disableTp.isToggled()) { + Utils.modulePrint("§cMost likely staff checked, disabling NoFall until on ground"); + tp = true; + Utils.ping(); + } + } + else if (mc.thePlayer.onGround && tp) { + tp = false; + Utils.modulePrint("§aNoFall re-enabled"); + } - - - + lastX = mc.thePlayer.posX; + lastY = mc.thePlayer.posY; + lastZ = mc.thePlayer.posZ; if (reset()) { Utils.resetTimer(); @@ -153,10 +147,6 @@ public class NoFall extends Module { isFalling = true; } - if (ModuleManager.antiVoid.started) { - return; - } - double predictedY = mc.thePlayer.posY + mc.thePlayer.motionY; double distanceFallen = initialY - predictedY; @@ -239,103 +229,13 @@ public class NoFall extends Module { e.setOnGround(false); break; case 6: - if (start) { + if (blink) { e.setOnGround(true); } break; } } - private void finishBlink() { - isBlinking = bnFalling = start = false; - blinkTicks = 0; - if (!blinkedPackets.isEmpty()) { - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } - blinkedPackets.clear(); - regularPackets.clear(); - } - - private void finishBlinkRegular() { - isBlinking = bnFalling = start = false; - blinkTicks = 0; - if (!regularPackets.isEmpty()) { - synchronized (regularPackets) { - for (Packet packet : regularPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } - regularPackets.clear(); - blinkedPackets.clear(); - } - - /* - if (mc.thePlayer.onGround) { - synchronized (blinkedPackets) { - for (Packet packet : blinkedPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } else { - synchronized (regularPackets) { - for (Packet packet : regularPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - } - } - } - blinkedPackets.clear(); - regularPackets.clear(); - */ - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck() || !renderTimer.isToggled() || mode.getInput() != 6 || blinkTicks == 0 || blinkTicks >= 99999) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - } - Utils.handleTimer(color, blinkTicks); - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - Packet packet = e.getPacket(); - if (packet.getClass().getSimpleName().startsWith("S")) { - return; - } - if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { - return; - } - if (!start) { - return; - } - if (!e.isCanceled()) { - isBlinking = true; - regularPackets.add(packet); - blinkedPackets.add(packet); - e.setCanceled(true); - } - } - - private boolean otherc03(Packet packet) { - return ((packet instanceof C03PacketPlayer.C04PacketPlayerPosition) || (packet instanceof C03PacketPlayer.C05PacketPlayerLook) || (packet instanceof C03PacketPlayer.C06PacketPlayerPosLook)); - } - @Override public String getInfo() { return modes[(int) mode.getInput()]; @@ -377,6 +277,9 @@ public class NoFall extends Module { if (voidC.isToggled() && Utils.overVoid() && !dist()) { return true; } + if (tp) { + return true; + } return false; } @@ -385,7 +288,7 @@ public class NoFall extends Module { public boolean dist() { - double minMotion = 0.1; + double minMotion = 0.12; int dist1 = 4; int dist2 = 6; int dist3 = 7; diff --git a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java index abd2663..24fc6c7 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java @@ -1,37 +1,37 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.module.Module; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; - -public class NoRotate extends Module { - private float prevPitch = 0f; - private float prevYaw = 0f; - - public NoRotate() { - super("NoRotate", category.player); - } - - public void handlePlayerPosLookPre() { - if (!this.isEnabled()) { - return; - } - if (mc.thePlayer == null || mc.thePlayer.rotationPitch == 0) { - return; - } - prevPitch = mc.thePlayer.rotationPitch % 360; - prevYaw = mc.thePlayer.rotationYaw % 360; - } - - public void handlePlayerPosLook(S08PacketPlayerPosLook packet) { - if (!this.isEnabled()) { - return; - } - if (packet.getPitch() == 0 || mc.thePlayer == null) { - return; - } - mc.thePlayer.prevRotationYaw = prevYaw; - mc.thePlayer.prevRotationPitch = prevPitch; - mc.thePlayer.rotationPitch = prevPitch; - mc.thePlayer.rotationYaw = prevYaw; - } -} +package keystrokesmod.module.impl.player; + +import keystrokesmod.module.Module; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; + +public class NoRotate extends Module { + private float prevPitch = 0f; + private float prevYaw = 0f; + + public NoRotate() { + super("NoRotate", category.player); + } + + public void handlePlayerPosLookPre() { + if (!this.isEnabled()) { + return; + } + if (mc.thePlayer == null || mc.thePlayer.rotationPitch == 0) { + return; + } + prevPitch = mc.thePlayer.rotationPitch % 360; + prevYaw = mc.thePlayer.rotationYaw % 360; + } + + public void handlePlayerPosLook(S08PacketPlayerPosLook packet) { + if (!this.isEnabled()) { + return; + } + if (packet.getPitch() == 0 || mc.thePlayer == null) { + return; + } + mc.thePlayer.prevRotationYaw = prevYaw; + mc.thePlayer.prevRotationPitch = prevPitch; + mc.thePlayer.rotationPitch = prevPitch; + mc.thePlayer.rotationYaw = prevYaw; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/player/Safewalk.java b/src/main/java/keystrokesmod/module/impl/player/Safewalk.java index ae3eeab..31b0c30 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Safewalk.java +++ b/src/main/java/keystrokesmod/module/impl/player/Safewalk.java @@ -1,10 +1,14 @@ package keystrokesmod.module.impl.player; +import keystrokesmod.event.PrePlayerInputEvent; import keystrokesmod.event.PreUpdateEvent; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.script.ScriptDefaults; +import keystrokesmod.script.model.Simulation; +import keystrokesmod.script.model.Vec3; import keystrokesmod.utility.Utils; import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemBlock; @@ -14,128 +18,94 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.input.Keyboard; public class Safewalk extends Module { - private SliderSetting sneakDelay; private SliderSetting motion; - private ButtonSetting sneak; - public static ButtonSetting blocksOnly, pitchCheck, disableOnForward; + public static ButtonSetting blocksOnly, pitchCheck, disableOnForward, legit; + + private SliderSetting edgeOffset, unsneakDelay, sneakOnJump; + public static ButtonSetting sneakKeyPressed, holdingBlocks, rmbDown, lookingDown, disableForward; - private int unsneakDelayTicks = 0; public boolean isSneaking; + private boolean wasOn; + private double HW = 0.3; + private double[][] CORNERS = {{ -HW, -HW }, { HW, -HW }, { -HW, HW }, { HW, HW }}; + private boolean setSneaking; + private int sneakJumpDelayTicks; + private int sneakJumpStartTick = -1; + private int unsneakDelayTicks; + private int unsneakStartTick = -1; public Safewalk() { super("Safewalk", Module.category.player, 0); - this.registerSetting(sneakDelay = new SliderSetting("Sneak delay", " tick", 0, 0, 20, 1)); this.registerSetting(motion = new SliderSetting("Motion", "x", 1.0, 0.5, 1.2, 0.01)); this.registerSetting(blocksOnly = new ButtonSetting("Blocks only", true)); this.registerSetting(disableOnForward = new ButtonSetting("Disable on forward", false)); this.registerSetting(pitchCheck = new ButtonSetting("Pitch check", false)); - this.registerSetting(sneak = new ButtonSetting("Sneak", false)); + this.registerSetting(legit = new ButtonSetting("Legit", false)); + + this.registerSetting(edgeOffset = new SliderSetting("Edge offset", " blocks", 0, 0, 0.3, 0.01)); + this.registerSetting(unsneakDelay = new SliderSetting("Unsneak delay", "ms", 50, 50, 300, 5)); + this.registerSetting(sneakOnJump = new SliderSetting("Sneak on jump", "ms", 50, 50, 300, 5)); + this.registerSetting(sneakKeyPressed = new ButtonSetting("Sneak key pressed", false)); + this.registerSetting(holdingBlocks = new ButtonSetting("Holding blocks", false)); + this.registerSetting(rmbDown = new ButtonSetting("RMB down", false)); + this.registerSetting(lookingDown = new ButtonSetting("Looking down", false)); + this.registerSetting(disableForward = new ButtonSetting("Disable on forward", false)); + } + + public void guiUpdate() { + blocksOnly.setVisible(!legit.isToggled(), this); + disableOnForward.setVisible(!legit.isToggled(), this); + pitchCheck.setVisible(!legit.isToggled(), this); + + edgeOffset.setVisible(legit.isToggled(), this); + unsneakDelay.setVisible(legit.isToggled(), this); + sneakOnJump.setVisible(legit.isToggled(), this); + sneakKeyPressed.setVisible(legit.isToggled(), this); + holdingBlocks.setVisible(legit.isToggled(), this); + rmbDown.setVisible(legit.isToggled(), this); + lookingDown.setVisible(legit.isToggled(), this); + disableForward.setVisible(legit.isToggled(), this); + } + + @Override + public String getInfo() { + return legit.isToggled() ? ((int) unsneakDelay.getInput() + "ms") : ""; } @Override public void onDisable() { - if (sneak.isToggled() && Utils.isEdgeOfBlock()) { - this.setSneakState(false); - } - isSneaking = false; - unsneakDelayTicks = 0; + reset(); } @Override public void onUpdate() { - if (motion.getInput() != 1.0 && mc.thePlayer.onGround && Utils.isMoving() && settingsMet()) { + if (motion.getInput() != 1.0 && mc.thePlayer.onGround && Utils.isMoving() && safewalkSettingsMet()) { mc.thePlayer.motionX *= motion.getInput(); mc.thePlayer.motionZ *= motion.getInput(); } } - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!sneak.isToggled() || !Utils.nullCheck()) { - return; - } - boolean edge = mc.thePlayer.onGround && Utils.isEdgeOfBlock(); - if (edge) { - if (!settingsMet()) { - this.setSneakState(false); - return; - } - if (!this.isSneaking) { - this.setSneakState(true); - unsneakDelayTicks = (int) sneakDelay.getInput(); - } - } - else { - if (this.isSneaking) { - if (!settingsMet()) { - this.setSneakState(false); - return; - } - if (unsneakDelayTicks > 0) { - unsneakDelayTicks--; - return; - } - this.setSneakState(false); - } - } - if (this.isSneaking && (mc.thePlayer.capabilities.isFlying || !settingsMet())) { - this.setSneakState(false); - } - } - - @SubscribeEvent - public void onGuiOpen(GuiOpenEvent e) { - if (sneak.isToggled() && e.gui == null) { - this.isSneaking = mc.thePlayer.isSneaking(); - } - } - - private void setSneakState(boolean sneakState) { - if (!sneakState) { - unsneakDelayTicks = 0; - } - if (this.isSneaking == sneakState) { - return; - } - - if (!sneakState && Utils.isBindDown(mc.gameSettings.keyBindSneak)) { - return; - } - - KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), sneakState); - if (sneakState) { - KeyBinding.onTick(mc.gameSettings.keyBindSneak.getKeyCode()); - } - this.isSneaking = sneakState; - } - public static boolean canSafeWalk() { if (ModuleManager.safeWalk != null && ModuleManager.safeWalk.isEnabled()) { - if (disableOnForward.isToggled() && Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode())) { + if (legit.isToggled()) { return false; } - if (pitchCheck.isToggled() && mc.thePlayer.rotationPitch < 70) { + if (!safewalkSettingsMet()) { return false; } - if (blocksOnly.isToggled()) { - ItemStack held = mc.thePlayer.getHeldItem(); - if (held == null || !(held.getItem() instanceof ItemBlock)) { - return false; - } - } return true; } return false; } - private boolean settingsMet() { + private static boolean safewalkSettingsMet() { if (blocksOnly.isToggled()) { ItemStack held = mc.thePlayer.getHeldItem(); if (held == null || !(held.getItem() instanceof ItemBlock)) { return false; } } - if (disableOnForward.isToggled() && Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode())) { + if (disableOnForward.isToggled() && mc.thePlayer.moveForward > -0.2) { return false; } if (pitchCheck.isToggled() && mc.thePlayer.rotationPitch < 70.0f) { @@ -143,4 +113,182 @@ public class Safewalk extends Module { } return true; } + + public boolean legitScafSettingsMet() { + if (!Utils.tabbedIn()) { + return false; + } + if (holdingBlocks.isToggled()) { + ItemStack held = mc.thePlayer.getHeldItem(); + if (held == null || !(held.getItem() instanceof ItemBlock)) { + return false; + } + } + if (disableForward.isToggled() && mc.thePlayer.moveForward > -0.2) { + return false; + } + if (lookingDown.isToggled() && mc.thePlayer.rotationPitch < 70.0f) { + return false; + } + if (sneakKeyPressed.isToggled() && !Utils.isBindDown(mc.gameSettings.keyBindSneak)) { + return false; + } + else if (!sneakKeyPressed.isToggled() && Utils.isBindDown(mc.gameSettings.keyBindSneak)) { + return false; + } + if (rmbDown.isToggled() && !Utils.keybinds.isMouseDown(1)) { + return false; + } + return true; + } + + private void reset() { + if (!legit.isToggled()) { + return; + } + setSneaking = false; + sneakJumpDelayTicks = unsneakDelayTicks = 0; + sneakJumpStartTick = unsneakStartTick = -1; + if (!wasOn) { + return; + } + wasOn = false; + if (!Utils.tabbedIn()) { + if (mc.thePlayer.isSneaking()) { + Utils.setSneak(false); + } + return; + } + if (mc.thePlayer.isSneaking() && !Utils.sneakDown()) { + Utils.setSneak(false); + } + if (!mc.thePlayer.isSneaking() && Utils.sneakDown()) { + Utils.setSneak(true); + } + } + + @SubscribeEvent + public void onPrePlayerInput(PrePlayerInputEvent e) { + if (!legit.isToggled()) { + return; + } + if (!legitScafSettingsMet()) { + reset(); + return; + } + if (!setSneaking) { + e.setSneak(false); + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!legit.isToggled()) { + return; + } + if (!legitScafSettingsMet()) { + reset(); + return; + } + wasOn = true; + + if (Utils.jumpDown() && mc.thePlayer.onGround && (mc.thePlayer.moveForward != 0 || mc.thePlayer.moveStrafing != 0) && sneakOnJump.getInput() > 0) { + sneakJumpStartTick = mc.thePlayer.ticksExisted; + double raw = sneakOnJump.getInput() / 50; + int base = (int) raw; + sneakJumpDelayTicks = base + (Utils.randomizeDouble(0, 1) < (raw - base) ? 1 : 0); + pressSneak(true); + return; + } + + Vec3 position = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + Simulation sim = Simulation.create(); + if (mc.thePlayer.isSneaking()) { + sim.setForward(mc.thePlayer.moveForward / 0.3f); + sim.setStrafe(mc.thePlayer.moveStrafing / 0.3f); + sim.setSneak(false); + } + sim.tick(); + Vec3 simPosition = sim.getPosition(); + + double edgeOffsetv = computeEdgeOffset(simPosition, position); + if (Double.isNaN(edgeOffsetv)) { + if (setSneaking) tryReleaseSneak(true); + return; + } + + boolean shouldSneak = edgeOffsetv > edgeOffset.getInput(); + boolean shouldRelease = setSneaking; + + if (shouldSneak) { + pressSneak(true); + } else if (shouldRelease) { + tryReleaseSneak(true); + } + } + + private void pressSneak(boolean resetDelay) { + Utils.setSneak(true); + setSneaking = true; + if (resetDelay) { + unsneakStartTick = -1; + } + } + + private void tryReleaseSneak(boolean resetDelay) { + int existed = mc.thePlayer.ticksExisted; + if (unsneakStartTick == -1 && sneakJumpStartTick == -1) { + unsneakStartTick = existed; + double raw = (unsneakDelay.getInput() - 50) / 50; + int base = (int) raw; + unsneakDelayTicks = base + (Utils.randomizeDouble(0, 1) < (raw - base) ? 1 : 0); + } + + if (existed - sneakJumpStartTick < sneakJumpDelayTicks) { + pressSneak(false); + return; + } + if (existed - unsneakStartTick < unsneakDelayTicks) { + pressSneak(false); + return; + } + + releaseSneak(resetDelay); + } + + private void releaseSneak(boolean resetDelay) { + Utils.setSneak(false); + setSneaking = false; + if (resetDelay) { + unsneakStartTick = sneakJumpStartTick = -1; + } + } + + private double computeEdgeOffset(Vec3 pos1, Vec3 pos2) { + int floorY = (int)(pos1.y - 0.01); + double best = Double.NaN; + + for (double[] c : CORNERS) { + int bx = (int)Math.floor(pos2.x + c[0]); + int bz = (int)Math.floor(pos2.z + c[1]); + if (ScriptDefaults.world.getBlockAt(bx, floorY, bz).name.equals("air")) continue; + + double offX = Math.abs(pos1.x - (bx + (pos1.x < bx + 0.5 ? 0 : 1))); + double offZ = Math.abs(pos1.z - (bz + (pos1.z < bz + 0.5 ? 0 : 1))); + boolean xDiff = (int)Math.floor(pos1.x) != bx; + boolean zDiff = (int)Math.floor(pos1.z) != bz; + + double cornerDist; + if (xDiff) { + cornerDist = zDiff ? Math.max(offX, offZ) : offX; + } else { + cornerDist = zDiff ? offZ : 0; + } + + best = Double.isNaN(best) ? cornerDist : Math.min(best, cornerDist); + } + + return best; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java index 9ffa422..159c277 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java +++ b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java @@ -1,1376 +1,1557 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.Raven; -import keystrokesmod.event.*; -import keystrokesmod.mixin.impl.accessor.IAccessorEntityPlayerSP; -import keystrokesmod.mixin.interfaces.IMixinItemRenderer; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.movement.Bhop; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.GroupSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.*; -import keystrokesmod.utility.Timer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockTNT; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.client.C0APacketAnimation; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.*; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; - -public class Scaffold extends Module { - private final SliderSetting motion; - public SliderSetting rotation, fakeRotation; - private SliderSetting sprint; - private SliderSetting floatFirstJump; - private SliderSetting fastScaffold; - private SliderSetting multiPlace; - - public ButtonSetting autoSwap; - private ButtonSetting fastOnRMB; - public ButtonSetting highlightBlocks; - private ButtonSetting jumpFacingForward; - public ButtonSetting safeWalk; - public ButtonSetting showBlockCount; - private ButtonSetting silentSwing; - private ButtonSetting prioritizeSprintWithSpeed; - - private String[] rotationModes = new String[] { "§cDisabled", "Simple", "Offset", "Precise" }; - private String[] fakeRotationModes = new String[] { "§cDisabled", "None", "Strict", "Smooth", "Spin", "Precise" }; - private String[] sprintModes = new String[] { "§cDisabled", "Vanilla", "Float" }; - private String[] fastScaffoldModes = new String[] { "§cDisabled", "Jump A", "Jump B", "Jump B Low", "Jump E", "Keep-Y", "Keep-Y Low" }; - private String[] multiPlaceModes = new String[] { "§cDisabled", "1 extra", "2 extra", "3 extra", "4 extra" }; - - //Highlight blocks - public Map highlight = new HashMap<>(); - public boolean canBlockFade; - - //Block count - private ScaffoldBlockCount scaffoldBlockCount; - - //swapping related - public AtomicInteger lastSlot = new AtomicInteger(-1); - private int spoofSlot; - public boolean hasSwapped; - private int blockSlot = -1; - - //placements related - private boolean hasPlaced, finishProcedure, stopUpdate, stopUpdate2; - private PlaceData lastPlacement; - private EnumFacing[] facings = { EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.UP }; - private BlockPos[] offsets = { new BlockPos(-1, 0, 0), new BlockPos(1, 0, 0), new BlockPos(0, 0, 1), new BlockPos(0, 0, -1), new BlockPos(0, -1, 0) }; - private Vec3 targetBlock; - private PlaceData blockInfo; - private Vec3 blockPos, hitVec, lookVec; - - //bypass related - private boolean rotateForward; - private double startYPos = -1; - public boolean fastScaffoldKeepY; - private boolean firstKeepYPlace; - private boolean rotatingForward; - private int keepYTicks; - public boolean lowhop; - private int rotationDelay; - private boolean floatJumped; - private boolean floatStarted; - private boolean floatWasEnabled; - private boolean floatKeepY; - public int offsetDelay; - public boolean placedVP; - private boolean jump; - private int floatTicks; - - //disable checks - public boolean moduleEnabled; - public boolean isEnabled; - private boolean disabledModule; - private boolean dontDisable, towerEdge; - private int disableTicks; - private int scaffoldTicks; - - //rotation related - private boolean was451, was452; - private float minPitch, minOffset, pOffset; - private float edge; - private long firstStroke, yawEdge, vlS; - private float lastEdge2, yawAngle, theYaw; - private boolean enabledOffGround = false; - private float[] blockRotations; - public float yaw, pitch, blockYaw, yawOffset, lastOffset; - private boolean set2; - private float maxOffset; - private int sameMouse; - private int randomF, yawChanges, dynamic; - private boolean getVTR; - private float VTRY; - private float normalYaw, normalPitch; - private int switchvl; - private int dt; - //fake rotations - private float fakeYaw, fakePitch; - private float fakeYaw1, fakeYaw2; - - - public Scaffold() { - super("Scaffold", category.player); - this.registerSetting(motion = new SliderSetting("Motion", "%", 100, 50, 150, 1)); - this.registerSetting(rotation = new SliderSetting("Rotation", 1, rotationModes)); - this.registerSetting(fakeRotation = new SliderSetting("Rotation (fake)", 0, fakeRotationModes)); - this.registerSetting(sprint = new SliderSetting("Sprint mode", 0, sprintModes)); - this.registerSetting(prioritizeSprintWithSpeed = new ButtonSetting("Prioritize sprint with speed", false)); - this.registerSetting(floatFirstJump = new SliderSetting("§eFloat §rfirst jump speed", "%", 100, 50, 100, 1)); - this.registerSetting(fastScaffold = new SliderSetting("Fast scaffold", 0, fastScaffoldModes)); - - this.registerSetting(multiPlace = new SliderSetting("Multi-place", 0, multiPlaceModes)); - - this.registerSetting(autoSwap = new ButtonSetting("Auto swap", true)); - this.registerSetting(fastOnRMB = new ButtonSetting("Fast on RMB", true)); - this.registerSetting(highlightBlocks = new ButtonSetting("Highlight blocks", true)); - this.registerSetting(jumpFacingForward = new ButtonSetting("Jump facing forward", false)); - this.registerSetting(safeWalk = new ButtonSetting("Safewalk", true)); - this.registerSetting(showBlockCount = new ButtonSetting("Show block count", true)); - this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); - //this.registerSetting(pitchOffset = new SliderSetting("Pitch offset", "", 9, 0, 30, 1)); - - //this.registerSetting(offsetAmount = new SliderSetting("Offset amount", "%", 100, 0, 100, 0.25)); - - this.alwaysOn = true; - } - - public void guiUpdate() { - this.prioritizeSprintWithSpeed.setVisible(sprint.getInput() > 0, this); - this.floatFirstJump.setVisible(sprint.getInput() == 2, this); - } - - public void onDisable() { - if (ModuleManager.tower.canTower() && (ModuleManager.tower.dCount == 0 || !Utils.isMoving())) { - towerEdge = true; - } - disabledModule = true; - moduleEnabled = false; - - if (!isEnabled) { - scaffoldBlockCount.beginFade(); - } - } - - public void onEnable() { - dt = 0; - isEnabled = true; - moduleEnabled = true; - ModuleUtils.fadeEdge = 0; - edge = -999999929; - minPitch = 80F; - if (!mc.thePlayer.onGround) { - rotationDelay = 2; - enabledOffGround = true; - } - lastEdge2 = mc.thePlayer.rotationYaw; - - FMLCommonHandler.instance().bus().register(scaffoldBlockCount = new ScaffoldBlockCount(mc)); - lastSlot.set(-1); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onMouse(MouseEvent e) { - if (!isEnabled) { - return; - } - KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), false); - KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); - e.setCanceled(true); - } - - @SubscribeEvent - public void onPreMotion(PreMotionEvent e) { - if (!Utils.nullCheck()) { - return; - } - normalYaw = mc.thePlayer.rotationYaw; - normalPitch = mc.thePlayer.rotationPitch; - if (dt > 0) { - return; - } - //Fake rotations - if (fakeRotation.getInput() > 0) { - if (fakeRotation.getInput() == 1) { - fakeYaw = normalYaw; - fakePitch = normalPitch; - } else if (fakeRotation.getInput() == 2) { - fakeYaw = fakeYaw1; - if (blockRotations != null) { - fakePitch = blockRotations[1] + 5; - } else { - fakePitch = 80f; - } - } else if (fakeRotation.getInput() == 3) { - fakeYaw2 = mc.thePlayer.rotationYaw - hardcodedYaw(); - float yawDifference = getAngleDifference(lastEdge2, fakeYaw2); - float smoothingFactor = (1.0f - (65.0f / 100.0f)); - fakeYaw2 = (lastEdge2 + yawDifference * smoothingFactor); - lastEdge2 = fakeYaw2; - - fakeYaw = fakeYaw2; - if (blockRotations != null) { - fakePitch = blockRotations[1] + 5; - } else { - fakePitch = 80f; - } - } else if (fakeRotation.getInput() == 4) { - fakeYaw += 25.71428571428571F; - fakePitch = 90F; - } else if (fakeRotation.getInput() == 5) { - if (blockRotations != null) { - fakeYaw2 = blockRotations[0]; - fakePitch = blockRotations[1]; - } else { - fakeYaw2 = mc.thePlayer.rotationYaw - hardcodedYaw() - 180; - fakePitch = 88F; - } - float yawDifference = getAngleDifference(lastEdge2, fakeYaw2); - float smoothingFactor = (1.0f - (65.0f / 100.0f)); - fakeYaw2 = (lastEdge2 + yawDifference * smoothingFactor); - lastEdge2 = fakeYaw2; - - fakeYaw = fakeYaw2; - } - RotationUtils.setFakeRotations(fakeYaw, fakePitch); - } - if (!isEnabled) { - dt++; - return; - } - if (Utils.isMoving()) { - scaffoldTicks++; - } - else { - scaffoldTicks = 0; - } - canBlockFade = true; - if (Utils.keysDown() && usingFastScaffold() && !ModuleManager.invmove.active() && fastScaffold.getInput() >= 1 && !ModuleManager.tower.canTower() && !LongJump.function) { // jump mode - if (mc.thePlayer.onGround && Utils.isMoving()) { - if (scaffoldTicks > 1) { - jump = true; - rotateForward(); - if (startYPos == -1 || Math.abs(startYPos - mc.thePlayer.posY) > 2) { - startYPos = mc.thePlayer.posY; - fastScaffoldKeepY = true; - } - } - } - } - else if (fastScaffoldKeepY) { - fastScaffoldKeepY = firstKeepYPlace = false; - startYPos = -1; - keepYTicks = 0; - } - - //Float - if (sprint.getInput() == 2 && !usingFastScaffold() && !fastScaffoldKeepY && !ModuleManager.tower.canTower() && !LongJump.function) { - floatWasEnabled = true; - if (!floatStarted && offsetDelay == 0) { - if (ModuleUtils.groundTicks > 8 && mc.thePlayer.onGround) { - floatKeepY = true; - startYPos = e.posY; - mc.thePlayer.jump(); - if (Utils.isMoving()) { - double fvl = (getSpeed(getSpeedLevel()) - Utils.randomizeDouble(0.0003, 0.0001)) * (floatFirstJump.getInput() / 100); - Utils.setSpeed(fvl); - } - floatJumped = true; - } else if (ModuleUtils.groundTicks <= 8 && mc.thePlayer.onGround) { - floatStarted = true; - } - if (floatJumped && !mc.thePlayer.onGround) { - floatStarted = true; - } - } - - if (floatStarted && mc.thePlayer.onGround) { - floatKeepY = false; - startYPos = -1; - if (moduleEnabled && mc.thePlayer.posY % 1 == 0) { - ++floatTicks; - if (floatTicks > 1) { - e.setPosY(e.getPosY() + 1e-3); - floatTicks = 0; - } - else { - e.setPosY(e.getPosY() + 1e-6); - } - if (sprint.getInput() == 2 && Utils.isMoving() && !ModuleManager.invmove.active()) Utils.setSpeed(getFloatSpeed(getSpeedLevel())); - ModuleUtils.groundTicks = 0; - offsetDelay = 2; - ModuleManager.tower.delay = true; - ModuleManager.tower.delayTicks = 0; - } - } - } else if (floatWasEnabled && moduleEnabled) { - if (floatKeepY) { - startYPos = -1; - } - floatStarted = floatJumped = floatKeepY = floatWasEnabled = false; - floatTicks = 0; - } - - if (blockRotations != null) { - if (mc.thePlayer.rotationYaw == lastOffset) { - sameMouse++; - } - else { - sameMouse = 0; - yawChanges++; - } - if (sameMouse > 2) { - yawChanges = 0; - } - lastOffset = mc.thePlayer.rotationYaw; - if (yawChanges > 15) { - randomF = 1; - yawEdge = Utils.time(); - } - if (yawEdge > 0 && (Utils.time() - yawEdge) > 500) { - yawEdge = 0; - } - } - else { - fakeYaw1 = mc.thePlayer.rotationYaw - hardcodedYaw(); - } - - dynamic = 0; - if (targetBlock != null) { - Vec3 lookAt = new Vec3(targetBlock.xCoord - lookVec.xCoord, targetBlock.yCoord - lookVec.yCoord, targetBlock.zCoord - lookVec.zCoord); - blockRotations = RotationUtils.getRotations(lookAt); - targetBlock = null; - fakeYaw1 = mc.thePlayer.rotationYaw - hardcodedYaw(); - if (yawEdge == 0) { - randomF = Utils.randomizeInt(0, 9); - yawEdge = Utils.time(); - } - dynamic++; - } - randomF = 0; - } - - @SubscribeEvent - public void onClientRotation(ClientRotationEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (!isEnabled) { - return; - } - - if (jump) { - mc.thePlayer.setSprinting(true); - mc.thePlayer.jump(); - jump = false; - if (rotation.getInput() == 2) { - Utils.setSpeed((getSpeed(getSpeedLevel()) - Utils.randomizeDouble(0.0003, 0.0001) * ModuleUtils.applyFrictionMulti())); - } - if (fastScaffold.getInput() == 6 || fastScaffold.getInput() == 3 && firstKeepYPlace) { - lowhop = true; - } - } - - - switch ((int) rotation.getInput()) { - case 1: - yaw = mc.thePlayer.rotationYaw - hardcodedYaw(); - pitch = 76F; - if (!Utils.isDiagonal(true)) { - //yaw += 45; - } - e.setRotations(yaw, pitch); - break; - case 2: - float moveAngle = (float) getMovementAngle(); - float relativeYaw = mc.thePlayer.rotationYaw + moveAngle; - float normalizedYaw = (relativeYaw % 360 + 360) % 360; - float quad = normalizedYaw % 90; - - float side = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); - float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); - float blockYawOffset = MathHelper.wrapAngleTo180_float(yawBackwards - blockYaw); - - long strokeDelay = 250; - - float first = 77.5F; - float sec = 77.5F; - - if (quad <= 5 || quad >= 85) { - yawAngle = 123.425F; - minOffset = 11; - minPitch = first; - } - if (quad > 5 && quad <= 15 || quad >= 75 && quad < 85) { - yawAngle = 125.825F; - minOffset = 9; - minPitch = first; - } - if (quad > 15 && quad <= 25 || quad >= 65 && quad < 75) { - yawAngle = 128.625F; - minOffset = 8; - minPitch = first; - } - if (quad > 25 && quad <= 32 || quad >= 58 && quad < 65) { - yawAngle = 131.625F; - minOffset = 7; - minPitch = sec; - } - if (quad > 32 && quad <= 38 || quad >= 52 && quad < 58) { - yawAngle = 133.825F; - minOffset = 6; - minPitch = sec; - } - if (quad > 38 && quad <= 42 || quad >= 48 && quad < 52) { - yawAngle = 135.825F; - minOffset = 4; - minPitch = sec; - } - if (quad > 42 && quad <= 45 || quad >= 45 && quad < 48) { - yawAngle = 138.125F; - minOffset = 3; - minPitch = sec; - } - //Utils.print("" + minOffset); - //float offsetAmountD = ((((float) offsetAmount.getInput() / 10) - 10) * -2) - (((float) offsetAmount.getInput() / 10) - 10); - //yawAngle += offsetAmountD; - //Utils.print("" + offsetAmountD); - - float offset = yawAngle;//(!Utils.scaffoldDiagonal(false)) ? 125.500F : 143.500F; - - - float nigger = 0; - - if (quad > 45) { - nigger = 10; - } - else { - nigger = -10; - } - if (switchvl > 0) { - /*if (vlS > 0 && (System.currentTimeMillis() - vlS) > strokeDelay && firstStroke == 0) { - switchvl = 0; - vlS = 0; - }*/ - //if (switchvl > 0) { - firstStroke = Utils.time(); - switchvl = 0; - vlS = 0; - //} - } - else { - vlS = Utils.time(); - } - if (firstStroke > 0 && (System.currentTimeMillis() - firstStroke) > strokeDelay) { - firstStroke = 0; - } - if (Utils.fallDist() <= 2 && Utils.getHorizontalSpeed() > 0.1) { - enabledOffGround = false; - } - if (enabledOffGround) { - if (blockRotations != null) { - yaw = blockRotations[0]; - pitch = blockRotations[1]; - } else { - yaw = mc.thePlayer.rotationYaw - hardcodedYaw() - nigger; - pitch = minPitch; - } - e.setRotations(yaw, pitch); - break; - } - - if (blockRotations != null) { - blockYaw = blockRotations[0]; - pitch = blockRotations[1]; - yawOffset = blockYawOffset; - if (pitch < minPitch) { - pitch = minPitch; - } - } else { - pitch = minPitch; - if (edge == 1 && ((quad <= 5 || quad >= 85) && !Utils.scaffoldDiagonal(false))) { - firstStroke = Utils.time(); - } - yawOffset = 5; - dynamic = 2; - } - - if (!Utils.isMoving() || Utils.getHorizontalSpeed() == 0.0D) { - e.setRotations(theYaw, pitch); - break; - } - - float motionYaw = getMotionYaw(); - - float newYaw = motionYaw - offset * Math.signum( - MathHelper.wrapAngleTo180_float(motionYaw - yaw) - ); - yaw = MathHelper.wrapAngleTo180_float(newYaw); - - if (quad > 5 && quad < 85 && dynamic > 0) { - if (quad < 45F) { - if (firstStroke == 0) { - if (side >= 0) { - set2 = false; - } else { - set2 = true; - } - } - if (was452) { - switchvl++; - } - was451 = true; - was452 = false; - } else { - if (firstStroke == 0) { - if (side >= 0) { - set2 = true; - } else { - set2 = false; - } - } - if (was451) { - switchvl++; - } - was452 = true; - was451 = false; - } - } - double minSwitch = (!Utils.scaffoldDiagonal(false)) ? 9 : 15; - if (side >= 0) { - if (yawOffset <= -minSwitch && firstStroke == 0 && dynamic > 0) { - if (quad <= 5 || quad >= 85) { - if (set2) { - switchvl++; - } - set2 = false; - } - } else if (yawOffset >= 0 && firstStroke == 0 && dynamic > 0) { - if (quad <= 5 || quad >= 85) { - if (yawOffset >= minSwitch) { - if (!set2) { - switchvl++; - } - set2 = true; - } - } - } - if (set2) { - if (yawOffset <= -0) yawOffset = -0; - if (yawOffset >= minOffset) yawOffset = minOffset; - theYaw = (yaw + offset * 2) - yawOffset; - e.setRotations(theYaw, pitch); - break; - } - } else if (side <= -0) { - if (yawOffset >= minSwitch && firstStroke == 0 && dynamic > 0) { - if (quad <= 5 || quad >= 85) { - if (set2) { - switchvl++; - } - set2 = false; - } - } else if (yawOffset <= 0 && firstStroke == 0 && dynamic > 0) { - if (quad <= 5 || quad >= 85) { - if (yawOffset <= -minSwitch) { - if (!set2) { - switchvl++; - } - set2 = true; - } - } - } - if (set2) { - if (yawOffset >= 0) yawOffset = 0; - if (yawOffset <= -minOffset) yawOffset = -minOffset; - theYaw = (yaw - offset * 2) - yawOffset; - e.setRotations(theYaw, pitch); - break; - } - } - - if (side >= 0) { - if (yawOffset >= 0) yawOffset = 0; - if (yawOffset <= -minOffset) yawOffset = -minOffset; - } else if (side <= -0) { - if (yawOffset <= -0) yawOffset = -0; - if (yawOffset >= minOffset) yawOffset = minOffset; - } - theYaw = yaw - yawOffset; - e.setRotations(theYaw, pitch); - break; - case 3: - if (blockRotations != null) { - yaw = blockRotations[0]; - pitch = blockRotations[1]; - } - else { - yaw = mc.thePlayer.rotationYaw - hardcodedYaw(); - pitch = 80F; - } - e.setRotations(yaw, pitch); - theYaw = yaw; - break; - } - if (edge != 1) { - switchvl++; - edge = 1; - } - if (mc.thePlayer.onGround) { - enabledOffGround = false; - } - - //jump facing forward - if (rotationDelay > 0) --rotationDelay; - if (!mc.thePlayer.onGround) { - rotateForward = false; - } - if (rotateForward && jumpFacingForward.isToggled()) { - if (rotation.getInput() > 0) { - if (!rotatingForward) { - rotationDelay = 2; - rotatingForward = true; - } - float forwardYaw = (mc.thePlayer.rotationYaw - hardcodedYaw() - 180); - e.setYaw(forwardYaw); - e.setPitch(10F); - } - } - else { - rotatingForward = false; - } - - if (rotation.getInput() == 2 && mc.thePlayer.motionX == 0.0D && mc.thePlayer.motionZ == 0.0D) { - if (blockRotations != null) { - e.setYaw(blockRotations[0]); - } - } - - if (ModuleManager.tower.isVerticalTowering()) { - if (blockRotations != null && (!getVTR || ModuleManager.tower.ebDelay <= 1 || !ModuleManager.tower.firstVTP)) { - VTRY = blockRotations[0]; - getVTR = true; - } - if (getVTR) { - e.setYaw(VTRY); - } - if (ModuleManager.tower.yaw != 0) { - e.setYaw(ModuleManager.tower.yaw); - } - if (ModuleManager.tower.pitch != 0) { - e.setPitch(ModuleManager.tower.pitch); - } - } - else { - getVTR = false; - } - } - - @SubscribeEvent - public void onPostPlayerInput(PostPlayerInputEvent e) { - if (!ModuleManager.scaffold.isEnabled) { - return; - } - if (!fastScaffoldKeepY && !floatKeepY) { - return; - } - mc.thePlayer.movementInput.jump = false; - } - - @SubscribeEvent - public void onSlotUpdate(SlotUpdateEvent e) { - if (isEnabled && autoSwap.isToggled()) { - lastSlot.set(e.slot); - e.setCanceled(true); - } - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - stopUpdate = stopUpdate2 = false; - if (!isEnabled) { - stopUpdate2 = true; - } - if (LongJump.function) { - startYPos = -1; - } - if (LongJump.stopModules) { - stopUpdate2 = true; - } - if (!stopUpdate2) { - if (holdingBlocks() && setSlot()) { - /*if (moduleEnabled && !finishProcedure) { - if (Utils.distanceToGround(mc.thePlayer) < 2) { - finishProcedure = true; - } - if (Utils.distanceToGround(mc.thePlayer) > 6) { - if (hasPlaced) { - finishProcedure = true; - } - } else if (!finishProcedure) { - stopUpdate = true; - } - }*/ - if (!stopUpdate) { - hasSwapped = true; - int mode = (int) fastScaffold.getInput(); - if (!ModuleManager.tower.placeExtraBlock) { - if (rotation.getInput() == 0 || rotationDelay == 0) { - placeBlock(0, 0); - } - } else if ((ModuleManager.tower.ebDelay == 0 || !ModuleManager.tower.firstVTP)) { - placeBlock(0, 0); - placedVP = true; - } - if (ModuleManager.tower.placeExtraBlock) { - placeBlock(0, -1); - } - - if (fastScaffoldKeepY && !ModuleManager.tower.canTower()) { - ++keepYTicks; - if ((int) mc.thePlayer.posY > (int) startYPos) { - switch (mode) { - case 1: - if (!firstKeepYPlace && keepYTicks == 3) { - placeBlock(1, 0); - firstKeepYPlace = true; - } - break; - case 2: - if (!firstKeepYPlace && keepYTicks == 8 || keepYTicks == 11) { - placeBlock(1, 0); - firstKeepYPlace = true; - } - break; - case 3: - if (!firstKeepYPlace && keepYTicks == 8 || firstKeepYPlace && keepYTicks == 7) { - placeBlock(1, 0); - firstKeepYPlace = true; - } - break; - case 4: - if (!firstKeepYPlace && keepYTicks == 7) { - placeBlock(1, 0); - firstKeepYPlace = true; - } - break; - } - } - if (mc.thePlayer.onGround) keepYTicks = 0; - if ((int) mc.thePlayer.posY == (int) startYPos) firstKeepYPlace = false; - } - handleMotion(); - } - } - } - - if (disabledModule) { - if (hasPlaced && (towerEdge || floatStarted && Utils.isMoving())) { - dontDisable = true; - } - - if (dontDisable && ++disableTicks >= 2) { - isEnabled = false; - //Utils.print("Extra tick"); - } - if (!dontDisable) { - isEnabled = false; - } - - - if (!isEnabled) { - disabledModule = dontDisable = false; - disableTicks = 0; - - if (ModuleManager.tower.speed) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer) / 1.6); - } - - if (lastSlot.get() != -1) { - mc.thePlayer.inventory.currentItem = lastSlot.get(); - lastSlot.set(-1); - } - blockSlot = -1; - if (autoSwap.isToggled() && ModuleManager.autoSwap.spoofItem.isToggled()) { - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(false); - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(false); - } - if (offsetDelay > 0) { - ModuleManager.sprint.requireJump = false; - } - scaffoldBlockCount.beginFade(); - hasSwapped = hasPlaced = false; - targetBlock = null; - blockInfo = null; - blockRotations = null; - fastScaffoldKeepY = firstKeepYPlace = rotateForward = rotatingForward = floatStarted = floatJumped = floatWasEnabled = towerEdge = - was451 = was452 = enabledOffGround = finishProcedure = jump = false; - rotationDelay = keepYTicks = scaffoldTicks = floatTicks = 0; - firstStroke = vlS = 0; - startYPos = -1; - lookVec = null; - lastPlacement = null; - } - } - } - - @Override - public String getInfo() { - String info; - if (fastOnRMB.isToggled()) { - info = fastOnRMB() ? fastScaffoldModes[(int) fastScaffold.getInput()] : sprintModes[(int) sprint.getInput()]; - } - else { - info = fastScaffold.getInput() > 0 ? fastScaffoldModes[(int) fastScaffold.getInput()] : sprintModes[(int) sprint.getInput()]; - } - return info; - } - - public boolean stopFastPlace() { - return this.isEnabled(); - } - - float getAngleDifference(float from, float to) { - float difference = (to - from) % 360.0F; - if (difference < -180.0F) { - difference += 360.0F; - } else if (difference >= 180.0F) { - difference -= 360.0F; - } - return difference; - } - - public void rotateForward() { - rotateForward = true; - rotatingForward = false; - } - - public boolean blockAbove() { - return !(BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY + 2, mc.thePlayer.posZ)) instanceof BlockAir); - } - - public boolean sprint() { - if (isEnabled) { - return handleFastScaffolds() > 0; - } - return false; - } - - private int handleFastScaffolds() { - if (fastOnRMB.isToggled()) { - return fastScaffold.getInput() > 0 && fastOnRMB() ? (int) fastScaffold.getInput() : (int) sprint.getInput(); - } - else { - return fastScaffold.getInput() > 0 ? (int) fastScaffold.getInput() : (int) sprint.getInput(); - } - } - - private boolean usingFloat() { - return sprint.getInput() == 2 && Utils.isMoving() && !usingFastScaffold(); - } - - public boolean usingFastScaffold() { - return fastScaffold.getInput() > 0 && (!fastOnRMB.isToggled() || fastOnRMB() && Utils.tabbedIn()) && !prioritizeSprint(); - } - - public boolean fastOnRMB() { - return fastOnRMB.isToggled() && Utils.tabbedIn() && (Mouse.isButtonDown(1) || ModuleManager.bhop.isEnabled() || defPS()); - } - - private boolean defPS() { - return prioritizeSprintWithSpeed.isToggled() && (sprint.getInput() == 0 || getSpeedLevel() == 0); - } - - private boolean prioritizeSprint() { - return prioritizeSprintWithSpeed.isToggled() && sprint.getInput() > 0 && getSpeedLevel() > 0 && !fastOnRMB(); - } - - public boolean safewalk() { - return this.isEnabled() && safeWalk.isToggled(); - } - - public boolean stopRotation() { - return this.isEnabled() && rotation.getInput() > 0; - } - - private void place(PlaceData block) { - ItemStack heldItem = mc.thePlayer.getHeldItem(); - if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { - return; - } - if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, heldItem, block.blockPos, block.enumFacing, block.hitVec)) { - if (silentSwing.isToggled()) { - mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); - } - else { - mc.thePlayer.swingItem(); - if (holdingBlocks()) { - mc.getItemRenderer().resetEquippedProgress(); - } - } - if (ModuleManager.tower.placeExtraBlock) { - ModuleManager.tower.firstVTP = true; - } - highlight.put(block.blockPos.offset(block.enumFacing), null); - hasPlaced = true; - } - } - - public boolean canSafewalk() { - if (!safeWalk.isToggled()) { - return false; - } - if (usingFastScaffold()) { - return false; - } - if (ModuleManager.tower.canTower()) { - return false; - } - if (!isEnabled) { - return false; - } - return true; - } - - public int totalBlocks() { - int totalBlocks = 0; - for (int i = 0; i < 9; ++i) { - final ItemStack stack = mc.thePlayer.inventory.mainInventory[i]; - if (stack != null && stack.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) stack.getItem()) && stack.stackSize > 0) { - totalBlocks += stack.stackSize; - } - } - return totalBlocks; - } - - private void placeBlock(int yOffset, int xOffset) { - locateAndPlaceBlock(yOffset, xOffset); - int input = (int) multiPlace.getInput(); - if (input >= 1) { - locateAndPlaceBlock(yOffset, xOffset); - if (input >= 2) { - locateAndPlaceBlock(yOffset, xOffset); - if (input >= 3) { - locateAndPlaceBlock(yOffset, xOffset); - if (input >= 4) { - locateAndPlaceBlock(yOffset, xOffset); - } - } - } - } - } - - private void locateAndPlaceBlock(int yOffset, int xOffset) { - locateBlocks(yOffset, xOffset); - if (blockInfo == null) { - return; - } - lastPlacement = blockInfo; - place(blockInfo); - blockInfo = null; - } - - private void locateBlocks(int yOffset, int xOffset) { - List blocksInfo = findBlocks(yOffset, xOffset); - - if (blocksInfo == null) { - return; - } - - double sumX = 0, sumY = !mc.thePlayer.onGround ? 0 : blocksInfo.get(0).blockPos.getY(), sumZ = 0; - int index = 0; - for (PlaceData blockssInfo : blocksInfo) { - if (index > 1 || (!Utils.isDiagonal(false) && index > 0 && mc.thePlayer.onGround)) { - break; - } - sumX += blockssInfo.blockPos.getX(); - if (!mc.thePlayer.onGround) { - sumY += blockssInfo.blockPos.getY(); - } - sumZ += blockssInfo.blockPos.getZ(); - index++; - } - - double avgX = sumX / index; - double avgY = !mc.thePlayer.onGround ? sumY / index : blocksInfo.get(0).blockPos.getY(); - double avgZ = sumZ / index; - - targetBlock = new Vec3(avgX, avgY, avgZ); - - PlaceData blockInfo2 = blocksInfo.get(0); - int blockX = blockInfo2.blockPos.getX(); - int blockY = blockInfo2.blockPos.getY(); - int blockZ = blockInfo2.blockPos.getZ(); - EnumFacing blockFacing = blockInfo2.enumFacing; - blockInfo = blockInfo2; - - double hitX = (blockX + 0.5D) + getCoord(blockFacing.getOpposite(), "x") * 0.5D; - double hitY = (blockY + 0.5D) + getCoord(blockFacing.getOpposite(), "y") * 0.5D; - double hitZ = (blockZ + 0.5D) + getCoord(blockFacing.getOpposite(), "z") * 0.5D; - lookVec = new Vec3(0.5D + getCoord(blockFacing.getOpposite(), "x") * 0.5D, 0.5D + getCoord(blockFacing.getOpposite(), "y") * 0.5D, 0.5D + getCoord(blockFacing.getOpposite(), "z") * 0.5D); - hitVec = new Vec3(hitX, hitY, hitZ); - blockInfo.hitVec = hitVec; - } - - private double getCoord(EnumFacing facing, String axis) { - switch (axis) { - case "x": return (facing == EnumFacing.WEST) ? -0.5 : (facing == EnumFacing.EAST) ? 0.5 : 0; - case "y": return (facing == EnumFacing.DOWN) ? -0.5 : (facing == EnumFacing.UP) ? 0.5 : 0; - case "z": return (facing == EnumFacing.NORTH) ? -0.5 : (facing == EnumFacing.SOUTH) ? 0.5 : 0; - } - return 0; - } - - private List findBlocks(int yOffset, int xOffset) { - int x = (int) Math.floor(mc.thePlayer.posX + xOffset); - int y = (int) Math.floor(((startYPos != -1) ? startYPos : mc.thePlayer.posY) + yOffset); - int z = (int) Math.floor(mc.thePlayer.posZ); - - BlockPos base = new BlockPos(x, y - 1, z); - - if (!BlockUtils.replaceable(base)) { - return null; - } - - EnumFacing[] allFacings = getFacingsSorted(); - List validFacings = new ArrayList<>(5); - for (EnumFacing facing : allFacings) { - if (facing != EnumFacing.UP && placeConditions(facing, yOffset, xOffset)) { - validFacings.add(facing); - } - } - int maxLayer = 1; - List possibleBlocks = new ArrayList<>(); - - for (int dy = 1; dy <= maxLayer; dy++) { - BlockPos layerBase = new BlockPos(x, y - dy, z); - if (dy == 1) { - for (EnumFacing facing : validFacings) { - BlockPos neighbor = layerBase.offset(facing); - if (!BlockUtils.replaceable(neighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(neighbor))) { - possibleBlocks.add(new PlaceData(neighbor, facing.getOpposite())); - } - } - } - for (EnumFacing facing : validFacings) { - BlockPos adjacent = layerBase.offset(facing); - if (BlockUtils.replaceable(adjacent)) { - for (EnumFacing nestedFacing : validFacings) { - BlockPos nestedNeighbor = adjacent.offset(nestedFacing); - if (!BlockUtils.replaceable(nestedNeighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(nestedNeighbor))) { - possibleBlocks.add(new PlaceData(nestedNeighbor, nestedFacing.getOpposite())); - } - } - } - } - for (EnumFacing facing : validFacings) { - BlockPos adjacent = layerBase.offset(facing); - if (BlockUtils.replaceable(adjacent)) { - for (EnumFacing nestedFacing : validFacings) { - BlockPos nestedNeighbor = adjacent.offset(nestedFacing); - if (BlockUtils.replaceable(nestedNeighbor)) { - for (EnumFacing thirdFacing : validFacings) { - BlockPos thirdNeighbor = nestedNeighbor.offset(thirdFacing); - if (!BlockUtils.replaceable(thirdNeighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(thirdNeighbor))) { - possibleBlocks.add(new PlaceData(thirdNeighbor, thirdFacing.getOpposite())); - } - } - } - } - } - } - } - - return possibleBlocks.isEmpty() ? null : possibleBlocks; - } - - private EnumFacing[] getFacingsSorted() { - EnumFacing lastFacing = EnumFacing.getHorizontal(MathHelper.floor_double((((IAccessorEntityPlayerSP)mc.thePlayer).getLastReportedYaw() * 4.0F / 360.0F) + 0.5D) & 3); - - EnumFacing perpClockwise = lastFacing.rotateY(); - EnumFacing perpCounterClockwise = lastFacing.rotateYCCW(); - - EnumFacing opposite = lastFacing.getOpposite(); - - float yaw = ((IAccessorEntityPlayerSP)mc.thePlayer).getLastReportedYaw() % 360; - if (yaw > 180) { - yaw -= 360; - } - else if (yaw < -180) { - yaw += 360; - } - - // Calculates the difference from the last placed angle and gets the closest one - float diffClockwise = Math.abs(MathHelper.wrapAngleTo180_float(yaw - getFacingAngle(perpClockwise))); - float diffCounterClockwise = Math.abs(MathHelper.wrapAngleTo180_float(yaw - getFacingAngle(perpCounterClockwise))); - - EnumFacing firstPerp, secondPerp; - if (diffClockwise <= diffCounterClockwise) { - firstPerp = perpClockwise; - secondPerp = perpCounterClockwise; - } - else { - firstPerp = perpCounterClockwise; - secondPerp = perpClockwise; - } - - return new EnumFacing[]{EnumFacing.UP, EnumFacing.DOWN, lastFacing, firstPerp, secondPerp, opposite}; - } - - private float getFacingAngle(EnumFacing facing) { - switch (facing) { - case WEST: - return 90; - case NORTH: - return 180; - case EAST: - return -90; - default: - return 0; - } - } - - private boolean placeConditions(EnumFacing enumFacing, int yCondition, int xCondition) { - if (xCondition == -1) { - if (!ModuleManager.tower.placeExtraBlock) { - return enumFacing == EnumFacing.EAST; - } - else { - return enumFacing == EnumFacing.DOWN; - } - } - else if (ModuleManager.tower.placeExtraBlock) { - return enumFacing == EnumFacing.WEST; - } - if (yCondition == 1) { - return enumFacing == EnumFacing.DOWN; - } - return true; - } - - /*private boolean allowedFaces(EnumFacing enumFacing) { - if (yaw >= 0 && yaw < 90) { - //Utils.print("1"); - //west south - return enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.WEST || enumFacing == EnumFacing.SOUTH; - } - else if (yaw >= 90 && yaw < 180) { - //Utils.print("2"); - //north west - return enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.NORTH || enumFacing == EnumFacing.WEST; - } - else if (yaw == 180 || yaw >= -180 && yaw < -90) { - //Utils.print("3"); - //north east - return enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.NORTH || enumFacing == EnumFacing.EAST; - } - else if (yaw >= -90 && yaw <= 0) { - //Utils.print("4"); - //east south - return enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.EAST || enumFacing == EnumFacing.SOUTH; - } - - return false; - }*/ - - float applyGcd(float value) { - float gcd = 0.2F * 0.2F * 0.2F * 8.0F; - return (float) ((double) value - (double) value % ((double) gcd * 0.15D)); - } - - public float getMotionYaw() { - return (float) Math.toDegrees(Math.atan2(mc.thePlayer.motionZ, mc.thePlayer.motionX)) - 90.0F; - } - - private int getSpeedLevel() { - for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { - if (potionEffect.getEffectName().equals("potion.moveSpeed")) { - return potionEffect.getAmplifier() + 1; - } - return 0; - } - return 0; - } - - double[] speedLevels = {0.48, 0.5, 0.52, 0.58, 0.68}; - - double getSpeed(int speedLevel) { - if (speedLevel >= 0) { - return speedLevels[speedLevel]; - } - return speedLevels[0]; - } - - double[] floatSpeedLevels = {0.2, 0.22, 0.265, 0.29, 0.3}; - - double getFloatSpeed(int speedLevel) { - double min = 0; - double value = 0; - double input = (motion.getInput() / 100); - if (mc.thePlayer.moveStrafing != 0 && mc.thePlayer.moveForward != 0) min = 0.003; - value = floatSpeedLevels[0] - min; - if (speedLevel >= 0) { - value = (speedLevel == 2 ? (Utils.scaffoldDiagonal(false) ? 0.265 : 0.275) : floatSpeedLevels[speedLevel]) - min; - } - value *= input; - return value; - } - - private void handleMotion() { - if (usingFastScaffold() || usingFloat() || ModuleManager.tower.canTower() || motion.getInput() == 100 || !mc.thePlayer.onGround) { - return; - } - double input = (motion.getInput() / 100); - mc.thePlayer.motionX *= input; - mc.thePlayer.motionZ *= input; - } - - public float hardcodedYaw() { - float simpleYaw = 0F; - - boolean w = Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode()); - boolean s = Keyboard.isKeyDown(mc.gameSettings.keyBindBack.getKeyCode()); - boolean a = Keyboard.isKeyDown(mc.gameSettings.keyBindLeft.getKeyCode()); - boolean d = Keyboard.isKeyDown(mc.gameSettings.keyBindRight.getKeyCode()); - - boolean dupe = a & d; - - if (w) { - simpleYaw -= 180; - if (!dupe) { - if (a) simpleYaw += 45; - if (d) simpleYaw -= 45; - } - } - else if (!s) { - simpleYaw -= 180; - if (!dupe) { - if (a) simpleYaw += 90; - if (d) simpleYaw -= 90; - } - } - else if (!w) { - if (!dupe) { - if (a) simpleYaw -= 45; - if (d) simpleYaw += 45; - } - } - return simpleYaw; - } - - public boolean holdingBlocks() { - ItemStack heldItem = mc.thePlayer.getHeldItem(); - if (autoSwap.isToggled() && ModuleManager.autoSwap.spoofItem.isToggled() && lastSlot.get() != mc.thePlayer.inventory.currentItem && totalBlocks() > 0) { - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); - ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); - } - if (!autoSwap.isToggled() || getSlot() == -1) { - if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { - return false; - } - } - return true; - } - - private double getMovementAngle() { - double angle = Math.toDegrees(Math.atan2(-mc.thePlayer.moveStrafing, mc.thePlayer.moveForward)); - return angle == -0 ? 0 : angle; - } - - private int getSlot() { - int slot = -1; - int highestStack = -1; - ItemStack heldItem = mc.thePlayer.getHeldItem(); - for (int i = 0; i < 9; ++i) { - final ItemStack itemStack = mc.thePlayer.inventory.mainInventory[i]; - if (itemStack != null && itemStack.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) itemStack.getItem()) && itemStack.stackSize > 0) { - if (Utils.getBedwarsStatus() == 2 && ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockTNT) { - continue; - } - if (itemStack != null && heldItem != null && (heldItem.getItem() instanceof ItemBlock) && Utils.canBePlaced((ItemBlock) heldItem.getItem()) && ModuleManager.autoSwap.sameType.isToggled() && !(itemStack.getItem().getClass().equals(heldItem.getItem().getClass()))) { - continue; - } - if (itemStack.stackSize > highestStack) { - highestStack = itemStack.stackSize; - slot = i; - } - } - } - return slot; - } - - public static boolean bypassRots() { - return (ModuleManager.scaffold.rotation.getInput() == 2 || ModuleManager.scaffold.rotation.getInput() == 0); - } - - public boolean setSlot() { - ItemStack heldItem = mc.thePlayer.getHeldItem(); - int slot = getSlot(); - if (slot == -1) { - return false; - } - if (blockSlot == -1) { - blockSlot = slot; - } - if (lastSlot.get() == -1) { - lastSlot.set(mc.thePlayer.inventory.currentItem); - } - if (autoSwap.isToggled() && blockSlot != -1) { - if (ModuleManager.autoSwap.swapToGreaterStack.isToggled()) { - mc.thePlayer.inventory.currentItem = slot; - spoofSlot = slot; - } - else { - if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem()) || mc.thePlayer.getHeldItem().stackSize <= ModuleManager.autoSwap.swapAt.getInput()) { - mc.thePlayer.inventory.currentItem = slot; - spoofSlot = slot; - } - } - } - - if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { - blockSlot = -1; - return false; - } - return true; - } - - - static class PlaceData { - EnumFacing enumFacing; - BlockPos blockPos; - Vec3 hitVec; - - PlaceData(BlockPos blockPos, EnumFacing enumFacing) { - this.enumFacing = enumFacing; - this.blockPos = blockPos; - } - - public PlaceData(EnumFacing enumFacing, BlockPos blockPos) { - this.enumFacing = enumFacing; - this.blockPos = blockPos; - } - } +package keystrokesmod.module.impl.player; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.mixin.impl.accessor.IAccessorEntityPlayerSP; +import keystrokesmod.mixin.interfaces.IMixinItemRenderer; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.module.impl.movement.Bhop; +import keystrokesmod.module.impl.movement.LongJump; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.GroupSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import keystrokesmod.utility.Timer; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockTNT; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.*; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +public class Scaffold extends Module { + private final SliderSetting motion; + public SliderSetting rotation, fakeRotation; + private SliderSetting sprint; + private SliderSetting floatFirstJump; + private SliderSetting fastScaffold; + private SliderSetting multiPlace; + + public ButtonSetting autoSwap; + private ButtonSetting fastOnRMB; + public ButtonSetting highlightBlocks; + private ButtonSetting jumpFacingForward; + public ButtonSetting safeWalk; + public ButtonSetting showBlockCount; + private ButtonSetting silentSwing; + private ButtonSetting prioritizeSprintWithSpeed; + + private String[] rotationModes = new String[] { "§cDisabled", "Simple", "Offset", "Precise" }; + private String[] fakeRotationModes = new String[] { "§cDisabled", "None", "Strict", "Smooth", "Spin", "Precise" }; + private String[] sprintModes = new String[] { "§cDisabled", "Vanilla", "Float" }; + private String[] fastScaffoldModes = new String[] { "§cDisabled", "Jump A", "Jump B", "Jump B Low", "Jump E", "Keep-Y", "Keep-Y Low" }; + private String[] multiPlaceModes = new String[] { "§cDisabled", "1 extra", "2 extra", "3 extra", "4 extra" }; + + //Highlight blocks + public Map highlight = new HashMap<>(); + public boolean canBlockFade; + + //Block count + private ScaffoldBlockCount scaffoldBlockCount; + + //swapping related + public AtomicInteger lastSlot = new AtomicInteger(-1); + private int spoofSlot; + public boolean hasSwapped; + private int blockSlot = -1; + + //placements related + private boolean hasPlaced, finishProcedure, stopUpdate, stopUpdate2; + private PlaceData lastPlacement; + private EnumFacing[] facings = { EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.UP }; + private BlockPos[] offsets = { new BlockPos(-1, 0, 0), new BlockPos(1, 0, 0), new BlockPos(0, 0, 1), new BlockPos(0, 0, -1), new BlockPos(0, -1, 0) }; + private Vec3 targetBlock; + private PlaceData blockInfo; + private Vec3 blockPos, hitVec, lookVec; + + //bypass related + private boolean rotateForward; + private double startYPos = -1; + public boolean fastScaffoldKeepY; + private boolean firstKeepYPlace; + private boolean rotatingForward; + private int keepYTicks; + public boolean lowhop; + private int rotationDelay; + private boolean floatJumped; + private boolean floatStarted; + private boolean floatWasEnabled; + private boolean floatKeepY; + public int offsetDelay; + public boolean placedVP; + private boolean jump; + private int floatTicks; + public boolean blink; + + //disable checks + public boolean moduleEnabled; + public boolean isEnabled; + private boolean disabledModule; + private boolean dontDisable, towerEdge; + private int disableTicks; + private int scaffoldTicks; + + //rotation related + private boolean was451, was452; + private float minPitch, minOffset, pOffset; + private float edge; + private long firstStroke, yawEdge, vlS, swDelay; + private float lastEdge2, yawAngle, theYaw; + private boolean enabledOffGround = false; + private float[] blockRotations; + public float yaw, pitch, blockYaw, yawOffset, lastOffset; + private boolean set2; + private float maxOffset; + private int sameMouse; + private int randomF, yawChanges, dynamic; + private boolean getVTR, resetm; + private float VTRY; + private float normalYaw, normalPitch; + private int switchvl; + private int dt; + private float getSmooth, lastYawS, smoothedYaw; + private boolean neg; + private float yawWithOffset; + private int rt; + //fake rotations + private float fakeYaw, fakePitch; + private float fakeYaw1, fakeYaw2; + + + public Scaffold() { + super("Scaffold", category.player); + this.registerSetting(motion = new SliderSetting("Motion", "%", 100, 50, 150, 1)); + this.registerSetting(rotation = new SliderSetting("Rotation", 1, rotationModes)); + this.registerSetting(fakeRotation = new SliderSetting("Rotation (fake)", 0, fakeRotationModes)); + this.registerSetting(sprint = new SliderSetting("Sprint mode", 0, sprintModes)); + this.registerSetting(prioritizeSprintWithSpeed = new ButtonSetting("Prioritize sprint with speed", false)); + this.registerSetting(floatFirstJump = new SliderSetting("§eFloat §rfirst jump speed", "%", 100, 50, 100, 1)); + this.registerSetting(fastScaffold = new SliderSetting("Fast scaffold", 0, fastScaffoldModes)); + + this.registerSetting(multiPlace = new SliderSetting("Multi-place", 0, multiPlaceModes)); + + this.registerSetting(autoSwap = new ButtonSetting("Auto swap", true)); + this.registerSetting(fastOnRMB = new ButtonSetting("Fast on RMB", true)); + this.registerSetting(highlightBlocks = new ButtonSetting("Highlight blocks", true)); + this.registerSetting(jumpFacingForward = new ButtonSetting("Jump facing forward", false)); + this.registerSetting(safeWalk = new ButtonSetting("Safewalk", true)); + this.registerSetting(showBlockCount = new ButtonSetting("Show block count", true)); + this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false)); + //this.registerSetting(pitchOffset = new SliderSetting("Pitch offset", "", 9, 0, 30, 1)); + + //this.registerSetting(offsetAmount = new SliderSetting("Offset amount", "%", 100, 0, 100, 0.25)); + + this.alwaysOn = true; + } + + public void guiUpdate() { + this.prioritizeSprintWithSpeed.setVisible(sprint.getInput() > 0, this); + this.floatFirstJump.setVisible(sprint.getInput() == 2, this); + } + + public void onDisable() { + if (ModuleManager.tower.canTower() && (ModuleManager.tower.dCount == 0 || !Utils.isMoving())) { + towerEdge = true; + } + disabledModule = true; + moduleEnabled = false; + + if (!isEnabled) { + scaffoldBlockCount.beginFade(); + } + } + + public void onEnable() { + dt = 0; + isEnabled = true; + moduleEnabled = true; + ModuleUtils.fadeEdge = 0; + edge = -999999929; + minPitch = 80F; + if (!mc.thePlayer.onGround) { + rotationDelay = 2; + enabledOffGround = true; + } + lastEdge2 = mc.thePlayer.rotationYaw; + + FMLCommonHandler.instance().bus().register(scaffoldBlockCount = new ScaffoldBlockCount(mc)); + lastSlot.set(-1); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onMouse(MouseEvent e) { + if (!isEnabled) { + return; + } + if (e.button == 0 || e.button == 1) { + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent e) { + if (!Utils.nullCheck()) { + return; + } + normalYaw = mc.thePlayer.rotationYaw; + normalPitch = mc.thePlayer.rotationPitch; + if (dt > 0) { + return; + } + //Fake rotations + if (fakeRotation.getInput() > 0) { + if (fakeRotation.getInput() == 1) { + fakeYaw = normalYaw; + fakePitch = normalPitch; + } else if (fakeRotation.getInput() == 2) { + fakeYaw = fakeYaw1; + if (blockRotations != null) { + fakePitch = blockRotations[1] + 5; + } else { + fakePitch = 80f; + } + } else if (fakeRotation.getInput() == 3) { + fakeYaw2 = mc.thePlayer.rotationYaw - hardcodedYaw(); + float yawDifference = Utils.getAngleDifference(lastEdge2, fakeYaw2); + float smoothingFactor = 0.35f; + fakeYaw2 = (lastEdge2 + yawDifference * smoothingFactor); + lastEdge2 = fakeYaw2; + + fakeYaw = fakeYaw2; + if (blockRotations != null) { + fakePitch = blockRotations[1] + 5; + } else { + fakePitch = 80f; + } + } else if (fakeRotation.getInput() == 4) { + fakeYaw += 25.71428571428571F; + fakePitch = 90F; + } else if (fakeRotation.getInput() == 5) { + if (blockRotations != null) { + fakeYaw2 = blockRotations[0]; + fakePitch = blockRotations[1]; + } else { + fakeYaw2 = mc.thePlayer.rotationYaw - hardcodedYaw() - 180; + fakePitch = 88F; + } + float yawDifference = Utils.getAngleDifference(lastEdge2, fakeYaw2); + float smoothingFactor = 0.35f; + fakeYaw2 = (lastEdge2 + yawDifference * smoothingFactor); + lastEdge2 = fakeYaw2; + + fakeYaw = fakeYaw2; + } + RotationUtils.setFakeRotations(fakeYaw, fakePitch); + } + if (!isEnabled) { + dt++; + return; + } + if (Utils.isMoving()) { + scaffoldTicks++; + } + else { + scaffoldTicks = 0; + } + canBlockFade = true; + if (Utils.keysDown() && usingFastScaffold() && !ModuleManager.invmove.active() && fastScaffold.getInput() >= 1 && !ModuleManager.tower.canTower() && !LongJump.function) { // jump mode + if (mc.thePlayer.onGround && Utils.isMoving()) { + if (scaffoldTicks > 1) { + jump = true; + rotateForward(true); + if (startYPos == -1 || Math.abs(startYPos - mc.thePlayer.posY) > 2) { + startYPos = mc.thePlayer.posY; + fastScaffoldKeepY = true; + } + } + } + } + else if (fastScaffoldKeepY) { + fastScaffoldKeepY = firstKeepYPlace = false; + startYPos = -1; + keepYTicks = 0; + } + + //Float + if (sprint.getInput() == 2 && !usingFastScaffold() && !fastScaffoldKeepY && !ModuleManager.tower.canTower() && !LongJump.function) { + floatWasEnabled = true; + if (!floatStarted && offsetDelay == 0) { + if (ModuleUtils.groundTicks > 8 && mc.thePlayer.onGround) { + floatKeepY = true; + startYPos = e.posY; + rotateForward(true); + mc.thePlayer.jump(); + if (Utils.isMoving()) { + double fvl = (getSpeed(getSpeedLevel()) - Utils.randomizeDouble(0.0003, 0.0001)) * (floatFirstJump.getInput() / 100); + Utils.setSpeed(fvl); + } + floatJumped = true; + } else if (ModuleUtils.groundTicks <= 8 && mc.thePlayer.onGround) { + floatStarted = true; + } + if (floatJumped && !mc.thePlayer.onGround) { + floatStarted = true; + } + } + + if (floatStarted && mc.thePlayer.onGround) { + floatKeepY = false; + startYPos = -1; + if (moduleEnabled && mc.thePlayer.posY % 1 == 0) { + ++floatTicks; + rotateForward = false; + rotationDelay = 0; + /*if (rt == 0) { + blink = true; + rotateForward(false); + } + ++rt; + if (rt == 3) { + rt = 0; + blink = false; + }*/ + if (floatTicks > 1) { + e.setPosY(e.getPosY() + 1e-3); + floatTicks = 0; + } + else { + e.setPosY(e.getPosY() + 1e-4); + } + if (sprint.getInput() == 2 && Utils.isMoving() && !ModuleManager.invmove.active()) Utils.setSpeed(getFloatSpeed(getSpeedLevel())); + ModuleUtils.groundTicks = 0; + offsetDelay = 2; + ModuleManager.tower.delay = true; + ModuleManager.tower.delayTicks = 0; + } + } + } else if (floatWasEnabled && moduleEnabled) { + if (floatKeepY) { + startYPos = -1; + } + if (mc.thePlayer.onGround) { + Utils.setSpeed(Utils.getHorizontalSpeed() / 2); + } + floatStarted = floatJumped = floatKeepY = floatWasEnabled = blink = false; + floatTicks = rt = 0; + } + + if (blockRotations != null) { + if (mc.thePlayer.rotationYaw == lastOffset) { + sameMouse++; + } + else { + sameMouse = 0; + yawChanges++; + } + if (sameMouse > 2) { + yawChanges = 0; + } + lastOffset = mc.thePlayer.rotationYaw; + if (yawChanges > 15) { + randomF = 1; + yawEdge = Utils.time(); + } + if (yawEdge > 0 && (Utils.time() - yawEdge) > 500) { + yawEdge = 0; + } + } + else { + fakeYaw1 = mc.thePlayer.rotationYaw - hardcodedYaw(); + } + + dynamic = 0; + if (targetBlock != null) { + Vec3 lookAt = new Vec3(targetBlock.xCoord - lookVec.xCoord, targetBlock.yCoord - lookVec.yCoord, targetBlock.zCoord - lookVec.zCoord); + blockRotations = RotationUtils.getRotations(lookAt); + targetBlock = null; + fakeYaw1 = mc.thePlayer.rotationYaw - hardcodedYaw(); + if (yawEdge == 0) { + randomF = Utils.randomizeInt(0, 9); + yawEdge = Utils.time(); + } + dynamic++; + } + randomF = 0; + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onClientRotation(ClientRotationEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (!isEnabled) { + lastMY = getMotionYaw(); + return; + } + + if (jump) { + mc.thePlayer.setSprinting(true); + mc.thePlayer.jump(); + jump = false; + if (!Settings.movementFix.isToggled()) { + Utils.setSpeed((getSpeed(getSpeedLevel()) * ModuleUtils.applyFrictionMulti())); + } + if (fastScaffold.getInput() == 6 || fastScaffold.getInput() == 3 && firstKeepYPlace) { + lowhop = true; + } + } + + + switch ((int) rotation.getInput()) { + case 1: + yaw = mc.thePlayer.rotationYaw - hardcodedYaw(); + pitch = 76F; + if (!Utils.isDiagonal(true)) { + //yaw += 45; + } + e.setRotations(yaw, pitch); + theYaw = yaw; + break; + case 2: + offsetRots(e); + break; + case 3: + preciseRots(e); + break; + } + if (edge != 1) { + switchvl++; + edge = 1; + } + if (mc.thePlayer.onGround) { + enabledOffGround = false; + } + + //jump facing forward + if (rotationDelay > 0) --rotationDelay; + if (!mc.thePlayer.onGround) { + rotateForward = false; + } + if (rotateForward && jumpFacingForward.isToggled()) { + if (rotation.getInput() > 0) { + float forwardYaw = (mc.thePlayer.rotationYaw - hardcodedYaw() - 180); + e.setYaw(forwardYaw); + e.setPitch(90F); + } + } + else { + rotatingForward = false; + } + + if (!Settings.movementFix.isToggled() && mc.thePlayer.motionX == 0.0D && mc.thePlayer.motionZ == 0.0D) { + if (blockRotations != null) { + e.setYaw(blockRotations[0]); + } + } + + if (ModuleManager.tower.isVerticalTowering()) { + if (blockRotations != null && (!getVTR || ModuleManager.tower.ebDelay <= 1 || !ModuleManager.tower.firstVTP)) { + VTRY = blockRotations[0]; + getVTR = true; + } + if (getVTR) { + e.setYaw(VTRY); + } + if (ModuleManager.tower.yaw != 0) { + e.setYaw(ModuleManager.tower.yaw); + } + if (ModuleManager.tower.pitch != 0) { + e.setPitch(ModuleManager.tower.pitch); + } + } + else { + getVTR = false; + } + } + + private float lastMY; + + private void handleV() { + float yawBackwards2 = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); + double dif = (lastMY - getMotionYaw()); + double v = 2.5; + float offset = (yawWithOffset - yawBackwards2); + if (offset > yawAngle || offset < -yawAngle) { + lastYawS = getSmooth = smoothedYaw = yaw; + return; + } + if (dif >= 0 && dif < v || dif <= -0 && dif > -v || mc.thePlayer.onGround) { + lastYawS = getSmooth = smoothedYaw = yaw; + return; + } + + getSmooth = yaw; + float yawDifference = Utils.getAngleDifference(lastYawS, getSmooth); + float smoothingFactor = 0.1f; + getSmooth = (lastYawS + yawDifference * smoothingFactor); + lastYawS = getSmooth; + smoothedYaw = getSmooth; + yaw = smoothedYaw; + } + + private void handleSmoothing() { + handleV(); + + lastMY = getMotionYaw(); + } + + private void offsetRots(ClientRotationEvent e) { + float moveAngle = (float) getMovementAngle(); + float relativeYaw = mc.thePlayer.rotationYaw + moveAngle; + float normalizedYaw = (relativeYaw % 360 + 360) % 360; + float quad = normalizedYaw % 90; + + float side = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); + float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); + float blockYawOffset = MathHelper.wrapAngleTo180_float(yawBackwards - blockYaw); + + long strokeDelay = 250; + + float first = 76F; + float sec = 78F; + + if (quad <= 5 || quad >= 85) { + yawAngle = 126.425F; + minOffset = 11; + minPitch = first; + } + if (quad > 5 && quad <= 15 || quad >= 75 && quad < 85) { + yawAngle = 127.825F; + minOffset = 9; + minPitch = first; + } + if (quad > 15 && quad <= 25 || quad >= 65 && quad < 75) { + yawAngle = 129.625F; + minOffset = 8; + minPitch = first; + } + if (quad > 25 && quad <= 32 || quad >= 58 && quad < 65) { + yawAngle = 130.485F; + minOffset = 7; + minPitch = sec; + } + if (quad > 32 && quad <= 38 || quad >= 52 && quad < 58) { + yawAngle = 133.485F; + minOffset = 6; + minPitch = sec; + } + if (quad > 38 && quad <= 42 || quad >= 48 && quad < 52) { + yawAngle = 135.625F; + minOffset = 4; + minPitch = sec; + } + if (quad > 42 && quad <= 45 || quad >= 45 && quad < 48) { + yawAngle = 137.625F; + minOffset = 3; + minPitch = sec; + } + //float offsetAmountD = ((((float) offsetAmount.getInput() / 10) - 10) * -2) - (((float) offsetAmount.getInput() / 10) - 10); + //yawAngle += offsetAmountD; + + float offset = yawAngle;//(!Utils.scaffoldDiagonal(false)) ? 125.500F : 143.500F; + + + float nigger = 0; + + if (quad > 45) { + nigger = 10; + } + else { + nigger = -10; + } + if (switchvl > 0) { + /*if (vlS > 0 && (System.currentTimeMillis() - vlS) > strokeDelay && firstStroke == 0) { + switchvl = 0; + vlS = 0; + }*/ + //if (switchvl > 0) { + firstStroke = Utils.time(); + switchvl = 0; + vlS = 0; + resetm = true; + //} + } + else { + vlS = Utils.time(); + } + if (firstStroke > 0 && (Utils.time() - firstStroke) > strokeDelay) { + firstStroke = 0; + } + if (Utils.fallDist() <= 2 && Utils.getHorizontalSpeed() > 0.1) { + enabledOffGround = false; + } + if (enabledOffGround) { + if (blockRotations != null) { + yaw = blockRotations[0]; + pitch = blockRotations[1]; + } else { + yaw = mc.thePlayer.rotationYaw - hardcodedYaw() - nigger; + pitch = minPitch; + } + e.setRotations(yaw, pitch); + return; + } + + if (blockRotations != null) { + blockYaw = blockRotations[0]; + pitch = blockRotations[1]; + yawOffset = blockYawOffset; + if (pitch < minPitch) { + pitch = minPitch; + } + } else { + pitch = minPitch; + if (edge == 1 && ((quad <= 3 || quad >= 87) && !Utils.scaffoldDiagonal(false))) { + firstStroke = Utils.time(); + } + yawOffset = 5; + dynamic = 2; + } + + if (!Utils.isMoving() || Utils.getHorizontalSpeed() == 0.0D) { + e.setRotations(theYaw, pitch); + return; + } + + float motionYaw = getMotionYaw(); + + float newYaw = motionYaw - offset * Math.signum( + MathHelper.wrapAngleTo180_float(motionYaw - yaw) + ); + yaw = MathHelper.wrapAngleTo180_float(newYaw); + + if (quad > 3 && quad < 87 && dynamic > 0) { + if (quad < 45F) { + if (firstStroke == 0) { + if (side >= 0) { + set2 = false; + } else { + set2 = true; + } + } + if (was452) { + switchvl++; + } + was451 = true; + was452 = false; + } else { + if (firstStroke == 0) { + if (side >= 0) { + set2 = true; + } else { + set2 = false; + } + } + if (was451) { + switchvl++; + } + was452 = true; + was451 = false; + } + } + double minSwitch = (!Utils.scaffoldDiagonal(false)) ? 9 : 15; + if (side >= 0) { + if (yawOffset <= -minSwitch && firstStroke == 0 && dynamic > 0) { + if (quad <= 3 || quad >= 87) { + if (set2) { + switchvl++; + } + set2 = false; + } + } else if (yawOffset >= 0 && firstStroke == 0 && dynamic > 0) { + if (quad <= 3 || quad >= 87) { + if (yawOffset >= minSwitch) { + if (!set2) { + switchvl++; + } + set2 = true; + } + } + } + if (set2) { + if (yawOffset <= -0) yawOffset = -0; + if (yawOffset >= minOffset) yawOffset = minOffset; + theYaw = (yaw + offset * 2) - yawOffset; + e.setRotations(theYaw, pitch); + return; + } + } else if (side <= -0) { + if (yawOffset >= minSwitch && firstStroke == 0 && dynamic > 0) { + if (quad <= 3 || quad >= 87) { + if (set2) { + switchvl++; + } + set2 = false; + } + } else if (yawOffset <= 0 && firstStroke == 0 && dynamic > 0) { + if (quad <= 3 || quad >= 87) { + if (yawOffset <= -minSwitch) { + if (!set2) { + switchvl++; + } + set2 = true; + } + } + } + if (set2) { + if (yawOffset >= 0) yawOffset = 0; + if (yawOffset <= -minOffset) yawOffset = -minOffset; + theYaw = (yaw - offset * 2) - yawOffset; + e.setRotations(theYaw, pitch); + return; + } + } + + if (side >= 0) { + if (yawOffset >= 0) yawOffset = 0; + if (yawOffset <= -minOffset) yawOffset = -minOffset; + } else if (side <= -0) { + if (yawOffset <= -0) yawOffset = -0; + if (yawOffset >= minOffset) yawOffset = minOffset; + } + theYaw = yaw - yawOffset; + e.setRotations(theYaw, pitch); + } + + private void offsetRots2(ClientRotationEvent e) { + float moveAngle2 = (float) getMovementAngle(); + float relativeYaw2 = mc.thePlayer.rotationYaw + moveAngle2; + float normalizedYaw2 = (relativeYaw2 % 360 + 360) % 360; + float quad2 = normalizedYaw2 % 90; + + float yawBackwards2 = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); + float blockYawOffset2 = MathHelper.wrapAngleTo180_float(yawBackwards2 - blockYaw); + + long sDelay = 250; + + if (switchvl > 0) { + /*if (vlS > 0 && (System.currentTimeMillis() - vlS) > strokeDelay && firstStroke == 0) { + switchvl = 0; + vlS = 0; + }*/ + //if (switchvl > 0) { + firstStroke = Utils.time(); + switchvl = 0; + vlS = 0; + resetm = true; + //} + } + else { + vlS = Utils.time(); + } + if (firstStroke > 0 && (System.currentTimeMillis() - firstStroke) > sDelay) { + firstStroke = 0; + } + + float firstv = 77.5F; + float secv = 77.5F; + + if (quad2 <= 5 || quad2 >= 85) { + yawAngle = 58.685F; + minOffset = 13; + minPitch = firstv; + } + if (quad2 > 5 && quad2 <= 15 || quad2 >= 75 && quad2 < 85) { + yawAngle = 56.185F; + minOffset = 11; + minPitch = firstv; + } + if (quad2 > 15 && quad2 <= 25 || quad2 >= 65 && quad2 < 75) { + yawAngle = 53.385F; + minOffset = 9; + minPitch = firstv; + } + if (quad2 > 25 && quad2 <= 32 || quad2 >= 58 && quad2 < 65) { + yawAngle = 50.385F; + minOffset = 7; + minPitch = secv; + } + if (quad2 > 32 && quad2 <= 38 || quad2 >= 52 && quad2 < 58) { + yawAngle = 48.185F; + minOffset = 6; + minPitch = secv; + } + if (quad2 > 38 && quad2 <= 42 || quad2 >= 48 && quad2 < 52) { + yawAngle = 46.185F; + minOffset = 4; + minPitch = secv; + } + if (quad2 > 42 && quad2 <= 45 || quad2 >= 45 && quad2 < 48) { + yawAngle = 42.885F; + minOffset = 3; + minPitch = secv; + } + + if (blockRotations != null) { + blockYaw = blockRotations[0]; + pitch = blockRotations[1]; + yawOffset = blockYawOffset2; + if (pitch < minPitch) { + pitch = minPitch; + } + } else { + pitch = minPitch; + if (edge == 1 && ((quad2 <= 3 || quad2 >= 87) && !Utils.scaffoldDiagonal(false))) { + switchvl++; + } + yawOffset = 5; + dynamic = 2; + } + + if (quad2 > 3 && quad2 < 87 && dynamic > 0) { + if (quad2 < 45F) { + if (firstStroke == 0) { + set2 = true; + } + if (was452) { + switchvl++; + } + was451 = true; + was452 = false; + } else { + if (firstStroke == 0) { + set2 = false; + } + if (was451) { + switchvl++; + } + was452 = true; + was451 = false; + } + } + double minSwitch2 = (!Utils.scaffoldDiagonal(false)) ? 9 : 15; + + if (yawOffset <= -minSwitch2 && firstStroke == 0 && dynamic > 0) { + if (quad2 <= 3 || quad2 >= 87) { + if (set2) { + switchvl++; + } + set2 = true; + } + } else if (yawOffset >= 0 && firstStroke == 0 && dynamic > 0) { + if (quad2 <= 3 || quad2 >= 87) { + if (yawOffset >= minSwitch2) { + if (!set2) { + switchvl++; + } + set2 = false; + } + } + } + + if (set2) { + yaw = ((yawBackwards2)); + if (yawOffset <= -0) yawOffset = 0; + if (yawOffset >= minOffset) yawOffset = minOffset; + yawWithOffset = yaw + yawAngle - yawOffset; + neg = false; + handleSmoothing(); + e.setRotations(yaw + yawAngle - yawOffset, pitch); + return; + } + + yaw = ((yawBackwards2)); + if (yawOffset >= 0) yawOffset = 0; + if (yawOffset <= -minOffset) yawOffset = -minOffset; + yawWithOffset = yaw - yawAngle - yawOffset; + neg = true; + handleSmoothing(); + e.setRotations(yaw - yawAngle - yawOffset, pitch); + } + + private void preciseRots(ClientRotationEvent e) { + if (blockRotations != null) { + yaw = blockRotations[0]; + pitch = blockRotations[1]; + } + else { + yaw = mc.thePlayer.rotationYaw - hardcodedYaw(); + pitch = 80F; + } + e.setRotations(yaw, pitch); + theYaw = yaw; + } + + @SubscribeEvent + public void onPostPlayerInput(PostPlayerInputEvent e) { + if (!ModuleManager.scaffold.isEnabled) { + return; + } + if (!fastScaffoldKeepY && !floatKeepY) { + return; + } + mc.thePlayer.movementInput.jump = false; + } + + @SubscribeEvent + public void onSlotUpdate(SlotUpdateEvent e) { + if (isEnabled && autoSwap.isToggled()) { + lastSlot.set(e.slot); + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + stopUpdate = stopUpdate2 = false; + if (!isEnabled) { + stopUpdate2 = true; + } + if (LongJump.function) { + startYPos = -1; + } + if (LongJump.stopModules) { + stopUpdate2 = true; + } + if (!stopUpdate2) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), false); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + if (holdingBlocks() && setSlot()) { + /*if (moduleEnabled && !finishProcedure) { + if (Utils.distanceToGround(mc.thePlayer) < 2) { + finishProcedure = true; + } + if (Utils.distanceToGround(mc.thePlayer) > 6) { + if (hasPlaced) { + finishProcedure = true; + } + } else if (!finishProcedure) { + stopUpdate = true; + } + }*/ + if (!stopUpdate) { + hasSwapped = true; + int mode = (int) fastScaffold.getInput(); + if (!ModuleManager.tower.placeExtraBlock) { + if (rotation.getInput() == 0 || rotationDelay == 0) { + placeBlock(0, 0); + } + } else if ((ModuleManager.tower.ebDelay == 0 || !ModuleManager.tower.firstVTP)) { + placeBlock(0, 0); + placedVP = true; + } + if (ModuleManager.tower.placeExtraBlock) { + placeBlock(0, -1); + } + + if (fastScaffoldKeepY && !ModuleManager.tower.canTower()) { + ++keepYTicks; + if ((int) mc.thePlayer.posY > (int) startYPos) { + switch (mode) { + case 1: + if (!firstKeepYPlace && keepYTicks == 3) { + placeBlock(1, 0); + firstKeepYPlace = true; + } + break; + case 2: + if (!firstKeepYPlace && keepYTicks == 8 || keepYTicks == 11) { + placeBlock(1, 0); + firstKeepYPlace = true; + } + break; + case 3: + if (!firstKeepYPlace && keepYTicks == 8 || firstKeepYPlace && keepYTicks == 7) { + placeBlock(1, 0); + firstKeepYPlace = true; + } + break; + case 4: + if (!firstKeepYPlace && keepYTicks == 7) { + placeBlock(1, 0); + firstKeepYPlace = true; + } + break; + } + } + if (mc.thePlayer.onGround) keepYTicks = 0; + if ((int) mc.thePlayer.posY == (int) startYPos) firstKeepYPlace = false; + } + handleMotion(); + } + } + } + + if (disabledModule) { + if (hasPlaced && (towerEdge || floatStarted && Utils.isMoving())) { + dontDisable = true; + } + + if (dontDisable && ++disableTicks >= 2) { + isEnabled = false; + } + if (!dontDisable) { + isEnabled = false; + } + + + if (!isEnabled) { + disabledModule = dontDisable = false; + disableTicks = 0; + + if (ModuleManager.tower.speed) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer) / 1.6); + } + + if (lastSlot.get() != -1) { + mc.thePlayer.inventory.currentItem = lastSlot.get(); + lastSlot.set(-1); + } + blockSlot = -1; + if (autoSwap.isToggled() && ModuleManager.autoSwap.spoofItem.isToggled()) { + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(false); + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(false); + } + if (offsetDelay > 0) { + ModuleManager.sprint.requireJump = false; + } + scaffoldBlockCount.beginFade(); + hasSwapped = hasPlaced = false; + targetBlock = null; + blockInfo = null; + blockRotations = null; + fastScaffoldKeepY = firstKeepYPlace = rotateForward = rotatingForward = floatStarted = floatJumped = floatWasEnabled = towerEdge = + was451 = was452 = enabledOffGround = finishProcedure = jump = blink = false; + rotationDelay = keepYTicks = scaffoldTicks = floatTicks = rt = 0; + firstStroke = vlS = 0; + startYPos = -1; + lookVec = null; + lastPlacement = null; + } + } + } + + @Override + public String getInfo() { + String info; + if (fastOnRMB.isToggled()) { + info = fastOnRMB() ? fastScaffoldModes[(int) fastScaffold.getInput()] : sprintModes[(int) sprint.getInput()]; + } + else { + info = fastScaffold.getInput() > 0 ? fastScaffoldModes[(int) fastScaffold.getInput()] : sprintModes[(int) sprint.getInput()]; + } + return info; + } + + public boolean stopFastPlace() { + return this.isEnabled(); + } + + public void rotateForward(boolean delay) { + if (jumpFacingForward.isToggled()) { + if (rotation.getInput() > 0) { + if (!rotatingForward) { + if (delay) { + rotationDelay = 2; + } + } + rotatingForward = rotateForward = true; + } + } + } + + public boolean blockAbove() { + return !(BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY + 2, mc.thePlayer.posZ)) instanceof BlockAir); + } + + public boolean sprint() { + if (isEnabled) { + return handleFastScaffolds() > 0; + } + return false; + } + + private int handleFastScaffolds() { + if (fastOnRMB.isToggled()) { + return fastScaffold.getInput() > 0 && fastOnRMB() ? (int) fastScaffold.getInput() : (int) sprint.getInput(); + } + else { + return fastScaffold.getInput() > 0 ? (int) fastScaffold.getInput() : (int) sprint.getInput(); + } + } + + private boolean usingFloat() { + return sprint.getInput() == 2 && Utils.isMoving() && !usingFastScaffold(); + } + + private boolean sprintScaf() { + return sprint.getInput() > 0 && Utils.isMoving() && mc.thePlayer.onGround && !usingFastScaffold() && !ModuleManager.tower.canTower(); + } + + public boolean usingFastScaffold() { + return fastScaffold.getInput() > 0 && (!fastOnRMB.isToggled() || fastOnRMB() && Utils.tabbedIn()) && !prioritizeSprint(); + } + + public boolean fastOnRMB() { + return fastOnRMB.isToggled() && Utils.tabbedIn() && (Mouse.isButtonDown(1) || ModuleManager.bhop.isEnabled() || defPS()); + } + + private boolean defPS() { + return prioritizeSprintWithSpeed.isToggled() && (sprint.getInput() == 0 || getSpeedLevel() == 0); + } + + private boolean prioritizeSprint() { + return prioritizeSprintWithSpeed.isToggled() && sprint.getInput() > 0 && getSpeedLevel() > 0 && !fastOnRMB(); + } + + public boolean safewalk() { + return this.isEnabled() && safeWalk.isToggled(); + } + + public boolean stopRotation() { + return this.isEnabled() && rotation.getInput() > 0; + } + + private void place(PlaceData block) { + ItemStack heldItem = mc.thePlayer.getHeldItem(); + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { + return; + } + if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, heldItem, block.blockPos, block.enumFacing, block.hitVec)) { + if (silentSwing.isToggled()) { + mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation()); + } + else { + mc.thePlayer.swingItem(); + if (holdingBlocks()) { + mc.getItemRenderer().resetEquippedProgress(); + } + } + if (ModuleManager.tower.placeExtraBlock) { + ModuleManager.tower.firstVTP = true; + } + highlight.put(block.blockPos.offset(block.enumFacing), null); + hasPlaced = true; + } + } + + public boolean canSafewalk() { + if (!safeWalk.isToggled()) { + return false; + } + if (usingFastScaffold()) { + return false; + } + if (ModuleManager.tower.canTower()) { + return false; + } + if (!isEnabled) { + return false; + } + return true; + } + + public int totalBlocks() { + int totalBlocks = 0; + for (int i = 0; i < 9; ++i) { + final ItemStack stack = mc.thePlayer.inventory.mainInventory[i]; + if (stack != null && stack.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) stack.getItem()) && stack.stackSize > 0) { + totalBlocks += stack.stackSize; + } + } + return totalBlocks; + } + + private void placeBlock(int yOffset, int xOffset) { + locateAndPlaceBlock(yOffset, xOffset); + int input = (int) multiPlace.getInput(); + if (input >= 1) { + locateAndPlaceBlock(yOffset, xOffset); + if (input >= 2) { + locateAndPlaceBlock(yOffset, xOffset); + if (input >= 3) { + locateAndPlaceBlock(yOffset, xOffset); + if (input >= 4) { + locateAndPlaceBlock(yOffset, xOffset); + } + } + } + } + } + + private void locateAndPlaceBlock(int yOffset, int xOffset) { + locateBlocks(yOffset, xOffset); + if (blockInfo == null) { + return; + } + lastPlacement = blockInfo; + place(blockInfo); + blockInfo = null; + } + + private void locateBlocks(int yOffset, int xOffset) { + List blocksInfo = findBlocks(yOffset, xOffset); + + if (blocksInfo == null) { + return; + } + + double sumX = 0, sumY = !mc.thePlayer.onGround ? 0 : blocksInfo.get(0).blockPos.getY(), sumZ = 0; + int index = 0; + for (PlaceData blockssInfo : blocksInfo) { + if (index > 1 || (!Utils.isDiagonal(false) && index > 0 && mc.thePlayer.onGround)) { + break; + } + sumX += blockssInfo.blockPos.getX(); + if (!mc.thePlayer.onGround) { + sumY += blockssInfo.blockPos.getY(); + } + sumZ += blockssInfo.blockPos.getZ(); + index++; + } + + double avgX = sumX / index; + double avgY = !mc.thePlayer.onGround ? sumY / index : blocksInfo.get(0).blockPos.getY(); + double avgZ = sumZ / index; + + targetBlock = new Vec3(avgX, avgY, avgZ); + + PlaceData blockInfo2 = blocksInfo.get(0); + int blockX = blockInfo2.blockPos.getX(); + int blockY = blockInfo2.blockPos.getY(); + int blockZ = blockInfo2.blockPos.getZ(); + EnumFacing blockFacing = blockInfo2.enumFacing; + blockInfo = blockInfo2; + + double hitX = (blockX + 0.5D) + getCoord(blockFacing.getOpposite(), "x") * 0.5D; + double hitY = (blockY + 0.5D) + getCoord(blockFacing.getOpposite(), "y") * 0.5D; + double hitZ = (blockZ + 0.5D) + getCoord(blockFacing.getOpposite(), "z") * 0.5D; + lookVec = new Vec3(0.5D + getCoord(blockFacing.getOpposite(), "x") * 0.5D, 0.5D + getCoord(blockFacing.getOpposite(), "y") * 0.5D, 0.5D + getCoord(blockFacing.getOpposite(), "z") * 0.5D); + hitVec = new Vec3(hitX, hitY, hitZ); + blockInfo.hitVec = hitVec; + } + + private double getCoord(EnumFacing facing, String axis) { + switch (axis) { + case "x": return (facing == EnumFacing.WEST) ? -0.5 : (facing == EnumFacing.EAST) ? 0.5 : 0; + case "y": return (facing == EnumFacing.DOWN) ? -0.5 : (facing == EnumFacing.UP) ? 0.5 : 0; + case "z": return (facing == EnumFacing.NORTH) ? -0.5 : (facing == EnumFacing.SOUTH) ? 0.5 : 0; + } + return 0; + } + + private List findBlocks(int yOffset, int xOffset) { + int x = (int) Math.floor(mc.thePlayer.posX + xOffset); + int y = (int) Math.floor(((startYPos != -1) ? startYPos : mc.thePlayer.posY) + yOffset); + int z = (int) Math.floor(mc.thePlayer.posZ); + + BlockPos base = new BlockPos(x, y - 1, z); + + if (!BlockUtils.replaceable(base)) { + return null; + } + + EnumFacing[] allFacings = getFacingsSorted(); + List validFacings = new ArrayList<>(5); + for (EnumFacing facing : allFacings) { + if (facing != EnumFacing.UP && placeConditions(facing, yOffset, xOffset)) { + validFacings.add(facing); + } + } + int maxLayer = 1; + List possibleBlocks = new ArrayList<>(); + + for (int dy = 1; dy <= maxLayer; dy++) { + BlockPos layerBase = new BlockPos(x, y - dy, z); + if (dy == 1) { + for (EnumFacing facing : validFacings) { + BlockPos neighbor = layerBase.offset(facing); + if (!BlockUtils.replaceable(neighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(neighbor))) { + possibleBlocks.add(new PlaceData(neighbor, facing.getOpposite())); + } + } + } + for (EnumFacing facing : validFacings) { + BlockPos adjacent = layerBase.offset(facing); + if (BlockUtils.replaceable(adjacent)) { + for (EnumFacing nestedFacing : validFacings) { + BlockPos nestedNeighbor = adjacent.offset(nestedFacing); + if (!BlockUtils.replaceable(nestedNeighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(nestedNeighbor))) { + possibleBlocks.add(new PlaceData(nestedNeighbor, nestedFacing.getOpposite())); + } + } + } + } + for (EnumFacing facing : validFacings) { + BlockPos adjacent = layerBase.offset(facing); + if (BlockUtils.replaceable(adjacent)) { + for (EnumFacing nestedFacing : validFacings) { + BlockPos nestedNeighbor = adjacent.offset(nestedFacing); + if (BlockUtils.replaceable(nestedNeighbor)) { + for (EnumFacing thirdFacing : validFacings) { + BlockPos thirdNeighbor = nestedNeighbor.offset(thirdFacing); + if (!BlockUtils.replaceable(thirdNeighbor) && !BlockUtils.isInteractable(BlockUtils.getBlock(thirdNeighbor))) { + possibleBlocks.add(new PlaceData(thirdNeighbor, thirdFacing.getOpposite())); + } + } + } + } + } + } + } + + return possibleBlocks.isEmpty() ? null : possibleBlocks; + } + + private EnumFacing[] getFacingsSorted() { + EnumFacing lastFacing = EnumFacing.getHorizontal(MathHelper.floor_double((((IAccessorEntityPlayerSP)mc.thePlayer).getLastReportedYaw() * 4.0F / 360.0F) + 0.5D) & 3); + + EnumFacing perpClockwise = lastFacing.rotateY(); + EnumFacing perpCounterClockwise = lastFacing.rotateYCCW(); + + EnumFacing opposite = lastFacing.getOpposite(); + + float yaw = ((IAccessorEntityPlayerSP)mc.thePlayer).getLastReportedYaw() % 360; + if (yaw > 180) { + yaw -= 360; + } + else if (yaw < -180) { + yaw += 360; + } + + // Calculates the difference from the last placed angle and gets the closest one + float diffClockwise = Math.abs(MathHelper.wrapAngleTo180_float(yaw - getFacingAngle(perpClockwise))); + float diffCounterClockwise = Math.abs(MathHelper.wrapAngleTo180_float(yaw - getFacingAngle(perpCounterClockwise))); + + EnumFacing firstPerp, secondPerp; + if (diffClockwise <= diffCounterClockwise) { + firstPerp = perpClockwise; + secondPerp = perpCounterClockwise; + } + else { + firstPerp = perpCounterClockwise; + secondPerp = perpClockwise; + } + + return new EnumFacing[]{EnumFacing.UP, EnumFacing.DOWN, lastFacing, firstPerp, secondPerp, opposite}; + } + + private float getFacingAngle(EnumFacing facing) { + switch (facing) { + case WEST: + return 90; + case NORTH: + return 180; + case EAST: + return -90; + default: + return 0; + } + } + + private boolean placeConditions(EnumFacing enumFacing, int yCondition, int xCondition) { + if (xCondition == -1) { + if (!ModuleManager.tower.placeExtraBlock) { + return enumFacing == EnumFacing.EAST; + } + else { + return enumFacing == EnumFacing.DOWN; + } + } + else if (ModuleManager.tower.placeExtraBlock) { + return enumFacing == EnumFacing.WEST; + } + if (yCondition == 1) { + return enumFacing == EnumFacing.DOWN; + } + return true; + } + + float applyGcd(float value) { + float gcd = 0.2F * 0.2F * 0.2F * 8.0F; + return (float) ((double) value - (double) value % ((double) gcd * 0.15D)); + } + + public float getMotionYaw() { + return (float) Math.toDegrees(Math.atan2(mc.thePlayer.motionZ, mc.thePlayer.motionX)) - 90.0F; + } + + private int getSpeedLevel() { + for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { + if (potionEffect.getEffectName().equals("potion.moveSpeed")) { + return potionEffect.getAmplifier() + 1; + } + return 0; + } + return 0; + } + + double[] speedLevels = {0.48, 0.5, 0.52, 0.58, 0.68}; + + double getSpeed(int speedLevel) { + if (speedLevel >= 0) { + return speedLevels[speedLevel]; + } + return speedLevels[0]; + } + + double[] floatSpeedLevels = {0.2, 0.22, 0.265, 0.29, 0.3}; + + double getFloatSpeed(int speedLevel) { + double min = 0; + double value = 0; + double input = (motion.getInput() / 100); + if (mc.thePlayer.moveStrafing != 0 && mc.thePlayer.moveForward != 0) min = 0.003; + value = floatSpeedLevels[0] - min; + if (speedLevel >= 0) { + value = (speedLevel == 2 ? (Utils.scaffoldDiagonal(false) ? 0.265 : 0.275) : floatSpeedLevels[speedLevel]) - min; + } + value *= input; + return value; + } + + private void handleMotion() { + if (usingFastScaffold() || usingFloat() || ModuleManager.tower.canTower() || motion.getInput() == 100 || !mc.thePlayer.onGround) { + return; + } + double input = (motion.getInput() / 100); + mc.thePlayer.motionX *= input; + mc.thePlayer.motionZ *= input; + } + + public float hardcodedYaw() { + float simpleYaw = 0F; + + boolean w = Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode()); + boolean s = Keyboard.isKeyDown(mc.gameSettings.keyBindBack.getKeyCode()); + boolean a = Keyboard.isKeyDown(mc.gameSettings.keyBindLeft.getKeyCode()); + boolean d = Keyboard.isKeyDown(mc.gameSettings.keyBindRight.getKeyCode()); + + boolean dupe = a & d; + + if (w) { + simpleYaw -= 180; + if (!dupe) { + if (a) simpleYaw += 45; + if (d) simpleYaw -= 45; + } + } + else if (!s) { + simpleYaw -= 180; + if (!dupe) { + if (a) simpleYaw += 90; + if (d) simpleYaw -= 90; + } + } + else if (!w) { + if (!dupe) { + if (a) simpleYaw -= 45; + if (d) simpleYaw += 45; + } + } + return simpleYaw; + } + + public boolean holdingBlocks() { + ItemStack heldItem = mc.thePlayer.getHeldItem(); + if (autoSwap.isToggled() && ModuleManager.autoSwap.spoofItem.isToggled() && lastSlot.get() != mc.thePlayer.inventory.currentItem && totalBlocks() > 0) { + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelUpdate(true); + ((IMixinItemRenderer) mc.getItemRenderer()).setCancelReset(true); + } + if (!autoSwap.isToggled() || getSlot() == -1) { + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { + return false; + } + } + return true; + } + + private double getMovementAngle() { + double angle = Math.toDegrees(Math.atan2(-mc.thePlayer.moveStrafing, mc.thePlayer.moveForward)); + return angle == -0 ? 0 : angle; + } + + private int getSlot() { + int slot = -1; + int highestStack = -1; + ItemStack heldItem = mc.thePlayer.getHeldItem(); + for (int i = 0; i < 9; ++i) { + final ItemStack itemStack = mc.thePlayer.inventory.mainInventory[i]; + if (itemStack != null && itemStack.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) itemStack.getItem()) && itemStack.stackSize > 0) { + if (Utils.getBedwarsStatus() == 2 && ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockTNT) { + continue; + } + if (itemStack != null && heldItem != null && (heldItem.getItem() instanceof ItemBlock) && Utils.canBePlaced((ItemBlock) heldItem.getItem()) && ModuleManager.autoSwap.sameType.isToggled() && !(itemStack.getItem().getClass().equals(heldItem.getItem().getClass()))) { + continue; + } + if (itemStack.stackSize > highestStack) { + highestStack = itemStack.stackSize; + slot = i; + } + } + } + return slot; + } + + public static boolean bypassRots() { + return (ModuleManager.scaffold.rotation.getInput() == 2 || ModuleManager.scaffold.rotation.getInput() == 0); + } + + public boolean setSlot() { + ItemStack heldItem = mc.thePlayer.getHeldItem(); + int slot = getSlot(); + if (slot == -1) { + return false; + } + if (blockSlot == -1) { + blockSlot = slot; + } + if (lastSlot.get() == -1) { + lastSlot.set(mc.thePlayer.inventory.currentItem); + } + if (autoSwap.isToggled() && blockSlot != -1) { + if (ModuleManager.autoSwap.swapToGreaterStack.isToggled()) { + mc.thePlayer.inventory.currentItem = slot; + spoofSlot = slot; + } + else { + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem()) || mc.thePlayer.getHeldItem().stackSize <= ModuleManager.autoSwap.swapAt.getInput()) { + mc.thePlayer.inventory.currentItem = slot; + spoofSlot = slot; + } + } + } + + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { + blockSlot = -1; + return false; + } + return true; + } + + + static class PlaceData { + EnumFacing enumFacing; + BlockPos blockPos; + Vec3 hitVec; + + PlaceData(BlockPos blockPos, EnumFacing enumFacing) { + this.enumFacing = enumFacing; + this.blockPos = blockPos; + } + + public PlaceData(EnumFacing enumFacing, BlockPos blockPos) { + this.enumFacing = enumFacing; + this.blockPos = blockPos; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/Tower.java b/src/main/java/keystrokesmod/module/impl/player/Tower.java index 6cf358f..56e94f2 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Tower.java +++ b/src/main/java/keystrokesmod/module/impl/player/Tower.java @@ -1,708 +1,712 @@ -package keystrokesmod.module.impl.player; - -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.GroupSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.RotationUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraft.potion.PotionEffect; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -public class Tower extends Module { - final public SliderSetting towerMove; - private SliderSetting speedSetting; - final public SliderSetting verticalTower; - final private SliderSetting slowedSpeed; - final private SliderSetting slowedTicks; - final private ButtonSetting disableWhileHurt; - private GroupSetting cancelKnockbackGroup; - private final ButtonSetting cancelKnockback; - private ButtonSetting cancelVelocityRequired; - public SliderSetting extraBlockDelay; - - final private String[] towerMoveModes = new String[]{"None", "Vanilla", "3 tick", "Edge", "2.5 tick", "1.5 tick", "1 tick", "10 tick", "Jump"}; - final private String[] verticalTowerModes = new String[]{"None", "Vanilla", "Extra block", "3 tick", "Edge"}; - private int slowTicks; - private boolean wasTowering, vtowering; - private int towerTicks; - public boolean towering; - private boolean hasTowered, startedTowerInAir, setLowMotion, firstJump; - private int cMotionTicks, placeTicks; - public int dCount; - public float yaw; - private int vt; - - public int activeTicks; - - public float pitch; - - public boolean finishedTower, delay; - public int delayTicks; - - //vertical tower - private boolean aligning, aligned, placed; - private double blockX; - private double firstX, firstY, firstZ; - public boolean placeExtraBlock; - public int ebDelay; - public boolean firstVTP; - - public boolean speed; - - private int grounds, towerVL; - - public int upFaces; - - private boolean jump; - - public Tower() { - super("Tower", category.player); - this.registerSetting(towerMove = new SliderSetting("Tower Move", 0, towerMoveModes)); - this.registerSetting(speedSetting = new SliderSetting("Speed", 3.0, 0.5, 8.0, 0.1)); - this.registerSetting(verticalTower = new SliderSetting("Vertical Tower", 0, verticalTowerModes)); - this.registerSetting(extraBlockDelay = new SliderSetting("Extra block delay", "", 0, 0, 10, 1)); - this.registerSetting(slowedSpeed = new SliderSetting("Slowed speed", "%", 0, 0, 100, 1)); - this.registerSetting(slowedTicks = new SliderSetting("Slowed ticks", 1, 0, 20, 1)); - this.registerSetting(disableWhileHurt = new ButtonSetting("Disable while hurt", false)); - this.registerSetting(cancelKnockbackGroup = new GroupSetting("Cancel knockback")); - this.registerSetting(cancelKnockback = new ButtonSetting(cancelKnockbackGroup, "Enable Cancel knockback", false)); - this.registerSetting(cancelVelocityRequired = new ButtonSetting(cancelKnockbackGroup, "Require velocity enabled", false)); - //this.registerSetting(capUpFaces = new ButtonSetting("Cap up faces", false)); - - this.canBeEnabled = false; - } - - public void guiUpdate() { - this.extraBlockDelay.setVisible(verticalTower.getInput() == 2, this); - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (!Utils.nullCheck() || !cancelKnockback()) { - return; - } - if (e.getPacket() instanceof S12PacketEntityVelocity) { - if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { - e.setCanceled(true); - } - } - else if (e.getPacket() instanceof S27PacketExplosion) { - e.setCanceled(true); - } - } - - @SubscribeEvent - public void onPreMotion(PreMotionEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (delay) { - return; - } - if (canTower() && Utils.keysDown()) { - if (disableWhileHurt.isToggled() && ModuleUtils.damage) { - return; - } - switch ((int) towerMove.getInput()) { - case 1: - - break; - case 2: - - break; - case 3: - - break; - case 4: - if (towering) { - if (towerTicks == 6) { - e.setPosY(e.getPosY() + 0.000383527); - ModuleManager.scaffold.rotateForward(); - } - } - break; - case 5: - if (mc.thePlayer.onGround) { - ModuleManager.scaffold.rotateForward(); - } - break; - case 6: - - break; - case 7: - if (towering) { - if (towerTicks == 0) { - //e.setOnGround(true); - } - } - break; - case 8: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { - towering = true; - } - if (towering) { - if (mc.thePlayer.onGround) { - jump = true; - ModuleManager.scaffold.rotateForward(); - } - } - break; - } - } - } - - @SubscribeEvent - public void onClientRotation(ClientRotationEvent e) { - if (jump) { - mc.thePlayer.setSprinting(true); - mc.thePlayer.jump(); - if (ModuleManager.scaffold.rotation.getInput() == 2) { - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - speed = true; - } - jump = false; - } - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - if (!Utils.nullCheck()) { - return; - } - int valY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); - int simpleY = (int) Math.round((mc.thePlayer.posY % 1.0D) * 100.0D); - if (towerVL > 0) { - --towerVL; - } - if (delay && ++delayTicks > 1) { - delay = false; - delayTicks = 0; - } - if (towerMove.getInput() > 0) { - if (canTower() && Utils.keysDown() && !delay) { - ++activeTicks; - speed = false; - wasTowering = hasTowered = true; - if (disableWhileHurt.isToggled() && ModuleUtils.damage) { - towerTicks = 0; - towering = false; - return; - } - switch ((int) towerMove.getInput()) { - case 1: - mc.thePlayer.motionY = 0.41965; - switch (towerTicks) { - case 1: - mc.thePlayer.motionY = 0.33; - break; - case 2: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - break; - } - if (towerTicks >= 3) { - towerTicks = 0; - } - case 2: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { - towering = true; - } - if (towering) { - if (valY == 0) { - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); - startedTowerInAir = false; - } else if (valY > 4000 && valY < 4300) { - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - speed = true; - } else if (valY > 7000) { - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - } - towerVL = 2; - } - break; - case 3: - if ((mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) && !setLowMotion) { - towering = true; - } - if (towering) { - if (valY == 0) { - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); - startedTowerInAir = false; - } else if (valY > 4000 && valY < 4300) { - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - speed = true; - } else if (valY > 7000) { - if (setLowMotion) { - towering = false; - } - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - } - towerVL = 2; - } else if (setLowMotion) { - ++cMotionTicks; - if (cMotionTicks == 1) { - mc.thePlayer.motionY = 0.08f; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - } else if (cMotionTicks == 4) { - cMotionTicks = 0; - setLowMotion = false; - towering = true; - Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.02); - } - } - break; - case 4: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { - towering = true; - } - if (towering) { - towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; - switch (simpleY) { - case 0: - mc.thePlayer.motionY = 0.42f; - if (towerTicks == 6) { - mc.thePlayer.motionY = -0.078400001525879; - } - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - speed = true; - break; - case 42: - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); - speed = true; - break; - case 75: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - break; - } - } - break; - case 5: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { - towering = true; - } - if (towering) { - towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; - switch (towerTicks) { - case 0: - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(get15tickspeed(getSpeedLevel())); // Speed + Strafe tick - speed = true; - break; - case 1: - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick - break; - case 2: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - break; - case 3: - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick - break; - case 4: - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick - break; - case 5: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1f + 0.0000001; - break; - case 6: - mc.thePlayer.motionY = -0.01f; - break; - } - } - break; - case 6: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { - grounds++; - } - if (mc.thePlayer.posY % 1 == 0) { - towering = true; - } - if (towering) { - towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; - switch (towerTicks) { - case 0: - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(get1tickspeed(getSpeedLevel())); // Speed + Strafe tick - speed = true; - break; - case 1: - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick - break; - case 2: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - break; - case 3: - mc.thePlayer.motionY = 0.005; - break; - } - } - break; - case 7: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { - towering = true; - } - if (towering) { - ++towerTicks; - switch (towerTicks) { - case 7: - case 4: - case 1: - mc.thePlayer.motionY = 0.42f; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); // Speed + Strafe tick - speed = true; - break; - case 8: - case 5: - case 2: - mc.thePlayer.motionY = 0.33f; - Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick - break; - case 6: - case 3: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; - break; - case 9: - mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1 + 0.0000001; - break; - case 10: - mc.thePlayer.motionY = -0.01f; - towerTicks = 0; - Utils.setSpeed(getTowerSpeed(getSpeedLevel())); // Speed + Strafe tick - speed = true; - break; - } - } - break; - case 8: - - break; - - } - } else { - if (finishedTower) { - finishedTower = false; - } - if (hasTowered) { - finishedTower = true; - } - if (wasTowering && modulesEnabled()) { - if (slowedTicks.getInput() > 0 && slowedTicks.getInput() != 100 && slowTicks++ < slowedTicks.getInput()) { - mc.thePlayer.motionX *= slowedSpeed.getInput() / 100; - mc.thePlayer.motionZ *= slowedSpeed.getInput() / 100; - } else { - ModuleUtils.handleSlow(); - } - if (slowTicks >= slowedTicks.getInput()) { - slowTicks = 0; - wasTowering = false; - } - } else { - if (wasTowering) { - wasTowering = false; - } - slowTicks = 0; - } - if (speed || hasTowered && mc.thePlayer.onGround) { - if (ModuleManager.scaffold.rotation.getInput() == 2) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer) / 1.6); - } - } - hasTowered = towering = firstJump = startedTowerInAir = setLowMotion = speed = jump = false; - cMotionTicks = placeTicks = towerTicks = grounds = upFaces = activeTicks = 0; - reset(); - } - } - if (verticalTower.getInput() > 0) { - if (canTower() && !Utils.keysDown()) { - wasTowering = true; - switch ((int) verticalTower.getInput()) { - case 1: - mc.thePlayer.motionY = 0.42f; - break; - case 2: - if (!aligned) { - if (mc.thePlayer.onGround) { - if (!aligning) { - blockX = (int) mc.thePlayer.posX + 1; - - firstX = mc.thePlayer.posX - 10; - firstY = mc.thePlayer.posY; - firstZ = mc.thePlayer.posZ; - } - mc.thePlayer.motionX = 0.2; - aligning = true; - } - if (aligning && mc.thePlayer.posX >= blockX) { - aligned = true; - } - yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; - pitch = 0; - } - if (aligned) { - if (placed) { - yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; - //yaw = RotationUtils.getRotations(mc.thePlayer.posX + 10, mc.thePlayer.posY, mc.thePlayer.posZ)[0]; - /*if (ModuleManager.scaffold.placedVP) { - pitch = 89.6F; - ModuleManager.scaffold.placedVP = false; - } - else {*/ - pitch = 86.6F; - //} - } else { - yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; - pitch = 0; - } - placeExtraBlock = true; - Utils.setSpeed(0); - mc.thePlayer.motionX = 0; - mc.thePlayer.motionY = verticalTowerValue(); - mc.thePlayer.motionZ = 0; - towerVL = 2; - } - break; - case 3: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { - vtowering = true; - } - if (vtowering) { - mc.thePlayer.motionY = verticalTowerValue(); - towerVL = 2; - } - break; - case 4: - if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { - vtowering = true; - } - if (vtowering) { - ++vt; - towerVL = 2; - if (vt <= 6 && verticalTowerValue() != 0) { - mc.thePlayer.motionY = verticalTowerValue(); - } - else { - vt = 0; - } - } - break; - } - } else { - yaw = pitch = 0; - aligning = aligned = placed = vtowering = false; - firstX = 0; - placeExtraBlock = firstVTP = false; - ebDelay = vt = 0; - ModuleManager.scaffold.placedVP = false; - } - } - } - - public boolean isVerticalTowering() { - return canTower() && !Utils.keysDown() && verticalTower.getInput() > 0; - } - - @SubscribeEvent - public void onPostPlayerInput(PostPlayerInputEvent e) { - if (!ModuleManager.scaffold.isEnabled) { - return; - } - if (canTower() && Utils.keysDown() && towerMove.getInput() > 0) { - mc.thePlayer.movementInput.jump = false; - if (!firstJump) { - if (!mc.thePlayer.onGround) { - if (!startedTowerInAir) { - //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.04); - } - startedTowerInAir = true; - } - else if (mc.thePlayer.onGround) { - //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); - firstJump = true; - } - } - } - if (canTower() && !Utils.keysDown() && verticalTower.getInput() > 0) { - mc.thePlayer.movementInput.jump = false; - } - if (delay) { - mc.thePlayer.movementInput.jump = false; - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { - if (firstVTP) { - ebDelay++; - if (ebDelay >= extraBlockDelay.getInput() + 2) { - ebDelay = 0; - } - } - if (canTower() && Utils.isMoving()) { - ++placeTicks; - if (((C08PacketPlayerBlockPlacement) e.getPacket()).getPlacedBlockDirection() == 1 && hasTowered) { - upFaces++; - if (placeTicks > 5) { - dCount++; - if (dCount >= 2) { - //Utils.sendMessage("Hey"); - setLowMotion = true; - } - } - } - else { - dCount = upFaces = 0; - } - } - else { - placeTicks = upFaces = 0; - } - - if (aligned) { - placed = true; - } - } - } - - private void reset() { - towerTicks = 0; - towering = false; - placeTicks = 0; - setLowMotion = false; - } - - public boolean cancelKnockback() { - if (!canTower()) { - return false; - } - if (cancelVelocityRequired.isToggled() && !ModuleManager.velocity.isEnabled()) { - return false; - } - if (cancelKnockback.isToggled()) { - return true; - } - return false; - } - - public boolean canTower() { - if (!Utils.nullCheck() || !Utils.jumpDown() || !Utils.tabbedIn()) { - return false; - } - else if (mc.thePlayer.isCollidedHorizontally) { - return false; - } - else if ((mc.thePlayer.isInWater() || mc.thePlayer.isInLava())) { - return false; - } - else if (modulesEnabled()) { - return true; - } - return false; - } - - private boolean modulesEnabled() { - return (ModuleManager.scaffold.moduleEnabled && ModuleManager.scaffold.holdingBlocks() && ModuleManager.scaffold.hasSwapped && !LongJump.function); - } - - private int getSpeedLevel() { - for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { - if (potionEffect.getEffectName().equals("potion.moveSpeed")) { - return potionEffect.getAmplifier() + 1; - } - return 0; - } - return 0; - } - - private double verticalTowerValue() { - int valY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); - double value = 0; - if (valY == 0) { - value = 0.42f; - } else if (valY > 4000 && valY < 4300) { - value = 0.33f; - } else if (valY > 7000) { - value = 1 - mc.thePlayer.posY % 1; - } - return value; - } - - private double getTowerSpeed(int speedLevel) { - if (speedLevel == 0) { - return (speedSetting.getInput() / 10); - } else if (speedLevel == 1) { - return (speedSetting.getInput() / 10) + 0.04; - } else if (speedLevel == 2) { - return (speedSetting.getInput() / 10) + 0.08; - } else if (speedLevel == 3) { - return (speedSetting.getInput() / 10) + 0.12; - } else if (speedLevel == 4) { - return (speedSetting.getInput() / 10) + 0.12; - } - return (speedSetting.getInput() / 10); - } - - private double getTowerGroundSpeed(int speedLevel) { - if (speedLevel == 0) { - return (speedSetting.getInput() / 10) - 0.085; - } else if (speedLevel == 1) { - return (speedSetting.getInput() / 10) - 0.05; - } else if (speedLevel == 2) { - return (speedSetting.getInput() / 10); - } else if (speedLevel == 3) { - return (speedSetting.getInput() / 10) + 0.05; - } else if (speedLevel == 4) { - return (speedSetting.getInput() / 10) + 0.10; - } - return (speedSetting.getInput() / 10) - 0.08; - } - - private double get15tickspeed(int speedLevel) { - if (speedLevel == 0) { - return (speedSetting.getInput() / 10); - } else if (speedLevel == 1) { - return (speedSetting.getInput() / 10) + 0.04; - } else if (speedLevel == 2) { - return (speedSetting.getInput() / 10) + 0.08; - } else if (speedLevel == 3) { - return (speedSetting.getInput() / 10) + 0.12; - } else if (speedLevel == 4) { - return (speedSetting.getInput() / 10) + 0.13; - } - return (speedSetting.getInput() / 10); - } - - private double get1tickspeed(int speedLevel) { - if (speedLevel == 0) { - return (speedSetting.getInput() / 10); - } else if (speedLevel == 1) { - return (speedSetting.getInput() / 10) + 0.03; - } else if (speedLevel == 2) { - return (speedSetting.getInput() / 10) + 0.06; - } else if (speedLevel == 3) { - return (speedSetting.getInput() / 10) + 0.1; - } else if (speedLevel == 4) { - return (speedSetting.getInput() / 10) + 0.11; - } - return (speedSetting.getInput() / 10); - } - +package keystrokesmod.module.impl.player; + +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.module.impl.movement.LongJump; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.GroupSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.potion.PotionEffect; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class Tower extends Module { + final public SliderSetting towerMove; + private SliderSetting speedSetting; + final public SliderSetting verticalTower; + final private SliderSetting slowedSpeed; + final private SliderSetting slowedTicks; + final private ButtonSetting disableWhileHurt; + private GroupSetting cancelKnockbackGroup; + private final ButtonSetting cancelKnockback; + private ButtonSetting cancelVelocityRequired; + public SliderSetting extraBlockDelay; + + final private String[] towerMoveModes = new String[]{"None", "Vanilla", "3 tick", "Edge", "2.5 tick", "1.5 tick", "1 tick", "10 tick", "Jump"}; + final private String[] verticalTowerModes = new String[]{"None", "Vanilla", "Extra block", "3 tick", "Edge"}; + private int slowTicks; + private boolean wasTowering, vtowering; + private int towerTicks; + public boolean towering; + private boolean hasTowered, startedTowerInAir, setLowMotion, firstJump; + private int cMotionTicks, placeTicks; + public int dCount; + public float yaw; + private int vt; + + public boolean blink; + + public int activeTicks; + + public float pitch; + + public boolean finishedTower, delay; + public int delayTicks; + + //vertical tower + private boolean aligning, aligned, placed; + private double blockX; + private double firstX, firstY, firstZ; + public boolean placeExtraBlock; + public int ebDelay; + public boolean firstVTP; + + public boolean speed; + + private int grounds, towerVL; + + public int upFaces; + + private boolean jump; + + public Tower() { + super("Tower", category.player); + this.registerSetting(towerMove = new SliderSetting("Tower Move", 0, towerMoveModes)); + this.registerSetting(speedSetting = new SliderSetting("Speed", 3.0, 0.5, 8.0, 0.1)); + this.registerSetting(verticalTower = new SliderSetting("Vertical Tower", 0, verticalTowerModes)); + this.registerSetting(extraBlockDelay = new SliderSetting("Extra block delay", "", 0, 0, 10, 1)); + this.registerSetting(slowedSpeed = new SliderSetting("Slowed speed", "%", 0, 0, 100, 1)); + this.registerSetting(slowedTicks = new SliderSetting("Slowed ticks", 1, 0, 20, 1)); + this.registerSetting(disableWhileHurt = new ButtonSetting("Disable while hurt", false)); + this.registerSetting(cancelKnockbackGroup = new GroupSetting("Cancel knockback")); + this.registerSetting(cancelKnockback = new ButtonSetting(cancelKnockbackGroup, "Enable Cancel knockback", false)); + this.registerSetting(cancelVelocityRequired = new ButtonSetting(cancelKnockbackGroup, "Require velocity enabled", false)); + //this.registerSetting(capUpFaces = new ButtonSetting("Cap up faces", false)); + + this.canBeEnabled = false; + } + + public void guiUpdate() { + this.extraBlockDelay.setVisible(verticalTower.getInput() == 2, this); + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (!Utils.nullCheck() || !cancelKnockback()) { + return; + } + if (e.getPacket() instanceof S12PacketEntityVelocity) { + if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { + e.setCanceled(true); + } + } + else if (e.getPacket() instanceof S27PacketExplosion) { + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (delay) { + return; + } + if (canTower() && Utils.keysDown()) { + if (disableWhileHurt.isToggled() && ModuleUtils.damage) { + return; + } + switch ((int) towerMove.getInput()) { + case 1: + + break; + case 2: + + break; + case 3: + + break; + case 4: + if (towering) { + if (towerTicks == 6) { + e.setPosY(e.getPosY() + 0.000383527); + ModuleManager.scaffold.rotateForward(true); + } + } + break; + case 5: + break; + case 6: + + break; + case 7: + if (towering) { + if (towerTicks == 0) { + //e.setOnGround(true); + } + } + break; + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onClientRotation(ClientRotationEvent e) { + if (!Utils.nullCheck()) { + return; + } + int valY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); + int simpleY = (int) Math.round((mc.thePlayer.posY % 1.0D) * 100.0D); + if (towerVL > 0) { + --towerVL; + } + if (delay && ++delayTicks > 1) { + delay = false; + delayTicks = 0; + } + blink = false; + if (towerMove.getInput() > 0) { + if (canTower() && Utils.keysDown() && !delay) { + ++activeTicks; + speed = false; + wasTowering = hasTowered = true; + if (disableWhileHurt.isToggled() && ModuleUtils.damage) { + towerTicks = 0; + towering = false; + return; + } + switch ((int) towerMove.getInput()) { + case 1: + mc.thePlayer.motionY = 0.41965; + switch (towerTicks) { + case 1: + mc.thePlayer.motionY = 0.33; + break; + case 2: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + break; + } + if (towerTicks >= 3) { + towerTicks = 0; + } + case 2: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { + towering = true; + } + if (towering) { + if (valY == 0) { + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); + startedTowerInAir = false; + } else if (valY > 4000 && valY < 4300) { + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + speed = true; + } else if (valY > 7000) { + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + } + towerVL = 2; + } + break; + case 3: + if ((mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) && !setLowMotion) { + towering = true; + } + if (towering) { + if (valY == 0) { + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); + startedTowerInAir = false; + } else if (valY > 4000 && valY < 4300) { + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + speed = true; + } else if (valY > 7000) { + if (setLowMotion) { + towering = false; + } + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + } + towerVL = 2; + } else if (setLowMotion) { + ++cMotionTicks; + if (cMotionTicks == 1) { + mc.thePlayer.motionY = 0.08f; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + } else if (cMotionTicks == 4) { + cMotionTicks = 0; + setLowMotion = false; + towering = true; + Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.02); + } + } + break; + case 4: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { + towering = true; + } + if (towering) { + towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; + switch (simpleY) { + case 0: + mc.thePlayer.motionY = 0.42f; + if (towerTicks == 6) { + mc.thePlayer.motionY = -0.078400001525879; + } + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + speed = true; + break; + case 42: + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + speed = true; + break; + case 75: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + break; + } + } + break; + case 5: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { + towering = true; + } + if (towering) { + towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; + switch (towerTicks) { + case 0: + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(get15tickspeed(getSpeedLevel())); // Speed + Strafe tick + speed = true; + break; + case 1: + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick + break; + case 2: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + break; + case 3: + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick + break; + case 4: + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick + break; + case 5: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1f + 0.0000001; + break; + case 6: + mc.thePlayer.motionY = -0.01f; + break; + } + } + break; + case 6: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { + grounds++; + } + if (mc.thePlayer.posY % 1 == 0) { + towering = true; + } + if (towering) { + towerTicks = mc.thePlayer.onGround ? 0 : ++towerTicks; + switch (towerTicks) { + case 0: + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(get1tickspeed(getSpeedLevel())); // Speed + Strafe tick + speed = true; + break; + case 1: + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick + break; + case 2: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + break; + case 3: + mc.thePlayer.motionY = 0.005; + break; + } + } + break; + case 7: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { + towering = true; + } + if (towering) { + ++towerTicks; + switch (towerTicks) { + case 7: + case 4: + case 1: + mc.thePlayer.motionY = 0.42f; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); // Speed + Strafe tick + speed = true; + break; + case 8: + case 5: + case 2: + mc.thePlayer.motionY = 0.33f; + Utils.setSpeed(Utils.getHorizontalSpeed()); // Strafe tick + break; + case 6: + case 3: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1; + break; + case 9: + mc.thePlayer.motionY = 1 - mc.thePlayer.posY % 1 + 0.0000001; + break; + case 10: + mc.thePlayer.motionY = -0.01f; + towerTicks = 0; + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); // Speed + Strafe tick + speed = true; + break; + } + } + break; + case 8: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround) { + towering = true; + } + if (towering && mc.thePlayer.onGround && Utils.isMoving()) { + mc.thePlayer.setSprinting(true); + mc.thePlayer.jump(); + if (!Settings.movementFix.isToggled()) { + Utils.setSpeed(getTowerSpeed(getSpeedLevel())); + } + speed = true; + } + break; + } + if (speed) { + if (!Settings.movementFix.isToggled()) { + blink = true; + ModuleManager.scaffold.rotateForward(false); + } + else { + ModuleManager.scaffold.rotateForward(true); + } + } + } else { + if (finishedTower) { + finishedTower = false; + } + if (hasTowered) { + finishedTower = true; + } + if (wasTowering && modulesEnabled()) { + if (slowedTicks.getInput() > 0 && slowedTicks.getInput() != 100 && slowTicks++ < slowedTicks.getInput()) { + mc.thePlayer.motionX *= slowedSpeed.getInput() / 100; + mc.thePlayer.motionZ *= slowedSpeed.getInput() / 100; + } else { + ModuleUtils.handleSlow(); + } + if (slowTicks >= slowedTicks.getInput()) { + slowTicks = 0; + wasTowering = false; + } + } else { + if (wasTowering) { + wasTowering = false; + } + slowTicks = 0; + } + if (speed || hasTowered && mc.thePlayer.onGround) { + if (!Settings.movementFix.isToggled()) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer) / 1.6); + } + } + hasTowered = towering = firstJump = startedTowerInAir = setLowMotion = speed = jump = false; + cMotionTicks = placeTicks = towerTicks = grounds = upFaces = activeTicks = 0; + reset(); + } + } + if (verticalTower.getInput() > 0) { + if (canTower() && !Utils.keysDown()) { + wasTowering = true; + switch ((int) verticalTower.getInput()) { + case 1: + mc.thePlayer.motionY = 0.42f; + break; + case 2: + if (!aligned) { + if (mc.thePlayer.onGround) { + if (!aligning) { + blockX = (int) mc.thePlayer.posX + 1; + + firstX = mc.thePlayer.posX - 10; + firstY = mc.thePlayer.posY; + firstZ = mc.thePlayer.posZ; + } + mc.thePlayer.motionX = 0.2; + aligning = true; + } + if (aligning && mc.thePlayer.posX >= blockX) { + aligned = true; + } + yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; + pitch = 0; + } + if (aligned) { + if (placed) { + yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; + //yaw = RotationUtils.getRotations(mc.thePlayer.posX + 10, mc.thePlayer.posY, mc.thePlayer.posZ)[0]; + /*if (ModuleManager.scaffold.placedVP) { + pitch = 89.6F; + ModuleManager.scaffold.placedVP = false; + } + else {*/ + pitch = 86.6F; + //} + } else { + yaw = RotationUtils.getRotations(firstX, firstY, firstZ)[0]; + pitch = 0; + } + placeExtraBlock = true; + Utils.setSpeed(0); + mc.thePlayer.motionX = 0; + mc.thePlayer.motionY = verticalTowerValue(); + mc.thePlayer.motionZ = 0; + towerVL = 2; + } + break; + case 3: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { + vtowering = true; + } + if (vtowering) { + mc.thePlayer.motionY = verticalTowerValue(); + towerVL = 2; + } + break; + case 4: + if (mc.thePlayer.posY % 1 == 0 && mc.thePlayer.onGround || towerVL > 0) { + vtowering = true; + } + if (vtowering) { + ++vt; + towerVL = 2; + if (vt <= 6 && verticalTowerValue() != 0) { + mc.thePlayer.motionY = verticalTowerValue(); + } + else { + vt = 0; + } + } + break; + } + } else { + yaw = pitch = 0; + aligning = aligned = placed = vtowering = false; + firstX = 0; + placeExtraBlock = firstVTP = false; + ebDelay = vt = 0; + ModuleManager.scaffold.placedVP = false; + } + } + } + + public boolean isVerticalTowering() { + return canTower() && !Utils.keysDown() && verticalTower.getInput() > 0; + } + + private boolean disableJump; + + @SubscribeEvent + public void onPostPlayerInput(PostPlayerInputEvent e) { + disableJump = false; + if (!ModuleManager.scaffold.isEnabled) { + return; + } + if (canTower() && Utils.keysDown() && towerMove.getInput() > 0) { + disableJump = true; + if (!firstJump) { + if (!mc.thePlayer.onGround) { + if (!startedTowerInAir) { + //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.04); + } + startedTowerInAir = true; + } + else if (mc.thePlayer.onGround) { + //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); + firstJump = true; + } + } + } + if (canTower() && !Utils.keysDown() && verticalTower.getInput() > 0) { + disableJump = true; + } + if (delay) { + disableJump = true; + } + if (disableJump) { + if (disableWhileHurt.isToggled() && ModuleUtils.damage && !delay) { + return; + } + mc.thePlayer.movementInput.jump = false; + } + } + + @SubscribeEvent + public void onSendPacket(SendPacketEvent e) { + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { + if (firstVTP) { + ebDelay++; + if (ebDelay >= extraBlockDelay.getInput() + 2) { + ebDelay = 0; + } + } + if (canTower() && Utils.isMoving()) { + ++placeTicks; + if (((C08PacketPlayerBlockPlacement) e.getPacket()).getPlacedBlockDirection() == 1 && hasTowered) { + upFaces++; + if (placeTicks > 5) { + dCount++; + if (dCount >= 2) { + //Utils.sendMessage("Hey"); + setLowMotion = true; + } + } + } + else { + dCount = upFaces = 0; + } + } + else { + placeTicks = upFaces = 0; + } + + if (aligned) { + placed = true; + } + } + } + + private void reset() { + towerTicks = 0; + towering = false; + placeTicks = 0; + setLowMotion = false; + } + + public boolean cancelKnockback() { + if (!canTower()) { + return false; + } + if (cancelVelocityRequired.isToggled() && !ModuleManager.velocity.isEnabled()) { + return false; + } + if (cancelKnockback.isToggled()) { + return true; + } + return false; + } + + public boolean canTower() { + if (!Utils.nullCheck() || !Utils.jumpDown() || !Utils.tabbedIn()) { + return false; + } + else if (mc.thePlayer.isCollidedHorizontally) { + return false; + } + else if ((mc.thePlayer.isInWater() || mc.thePlayer.isInLava())) { + return false; + } + else if (modulesEnabled()) { + return true; + } + return false; + } + + private boolean modulesEnabled() { + return (ModuleManager.scaffold.moduleEnabled && ModuleManager.scaffold.holdingBlocks() && ModuleManager.scaffold.hasSwapped && !LongJump.function); + } + + private int getSpeedLevel() { + for (PotionEffect potionEffect : mc.thePlayer.getActivePotionEffects()) { + if (potionEffect.getEffectName().equals("potion.moveSpeed")) { + return potionEffect.getAmplifier() + 1; + } + return 0; + } + return 0; + } + + private double verticalTowerValue() { + int valY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); + double value = 0; + if (valY == 0) { + value = 0.42f; + } else if (valY > 4000 && valY < 4300) { + value = 0.33f; + } else if (valY > 7000) { + value = 1 - mc.thePlayer.posY % 1; + } + return value; + } + + private double getTowerSpeed(int speedLevel) { + if (speedLevel == 0) { + return (speedSetting.getInput() / 10); + } else if (speedLevel == 1) { + return (speedSetting.getInput() / 10) + 0.04; + } else if (speedLevel == 2) { + return (speedSetting.getInput() / 10) + 0.08; + } else if (speedLevel == 3) { + return (speedSetting.getInput() / 10) + 0.12; + } else if (speedLevel == 4) { + return (speedSetting.getInput() / 10) + 0.12; + } + return (speedSetting.getInput() / 10); + } + + private double getTowerGroundSpeed(int speedLevel) { + if (speedLevel == 0) { + return (speedSetting.getInput() / 10) - 0.085; + } else if (speedLevel == 1) { + return (speedSetting.getInput() / 10) - 0.05; + } else if (speedLevel == 2) { + return (speedSetting.getInput() / 10); + } else if (speedLevel == 3) { + return (speedSetting.getInput() / 10) + 0.05; + } else if (speedLevel == 4) { + return (speedSetting.getInput() / 10) + 0.10; + } + return (speedSetting.getInput() / 10) - 0.08; + } + + private double get15tickspeed(int speedLevel) { + if (speedLevel == 0) { + return (speedSetting.getInput() / 10); + } else if (speedLevel == 1) { + return (speedSetting.getInput() / 10) + 0.04; + } else if (speedLevel == 2) { + return (speedSetting.getInput() / 10) + 0.08; + } else if (speedLevel == 3) { + return (speedSetting.getInput() / 10) + 0.12; + } else if (speedLevel == 4) { + return (speedSetting.getInput() / 10) + 0.13; + } + return (speedSetting.getInput() / 10); + } + + private double get1tickspeed(int speedLevel) { + if (speedLevel == 0) { + return (speedSetting.getInput() / 10); + } else if (speedLevel == 1) { + return (speedSetting.getInput() / 10) + 0.03; + } else if (speedLevel == 2) { + return (speedSetting.getInput() / 10) + 0.06; + } else if (speedLevel == 3) { + return (speedSetting.getInput() / 10) + 0.1; + } else if (speedLevel == 4) { + return (speedSetting.getInput() / 10) + 0.11; + } + return (speedSetting.getInput() / 10); + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/AntiDebuff.java b/src/main/java/keystrokesmod/module/impl/render/AntiDebuff.java index f46226f..672b265 100644 --- a/src/main/java/keystrokesmod/module/impl/render/AntiDebuff.java +++ b/src/main/java/keystrokesmod/module/impl/render/AntiDebuff.java @@ -1,27 +1,27 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import net.minecraft.potion.Potion; - -public class AntiDebuff extends Module { - public ButtonSetting removeBlindness; - public ButtonSetting removeNausea; - public ButtonSetting removeSideEffects; - - public AntiDebuff() { - super("AntiDebuff", category.render); - this.registerSetting(removeBlindness = new ButtonSetting("Remove blindness", true)); - this.registerSetting(removeNausea = new ButtonSetting("Remove nausea", true)); - this.registerSetting(removeSideEffects = new ButtonSetting("Remove side effects", false)); - } - - public boolean canRemoveBlindness(Potion potion) { - return this.isEnabled() && potion == Potion.blindness && this.removeBlindness.isToggled(); - } - - public boolean canRemoveNausea(Potion potion) { - return this.isEnabled() && potion == Potion.confusion && this.removeNausea.isToggled(); - } - +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import net.minecraft.potion.Potion; + +public class AntiDebuff extends Module { + public ButtonSetting removeBlindness; + public ButtonSetting removeNausea; + public ButtonSetting removeSideEffects; + + public AntiDebuff() { + super("AntiDebuff", category.render); + this.registerSetting(removeBlindness = new ButtonSetting("Remove blindness", true)); + this.registerSetting(removeNausea = new ButtonSetting("Remove nausea", true)); + this.registerSetting(removeSideEffects = new ButtonSetting("Remove side effects", false)); + } + + public boolean canRemoveBlindness(Potion potion) { + return this.isEnabled() && potion == Potion.blindness && this.removeBlindness.isToggled(); + } + + public boolean canRemoveNausea(Potion potion) { + return this.isEnabled() && potion == Potion.confusion && this.removeNausea.isToggled(); + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/Arrows.java b/src/main/java/keystrokesmod/module/impl/render/Arrows.java index a83f7aa..935cbd5 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Arrows.java +++ b/src/main/java/keystrokesmod/module/impl/render/Arrows.java @@ -1,197 +1,197 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.Vec3; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class Arrows extends Module { - private SliderSetting arrow; - private SliderSetting radius; - private ButtonSetting teamColor; - private ButtonSetting hideTeammates; - private ButtonSetting enemiesOnly; - private ButtonSetting renderFriends; - private ButtonSetting renderEnemies; - private ButtonSetting renderDistance; - private ButtonSetting renderOnlyOffScreen; - private ButtonSetting renderInGUIs; - - private int friendColor = new Color(0, 255, 0, 255).getRGB(); - private int enemyColor = new Color(255, 0, 0, 255).getRGB(); - - private String[] arrowTypes = new String[] { "Caret", "Greater than", "Triangle" }; - - public Arrows() { - super("Arrows", category.render); - this.registerSetting(arrow = new SliderSetting("Arrow", 0, arrowTypes)); - this.registerSetting(radius = new SliderSetting("Circle radius", 50, 30, 200, 5)); - this.registerSetting(teamColor = new ButtonSetting("Team color", true)); - this.registerSetting(hideTeammates = new ButtonSetting("Hide teammates", true)); - this.registerSetting(enemiesOnly = new ButtonSetting("Show enemies only", false)); - this.registerSetting(renderFriends = new ButtonSetting("Render friends (green)", true)); - this.registerSetting(renderEnemies = new ButtonSetting("Render enemies (red)", true)); - this.registerSetting(renderDistance = new ButtonSetting("Render distance", true)); - this.registerSetting(renderOnlyOffScreen = new ButtonSetting("Render only offscreen", false)); - this.registerSetting(renderInGUIs = new ButtonSetting("Render in GUIs", false)); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent event) { - if (event.phase != TickEvent.Phase.END) { - return; - } - if (mc.currentScreen != null && !renderInGUIs.isToggled() || !Utils.nullCheck()) { - return; - } - try { - for (EntityPlayer en : mc.theWorld.playerEntities) { - if (en == null || en == mc.thePlayer) { - continue; - } - if (AntiBot.isBot(en)) { - continue; - } - this.renderIndicatorFor(en, event.renderTickTime); - } - } - catch (Exception e) {} - } - - private void renderIndicatorFor(EntityPlayer en, float partialTicks) { - if (renderOnlyOffScreen.isToggled() && RenderUtils.isInViewFrustum(en)) { - return; - } - int color = -1; - - if (Utils.isTeammate(en) && hideTeammates.isToggled()) { - return; - } - if (!Utils.isEnemy(en) && enemiesOnly.isToggled()) { - return; - } - if (renderFriends.isToggled() && Utils.isFriended(en)) { - color = friendColor; - } - else if (renderEnemies.isToggled() && Utils.isEnemy(en)) { - color = enemyColor; - } - else if (teamColor.isToggled()) { - color = Utils.getColorFromEntity(en); - } - - double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; - double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY + en.height / 2; - double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; - - ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); - - ScaledResolution scaledResolution = new ScaledResolution(mc); - Vec3 vec = RenderUtils.convertTo2D(scaledResolution.getScaleFactor(), x, y, z); - - if (vec != null) { - mc.entityRenderer.setupOverlayRendering(); - ScaledResolution res = new ScaledResolution(mc); - - double dx = vec.xCoord - res.getScaledWidth() / 2.0; - double dy = vec.yCoord - res.getScaledHeight() / 2.0; - boolean inFrustum = vec.zCoord < 1.0003684; - - if (!inFrustum) { - dx *= -1.0; - dy *= -1.0; - } - - double angle1 = Math.atan2(dx, dy); - double angle2 = Math.atan2(dy, dx) * 57.295780181884766 + 90.0; - double hypotenuse = Math.hypot(dx, dy); - double radiusInput = radius.getInput(); - - if (inFrustum && hypotenuse < radiusInput + 15.0) { - return; - } - - double baseX = res.getScaledWidth() / 2.0; - double baseY = res.getScaledHeight() / 2.0; - double sinAng = Math.sin(angle1); - double cosAng = Math.cos(angle1); - double renderX = baseX + radiusInput * sinAng; - double renderY = baseY + radiusInput * cosAng; - - GlStateManager.pushMatrix(); - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.rotate((float) angle2, 0.0f, 0.0f, 1.0f); - GlStateManager.scale(1.0f, 1.0f, 1.0f); - - int arrowInput = (int) arrow.getInput(); - - if (arrowInput == 0) { - if (color == -1) { - GL11.glColor3d(1.0, 1.0, 1.0); - } - else { - int rgb = color; - float red = ((rgb >> 16) & 0xFF) / 255.0F; - float green = ((rgb >> 8) & 0xFF) / 255.0F; - float blue = ( rgb & 0xFF) / 255.0F; - GL11.glColor4f(red, green, blue, 1.0f); - } - - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_LINE_SMOOTH); - - double halfAngle = 0.6108652353286743; - double size = 9.0; - double offsetY = 5.0; - GL11.glLineWidth(3.0f); - GL11.glBegin(GL11.GL_LINE_STRIP); - GL11.glVertex2d(Math.sin(-halfAngle) * size, Math.cos(-halfAngle) * size - offsetY); - GL11.glVertex2d(0.0, -offsetY); - GL11.glVertex2d(Math.sin(halfAngle) * size, Math.cos(halfAngle) * size - offsetY); - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - } - else if (arrowInput == 1) { - GlStateManager.rotate(-90.0f, 0.0f, 0.0f, 1.0f); - GlStateManager.scale(1.5, 1.5, 1.5); - mc.fontRendererObj.drawString(">", -2.0f, -4.0f, color, false); - } - else if (arrowInput == 2) { - RenderUtils.draw2DPolygon(0.0, 0.0, 5.0, 3, Utils.mergeAlpha(color, 255)); - } - - GlStateManager.popMatrix(); - - renderX = baseX + (radiusInput - 13.0) * sinAng; - renderY = baseY + (radiusInput - 13.0) * cosAng; - - GlStateManager.pushMatrix(); - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.scale(0.8, 0.8, 0.8); - - if (renderDistance.isToggled()) { - String text = (int) mc.thePlayer.getDistanceToEntity(en) + "m"; - mc.fontRendererObj.drawString(text, (float) (-mc.fontRendererObj.getStringWidth(text) / 2), -4.0f, -1, true); - } - - GlStateManager.popMatrix(); - } - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class Arrows extends Module { + private SliderSetting arrow; + private SliderSetting radius; + private ButtonSetting teamColor; + private ButtonSetting hideTeammates; + private ButtonSetting enemiesOnly; + private ButtonSetting renderFriends; + private ButtonSetting renderEnemies; + private ButtonSetting renderDistance; + private ButtonSetting renderOnlyOffScreen; + private ButtonSetting renderInGUIs; + + private int friendColor = new Color(0, 255, 0, 255).getRGB(); + private int enemyColor = new Color(255, 0, 0, 255).getRGB(); + + private String[] arrowTypes = new String[] { "Caret", "Greater than", "Triangle" }; + + public Arrows() { + super("Arrows", category.render); + this.registerSetting(arrow = new SliderSetting("Arrow", 0, arrowTypes)); + this.registerSetting(radius = new SliderSetting("Circle radius", 50, 30, 200, 5)); + this.registerSetting(teamColor = new ButtonSetting("Team color", true)); + this.registerSetting(hideTeammates = new ButtonSetting("Hide teammates", true)); + this.registerSetting(enemiesOnly = new ButtonSetting("Show enemies only", false)); + this.registerSetting(renderFriends = new ButtonSetting("Render friends (green)", true)); + this.registerSetting(renderEnemies = new ButtonSetting("Render enemies (red)", true)); + this.registerSetting(renderDistance = new ButtonSetting("Render distance", true)); + this.registerSetting(renderOnlyOffScreen = new ButtonSetting("Render only offscreen", false)); + this.registerSetting(renderInGUIs = new ButtonSetting("Render in GUIs", false)); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + if (event.phase != TickEvent.Phase.END) { + return; + } + if (mc.currentScreen != null && !renderInGUIs.isToggled() || !Utils.nullCheck()) { + return; + } + try { + for (EntityPlayer en : mc.theWorld.playerEntities) { + if (en == null || en == mc.thePlayer) { + continue; + } + if (AntiBot.isBot(en)) { + continue; + } + this.renderIndicatorFor(en, event.renderTickTime); + } + } + catch (Exception e) {} + } + + private void renderIndicatorFor(EntityPlayer en, float partialTicks) { + if (renderOnlyOffScreen.isToggled() && RenderUtils.isInViewFrustum(en)) { + return; + } + int color = -1; + + if (Utils.isTeammate(en) && hideTeammates.isToggled()) { + return; + } + if (!Utils.isEnemy(en) && enemiesOnly.isToggled()) { + return; + } + if (renderFriends.isToggled() && Utils.isFriended(en)) { + color = friendColor; + } + else if (renderEnemies.isToggled() && Utils.isEnemy(en)) { + color = enemyColor; + } + else if (teamColor.isToggled()) { + color = Utils.getColorFromEntity(en); + } + + double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; + double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY + en.height / 2; + double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; + + ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); + + ScaledResolution scaledResolution = new ScaledResolution(mc); + Vec3 vec = RenderUtils.convertTo2D(scaledResolution.getScaleFactor(), x, y, z); + + if (vec != null) { + mc.entityRenderer.setupOverlayRendering(); + ScaledResolution res = new ScaledResolution(mc); + + double dx = vec.xCoord - res.getScaledWidth() / 2.0; + double dy = vec.yCoord - res.getScaledHeight() / 2.0; + boolean inFrustum = vec.zCoord < 1.0003684; + + if (!inFrustum) { + dx *= -1.0; + dy *= -1.0; + } + + double angle1 = Math.atan2(dx, dy); + double angle2 = Math.atan2(dy, dx) * 57.295780181884766 + 90.0; + double hypotenuse = Math.hypot(dx, dy); + double radiusInput = radius.getInput(); + + if (inFrustum && hypotenuse < radiusInput + 15.0) { + return; + } + + double baseX = res.getScaledWidth() / 2.0; + double baseY = res.getScaledHeight() / 2.0; + double sinAng = Math.sin(angle1); + double cosAng = Math.cos(angle1); + double renderX = baseX + radiusInput * sinAng; + double renderY = baseY + radiusInput * cosAng; + + GlStateManager.pushMatrix(); + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.rotate((float) angle2, 0.0f, 0.0f, 1.0f); + GlStateManager.scale(1.0f, 1.0f, 1.0f); + + int arrowInput = (int) arrow.getInput(); + + if (arrowInput == 0) { + if (color == -1) { + GL11.glColor3d(1.0, 1.0, 1.0); + } + else { + int rgb = color; + float red = ((rgb >> 16) & 0xFF) / 255.0F; + float green = ((rgb >> 8) & 0xFF) / 255.0F; + float blue = ( rgb & 0xFF) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0f); + } + + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + + double halfAngle = 0.6108652353286743; + double size = 9.0; + double offsetY = 5.0; + GL11.glLineWidth(3.0f); + GL11.glBegin(GL11.GL_LINE_STRIP); + GL11.glVertex2d(Math.sin(-halfAngle) * size, Math.cos(-halfAngle) * size - offsetY); + GL11.glVertex2d(0.0, -offsetY); + GL11.glVertex2d(Math.sin(halfAngle) * size, Math.cos(halfAngle) * size - offsetY); + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + } + else if (arrowInput == 1) { + GlStateManager.rotate(-90.0f, 0.0f, 0.0f, 1.0f); + GlStateManager.scale(1.5, 1.5, 1.5); + mc.fontRendererObj.drawString(">", -2.0f, -4.0f, color, false); + } + else if (arrowInput == 2) { + RenderUtils.draw2DPolygon(0.0, 0.0, 5.0, 3, Utils.mergeAlpha(color, 255)); + } + + GlStateManager.popMatrix(); + + renderX = baseX + (radiusInput - 13.0) * sinAng; + renderY = baseY + (radiusInput - 13.0) * cosAng; + + GlStateManager.pushMatrix(); + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.scale(0.8, 0.8, 0.8); + + if (renderDistance.isToggled()) { + String text = (int) mc.thePlayer.getDistanceToEntity(en) + "m"; + mc.fontRendererObj.drawString(text, (float) (-mc.fontRendererObj.getStringWidth(text) / 2), -4.0f, -1, true); + } + + GlStateManager.popMatrix(); + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/BedESP.java b/src/main/java/keystrokesmod/module/impl/render/BedESP.java index 8a74d0f..a724d39 100644 --- a/src/main/java/keystrokesmod/module/impl/render/BedESP.java +++ b/src/main/java/keystrokesmod/module/impl/render/BedESP.java @@ -1,187 +1,187 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.Raven; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.*; -import net.minecraft.block.BlockBed; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class BedESP extends Module { - public SliderSetting theme; - private SliderSetting range; - private SliderSetting rate; - private ButtonSetting firstBed; - private ButtonSetting renderFullBlock; - private BlockPos[] bed; - private Timer firstBedTimer; - private Map beds = Collections.synchronizedMap(new HashMap<>()); - private long lastCheck = 0; - - public BedESP() { - super("BedESP", category.render); - this.registerSetting(theme = new SliderSetting("Theme", 0, Theme.themes)); - this.registerSetting(range = new SliderSetting("Range", 10.0, 2.0, 200.0, 2.0)); - this.registerSetting(rate = new SliderSetting("Rate", " second", 0.4, 0.1, 3.0, 0.1)); - this.registerSetting(firstBed = new ButtonSetting("Only render first bed", false)); - this.registerSetting(renderFullBlock = new ButtonSetting("Render full block", false)); - } - - public void onUpdate() { - if (System.currentTimeMillis() - lastCheck < rate.getInput() * 1000) { - return; - } - lastCheck = System.currentTimeMillis(); - Raven.getCachedExecutor().execute(() -> { - int i; - priorityLoop: - for (int n = i = (int) range.getInput(); i >= -n; --i) { - for (int j = -n; j <= n; ++j) { - for (int k = -n; k <= n; ++k) { - final BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k); - final IBlockState getBlockState = mc.theWorld.getBlockState(blockPos); - if (getBlockState.getBlock() == Blocks.bed && getBlockState.getValue((IProperty) BlockBed.PART) == BlockBed.EnumPartType.FOOT) { - if (firstBed.isToggled()) { - if (this.bed != null && BlockUtils.isSamePos(blockPos, this.bed[0])) { - return; - } - this.bed = new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))}; - return; - } - else { - for (BlockPos[] pos : beds.keySet()) { - if (BlockUtils.isSamePos(blockPos, pos[0])) { - continue priorityLoop; - } - } - this.beds.put(new BlockPos[] { blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING)) }, null); - } - } - } - } - } - }); - } - - @SubscribeEvent - public void onEntityJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - this.beds.clear(); - this.bed = null; - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderWorld(RenderWorldLastEvent e) { - if (Utils.nullCheck()) { - float blockHeight = getBlockHeight(); - if (firstBed.isToggled() && this.bed != null) { - float customAlpha = 0.25f; - if (!isBed(bed[0])) { - if (firstBedTimer == null) { - (firstBedTimer = (new Timer(300))).start(); - } - int alpha = firstBedTimer == null ? 230 : 230 - firstBedTimer.getValueInt(0, 230, 1); - if (alpha <= 0) { - this.bed = null; - return; - } - customAlpha = alpha / 255.0f; - } - else { - firstBedTimer = null; - } - renderBed(this.bed, blockHeight, customAlpha); - return; - } - synchronized (beds) { - Iterator> iterator = this.beds.entrySet().iterator(); - while (iterator.hasNext()) { - float customAlpha = 0.25f; - Map.Entry entry = iterator.next(); - BlockPos[] blockPos = entry.getKey(); - if (!isBed(blockPos[0])) { - if (entry.getValue() == null) { - entry.setValue(new Timer(300)); - entry.getValue().start(); - } - int alpha = entry.getValue() == null ? 230 : 230 - entry.getValue().getValueInt(0, 230, 1); - if (alpha <= 0) { - iterator.remove(); - continue; - } - customAlpha = alpha / 255.0f; - } - else { - entry.setValue(null); - } - renderBed(blockPos, blockHeight, customAlpha); - } - } - } - } - - public void onDisable() { - this.bed = null; - this.beds.clear(); - } - - private void renderBed(final BlockPos[] array, float height, float alpha) { - final double n = array[0].getX() - mc.getRenderManager().viewerPosX; - final double n2 = array[0].getY() - mc.getRenderManager().viewerPosY; - final double n3 = array[0].getZ() - mc.getRenderManager().viewerPosZ; - GL11.glBlendFunc(770, 771); - GL11.glEnable(3042); - GL11.glLineWidth(2.0f); - GL11.glDisable(3553); - GL11.glDisable(2929); - GL11.glDepthMask(false); - final int color = Theme.getGradient((int) theme.getInput(), 0); - final float a = (color >> 24 & 0xFF) / 255.0f; - final float r = (color >> 16 & 0xFF) / 255.0f; - final float g = (color >> 8 & 0xFF) / 255.0f; - final float b = (color & 0xFF) / 255.0f; - GL11.glColor4d(r, g, b, a); - AxisAlignedBB axisAlignedBB; - if (array[0].getX() != array[1].getX()) { - if (array[0].getX() > array[1].getX()) { - axisAlignedBB = new AxisAlignedBB(n - 1.0, n2, n3, n + 1.0, n2 + height, n3 + 1.0); - } else { - axisAlignedBB = new AxisAlignedBB(n, n2, n3, n + 2.0, n2 + height, n3 + 1.0); - } - } else if (array[0].getZ() > array[1].getZ()) { - axisAlignedBB = new AxisAlignedBB(n, n2, n3 - 1.0, n + 1.0, n2 + height, n3 + 1.0); - } else { - axisAlignedBB = new AxisAlignedBB(n, n2, n3, n + 1.0, n2 + height, n3 + 2.0); - } - RenderUtils.drawBoundingBox(axisAlignedBB, r, g, b, alpha); - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDepthMask(true); - GL11.glDisable(3042); - } - - private float getBlockHeight() { - return (renderFullBlock.isToggled() ? 1 : 0.5625F); - } - - public boolean isBed(BlockPos blockPos) { - return mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockBed; - } +package keystrokesmod.module.impl.render; + +import keystrokesmod.Raven; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.*; +import net.minecraft.block.BlockBed; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class BedESP extends Module { + public SliderSetting theme; + private SliderSetting range; + private SliderSetting rate; + private ButtonSetting firstBed; + private ButtonSetting renderFullBlock; + private BlockPos[] bed; + private Timer firstBedTimer; + private Map beds = Collections.synchronizedMap(new HashMap<>()); + private long lastCheck = 0; + + public BedESP() { + super("BedESP", category.render); + this.registerSetting(theme = new SliderSetting("Theme", 0, Theme.themes)); + this.registerSetting(range = new SliderSetting("Range", 10.0, 2.0, 200.0, 2.0)); + this.registerSetting(rate = new SliderSetting("Rate", " second", 0.4, 0.1, 3.0, 0.1)); + this.registerSetting(firstBed = new ButtonSetting("Only render first bed", false)); + this.registerSetting(renderFullBlock = new ButtonSetting("Render full block", false)); + } + + public void onUpdate() { + if (System.currentTimeMillis() - lastCheck < rate.getInput() * 1000) { + return; + } + lastCheck = System.currentTimeMillis(); + Raven.getCachedExecutor().execute(() -> { + int i; + priorityLoop: + for (int n = i = (int) range.getInput(); i >= -n; --i) { + for (int j = -n; j <= n; ++j) { + for (int k = -n; k <= n; ++k) { + final BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k); + final IBlockState getBlockState = mc.theWorld.getBlockState(blockPos); + if (getBlockState.getBlock() == Blocks.bed && getBlockState.getValue((IProperty) BlockBed.PART) == BlockBed.EnumPartType.FOOT) { + if (firstBed.isToggled()) { + if (this.bed != null && BlockUtils.isSamePos(blockPos, this.bed[0])) { + return; + } + this.bed = new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))}; + return; + } + else { + for (BlockPos[] pos : beds.keySet()) { + if (BlockUtils.isSamePos(blockPos, pos[0])) { + continue priorityLoop; + } + } + this.beds.put(new BlockPos[] { blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING)) }, null); + } + } + } + } + } + }); + } + + @SubscribeEvent + public void onEntityJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + this.beds.clear(); + this.bed = null; + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderWorld(RenderWorldLastEvent e) { + if (Utils.nullCheck()) { + float blockHeight = getBlockHeight(); + if (firstBed.isToggled() && this.bed != null) { + float customAlpha = 0.25f; + if (!isBed(bed[0])) { + if (firstBedTimer == null) { + (firstBedTimer = (new Timer(300))).start(); + } + int alpha = firstBedTimer == null ? 230 : 230 - firstBedTimer.getValueInt(0, 230, 1); + if (alpha <= 0) { + this.bed = null; + return; + } + customAlpha = alpha / 255.0f; + } + else { + firstBedTimer = null; + } + renderBed(this.bed, blockHeight, customAlpha); + return; + } + synchronized (beds) { + Iterator> iterator = this.beds.entrySet().iterator(); + while (iterator.hasNext()) { + float customAlpha = 0.25f; + Map.Entry entry = iterator.next(); + BlockPos[] blockPos = entry.getKey(); + if (!isBed(blockPos[0])) { + if (entry.getValue() == null) { + entry.setValue(new Timer(300)); + entry.getValue().start(); + } + int alpha = entry.getValue() == null ? 230 : 230 - entry.getValue().getValueInt(0, 230, 1); + if (alpha <= 0) { + iterator.remove(); + continue; + } + customAlpha = alpha / 255.0f; + } + else { + entry.setValue(null); + } + renderBed(blockPos, blockHeight, customAlpha); + } + } + } + } + + public void onDisable() { + this.bed = null; + this.beds.clear(); + } + + private void renderBed(final BlockPos[] array, float height, float alpha) { + final double n = array[0].getX() - mc.getRenderManager().viewerPosX; + final double n2 = array[0].getY() - mc.getRenderManager().viewerPosY; + final double n3 = array[0].getZ() - mc.getRenderManager().viewerPosZ; + GL11.glBlendFunc(770, 771); + GL11.glEnable(3042); + GL11.glLineWidth(2.0f); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glDepthMask(false); + final int color = Theme.getGradient((int) theme.getInput(), 0); + final float a = (color >> 24 & 0xFF) / 255.0f; + final float r = (color >> 16 & 0xFF) / 255.0f; + final float g = (color >> 8 & 0xFF) / 255.0f; + final float b = (color & 0xFF) / 255.0f; + GL11.glColor4d(r, g, b, a); + AxisAlignedBB axisAlignedBB; + if (array[0].getX() != array[1].getX()) { + if (array[0].getX() > array[1].getX()) { + axisAlignedBB = new AxisAlignedBB(n - 1.0, n2, n3, n + 1.0, n2 + height, n3 + 1.0); + } else { + axisAlignedBB = new AxisAlignedBB(n, n2, n3, n + 2.0, n2 + height, n3 + 1.0); + } + } else if (array[0].getZ() > array[1].getZ()) { + axisAlignedBB = new AxisAlignedBB(n, n2, n3 - 1.0, n + 1.0, n2 + height, n3 + 1.0); + } else { + axisAlignedBB = new AxisAlignedBB(n, n2, n3, n + 1.0, n2 + height, n3 + 2.0); + } + RenderUtils.drawBoundingBox(axisAlignedBB, r, g, b, alpha); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + } + + private float getBlockHeight() { + return (renderFullBlock.isToggled() ? 1 : 0.5625F); + } + + public boolean isBed(BlockPos blockPos) { + return mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockBed; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/BreakProgress.java b/src/main/java/keystrokesmod/module/impl/render/BreakProgress.java index 23a474a..3ac516d 100644 --- a/src/main/java/keystrokesmod/module/impl/render/BreakProgress.java +++ b/src/main/java/keystrokesmod/module/impl/render/BreakProgress.java @@ -1,118 +1,118 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.mixin.impl.accessor.IAccessorPlayerControllerMP; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.BlockBed; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; - -public class BreakProgress extends Module { - private SliderSetting mode; - private ButtonSetting manual; - private ButtonSetting bedAura; - private ButtonSetting fadeIn; - - private String[] modes = new String[] { "Percentage", "Second", "Decimal" }; - - private float progress; - private BlockPos block; - private String progressStr; - - public BreakProgress() { - super("BreakProgress", category.render); - this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); - this.registerSetting(manual = new ButtonSetting("Show manual", true)); - this.registerSetting(bedAura = new ButtonSetting("Show BedAura", true)); - this.registerSetting(fadeIn = new ButtonSetting("Fade in", false)); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderWorld(RenderWorldLastEvent e) { - if (this.progress == 0.0f || this.block == null || !Utils.nullCheck()) { - return; - } - final double x = this.block.getX() + 0.5 - mc.getRenderManager().viewerPosX; - final double y = this.block.getY() + 0.5 - mc.getRenderManager().viewerPosY; - final double z = this.block.getZ() + 0.5 - mc.getRenderManager().viewerPosZ; - GlStateManager.pushMatrix(); - GlStateManager.translate((float) x, (float) y, (float) z); - GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate((mc.gameSettings.thirdPersonView == 2 ? -1 : 1) * mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); - GlStateManager.scale(-0.02266667f, -0.02266667f, -0.02266667f); - GlStateManager.depthMask(false); - GlStateManager.disableDepth(); - GL11.glEnable(GL11.GL_BLEND); - int colorAlpha = Utils.mergeAlpha(-1, Math.max(10, (int) (255 * progress))); - mc.fontRendererObj.drawString(this.progressStr, (float) (-mc.fontRendererObj.getStringWidth(this.progressStr) / 2), -3.0f, fadeIn.isToggled() ? colorAlpha : -1, true); - GL11.glDisable(GL11.GL_BLEND); - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.popMatrix(); - } - - private void setProgress() { - switch ((int) mode.getInput()) { - case 0: { - this.progressStr = (int) (100.0 * (this.progress / 1.0)) + "%"; - break; - } - case 1: { - double timeLeft = Utils.round((double) ((1.0f - this.progress) / BlockUtils.getBlockHardness(BlockUtils.getBlock(this.block), mc.thePlayer.getHeldItem(), false, false)) / 20.0, 1); - this.progressStr = timeLeft == 0 ? "0" : timeLeft + "s"; - break; - } - case 2: { - this.progressStr = String.valueOf(Utils.round(this.progress, 2)); - break; - } - } - } - - public void onUpdate() { - if (mc.thePlayer.capabilities.isCreativeMode || !mc.thePlayer.capabilities.allowEdit) { - this.resetVariables(); - return; - } - if (bedAura.isToggled() && ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && ModuleManager.bedAura.breakProgress != 0.0f && ModuleManager.bedAura.currentBlock != null && !(BlockUtils.getBlock(ModuleManager.bedAura.currentBlock) instanceof BlockBed)) { - this.progress = Math.min(1.0f, ModuleManager.bedAura.breakProgress); - this.block = ModuleManager.bedAura.currentBlock; - if (this.block == null) { - return; - } - this.setProgress(); - return; - } - if (!manual.isToggled() || mc.objectMouseOver == null || mc.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { - this.resetVariables(); - return; - } - this.progress = ((IAccessorPlayerControllerMP) mc.playerController).getCurBlockDamageMP(); - if (this.progress == 0.0f) { - this.resetVariables(); - return; - } - this.block = mc.objectMouseOver.getBlockPos(); - this.setProgress(); - } - - public void onDisable() { - this.resetVariables(); - } - - private void resetVariables() { - this.progress = 0.0f; - this.block = null; - this.progressStr = ""; - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.mixin.impl.accessor.IAccessorPlayerControllerMP; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.BlockBed; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +public class BreakProgress extends Module { + private SliderSetting mode; + private ButtonSetting manual; + private ButtonSetting bedAura; + private ButtonSetting fadeIn; + + private String[] modes = new String[] { "Percentage", "Second", "Decimal" }; + + private float progress; + private BlockPos block; + private String progressStr; + + public BreakProgress() { + super("BreakProgress", category.render); + this.registerSetting(mode = new SliderSetting("Mode", 0, modes)); + this.registerSetting(manual = new ButtonSetting("Show manual", true)); + this.registerSetting(bedAura = new ButtonSetting("Show BedAura", true)); + this.registerSetting(fadeIn = new ButtonSetting("Fade in", false)); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderWorld(RenderWorldLastEvent e) { + if (this.progress == 0.0f || this.block == null || !Utils.nullCheck()) { + return; + } + final double x = this.block.getX() + 0.5 - mc.getRenderManager().viewerPosX; + final double y = this.block.getY() + 0.5 - mc.getRenderManager().viewerPosY; + final double z = this.block.getZ() + 0.5 - mc.getRenderManager().viewerPosZ; + GlStateManager.pushMatrix(); + GlStateManager.translate((float) x, (float) y, (float) z); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0f, 1.0f, 0.0f); + GlStateManager.rotate((mc.gameSettings.thirdPersonView == 2 ? -1 : 1) * mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); + GlStateManager.scale(-0.02266667f, -0.02266667f, -0.02266667f); + GlStateManager.depthMask(false); + GlStateManager.disableDepth(); + GL11.glEnable(GL11.GL_BLEND); + int colorAlpha = Utils.mergeAlpha(-1, Math.max(10, (int) (255 * progress))); + mc.fontRendererObj.drawString(this.progressStr, (float) (-mc.fontRendererObj.getStringWidth(this.progressStr) / 2), -3.0f, fadeIn.isToggled() ? colorAlpha : -1, true); + GL11.glDisable(GL11.GL_BLEND); + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.popMatrix(); + } + + private void setProgress() { + switch ((int) mode.getInput()) { + case 0: { + this.progressStr = (int) (100.0 * (this.progress / 1.0)) + "%"; + break; + } + case 1: { + double timeLeft = Utils.round((double) ((1.0f - this.progress) / BlockUtils.getBlockHardness(BlockUtils.getBlock(this.block), mc.thePlayer.getHeldItem(), false, false)) / 20.0, 1); + this.progressStr = timeLeft == 0 ? "0" : timeLeft + "s"; + break; + } + case 2: { + this.progressStr = String.valueOf(Utils.round(this.progress, 2)); + break; + } + } + } + + public void onUpdate() { + if (mc.thePlayer.capabilities.isCreativeMode || !mc.thePlayer.capabilities.allowEdit) { + this.resetVariables(); + return; + } + if (bedAura.isToggled() && ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled() && ModuleManager.bedAura.breakProgress != 0.0f && ModuleManager.bedAura.currentBlock != null && !(BlockUtils.getBlock(ModuleManager.bedAura.currentBlock) instanceof BlockBed)) { + this.progress = Math.min(1.0f, ModuleManager.bedAura.breakProgress); + this.block = ModuleManager.bedAura.currentBlock; + if (this.block == null) { + return; + } + this.setProgress(); + return; + } + if (!manual.isToggled() || mc.objectMouseOver == null || mc.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + this.resetVariables(); + return; + } + this.progress = ((IAccessorPlayerControllerMP) mc.playerController).getCurBlockDamageMP(); + if (this.progress == 0.0f) { + this.resetVariables(); + return; + } + this.block = mc.objectMouseOver.getBlockPos(); + this.setProgress(); + } + + public void onDisable() { + this.resetVariables(); + } + + private void resetVariables() { + this.progress = 0.0f; + this.block = null; + this.progressStr = ""; + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/ExtendCamera.java b/src/main/java/keystrokesmod/module/impl/render/ExtendCamera.java index b6bf7a7..0f14da0 100644 --- a/src/main/java/keystrokesmod/module/impl/render/ExtendCamera.java +++ b/src/main/java/keystrokesmod/module/impl/render/ExtendCamera.java @@ -1,43 +1,43 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; - -public class ExtendCamera extends Module { - public SliderSetting distance; - private float lastDistance; - public ExtendCamera() { - super("ExtendCamera", category.render); - this.registerSetting(new DescriptionSetting("Extends camera in third person.")); - this.registerSetting(new DescriptionSetting("Default is 4 blocks.")); - this.registerSetting(distance = new SliderSetting("Distance", " block", 4, 1, 40, 0.5)); - } - - public void onEnable() { - setThirdPersonDistance((float) distance.getInput()); - } - - public void onUpdate() { - try { - float input = (float) distance.getInput(); - if (lastDistance != input) { - setThirdPersonDistance(lastDistance = input); - } - } - catch (Exception e) { - e.printStackTrace(); - Utils.sendMessage("&cThere was an issue setting third person distance."); - } - } - - public void onDisable() { - setThirdPersonDistance(4.0f); - } - - private void setThirdPersonDistance(float distance) { - ((IAccessorEntityRenderer) mc.entityRenderer).setThirdPersonDistance(distance); - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; + +public class ExtendCamera extends Module { + public SliderSetting distance; + private float lastDistance; + public ExtendCamera() { + super("ExtendCamera", category.render); + this.registerSetting(new DescriptionSetting("Extends camera in third person.")); + this.registerSetting(new DescriptionSetting("Default is 4 blocks.")); + this.registerSetting(distance = new SliderSetting("Distance", " block", 4, 1, 40, 0.5)); + } + + public void onEnable() { + setThirdPersonDistance((float) distance.getInput()); + } + + public void onUpdate() { + try { + float input = (float) distance.getInput(); + if (lastDistance != input) { + setThirdPersonDistance(lastDistance = input); + } + } + catch (Exception e) { + e.printStackTrace(); + Utils.sendMessage("&cThere was an issue setting third person distance."); + } + } + + public void onDisable() { + setThirdPersonDistance(4.0f); + } + + private void setThirdPersonDistance(float distance) { + ((IAccessorEntityRenderer) mc.entityRenderer).setThirdPersonDistance(distance); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/HUD.java b/src/main/java/keystrokesmod/module/impl/render/HUD.java index 5a39513..903819f 100644 --- a/src/main/java/keystrokesmod/module/impl/render/HUD.java +++ b/src/main/java/keystrokesmod/module/impl/render/HUD.java @@ -25,7 +25,8 @@ public class HUD extends Module { public static SliderSetting theme; private static SliderSetting outline; public static ButtonSetting alphabeticalSort; - private static ButtonSetting drawBackground; + private static SliderSetting backgroundAlpha; + private static SliderSetting gap; private static ButtonSetting alignRight; private static ButtonSetting lowercase; private static ButtonSetting removeCloset; @@ -37,7 +38,9 @@ public class HUD extends Module { private boolean isAlphabeticalSort; private boolean canShowInfo; private String[] outlineModes = new String[] { "None", "Full", "Side" }; - private static int backGroundColor = new Color(0, 0, 0, 110).getRGB(); + + private static double gapv; + private static int a; public HUD() { super("HUD", Module.category.render); @@ -49,7 +52,9 @@ public class HUD extends Module { })); this.registerSetting(alignRight = new ButtonSetting("Align right", false)); this.registerSetting(alphabeticalSort = new ButtonSetting("Alphabetical sort", false)); - this.registerSetting(drawBackground = new ButtonSetting("Draw background", false)); + //this.registerSetting(drawBackground = new ButtonSetting("Draw background", false)); + this.registerSetting(backgroundAlpha = new SliderSetting("Background alpha", 50, 0, 100, 1)); + this.registerSetting(gap = new SliderSetting("Gap", 2, 0, 10, 0.5)); this.registerSetting(lowercase = new ButtonSetting("Lowercase", false)); this.registerSetting(removeCloset = new ButtonSetting("Remove closet modules", false)); this.registerSetting(removeRender = new ButtonSetting("Remove render modules", false)); @@ -72,6 +77,9 @@ public class HUD extends Module { if (ev.phase != TickEvent.Phase.END || !Utils.nullCheck()) { return; } + gapv = gap.getInput(); + a = (int) (backgroundAlpha.getInput() * 2.55); + int alpha = new Color(0, 0, 0, a).getRGB(); if (isAlphabeticalSort != alphabeticalSort.isToggled()) { isAlphabeticalSort = alphabeticalSort.isToggled(); ModuleManager.sort(); @@ -127,8 +135,8 @@ public class HUD extends Module { if (alignRight.isToggled()) { xPos -= mc.fontRendererObj.getStringWidth(moduleName); } - if (drawBackground.isToggled()) { - RenderUtils.drawRect(xPos - 1, yPos - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, yPos + mc.fontRendererObj.FONT_HEIGHT + 1, backGroundColor); + if (backgroundAlpha.getInput() != 0) { + RenderUtils.drawRect(xPos - 1, yPos - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, yPos + mc.fontRendererObj.FONT_HEIGHT + 1, alpha); } if (outline.getInput() == 1 && n2 == 0.0) { // top RenderUtils.drawRect(xPos - 2, yPos - 2, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 1.5, yPos - 1, color); @@ -163,13 +171,13 @@ public class HUD extends Module { RenderUtils.drawRect(xPos - 2, yPos - 1, xPos - 1, yPos + mc.fontRendererObj.FONT_HEIGHT + 1, color); } else { - RenderUtils.drawRect(xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, yPos - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 1.5, yPos + mc.fontRendererObj.FONT_HEIGHT + 1, color); + RenderUtils.drawRect(xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, yPos - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 1.5, yPos + mc.fontRendererObj.FONT_HEIGHT + (gapv / 2), color); } } mc.fontRendererObj.drawString(moduleName, xPos, (float) yPos, color, true); previousModule = moduleName; lastXPos = xPos; - yPos += mc.fontRendererObj.FONT_HEIGHT + 2; + yPos += mc.fontRendererObj.FONT_HEIGHT + gapv; } } } @@ -321,8 +329,8 @@ public class HUD extends Module { } else { n2 -= 12; } - if (drawBackground.isToggled()) { - RenderUtils.drawRect(xPos - 1, n - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, n + mc.fontRendererObj.FONT_HEIGHT + 1, backGroundColor); + if (backgroundAlpha.getInput() != 0) { + RenderUtils.drawRect(xPos - 1, n - 1, xPos + mc.fontRendererObj.getStringWidth(moduleName) + 0.5, n + mc.fontRendererObj.FONT_HEIGHT + (gapv / 2), a); } if (n2 != 0 && outline.getInput() == 1) { // between double difference = mc.fontRendererObj.getStringWidth(previousModule) - mc.fontRendererObj.getStringWidth(moduleName); diff --git a/src/main/java/keystrokesmod/module/impl/render/Indicators.java b/src/main/java/keystrokesmod/module/impl/render/Indicators.java index 6c2bb42..ae77cf1 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Indicators.java +++ b/src/main/java/keystrokesmod/module/impl/render/Indicators.java @@ -1,337 +1,337 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.mixin.impl.accessor.IAccessorEntityArrow; -import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.GroupSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockFire; -import net.minecraft.block.BlockLiquid; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityEnderPearl; -import net.minecraft.entity.projectile.*; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.HashSet; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -public class Indicators extends Module { - private GroupSetting items; - private ButtonSetting renderArrows; - private ButtonSetting renderPearls; - private ButtonSetting renderFireballs; - private ButtonSetting renderEggs; - private ButtonSetting renderSnowballs; - - private SliderSetting arrow; - private SliderSetting radius; - private ButtonSetting itemColors; - private ButtonSetting renderItem; - private ButtonSetting renderDistance; - private ButtonSetting threatsOnly; - private ButtonSetting renderOnlyOffScreen; - - private HashSet threats = new HashSet<>(); - private Map lastHeldItems = new ConcurrentHashMap<>(); - - private String[] arrowTypes = new String[] { "Caret", "Greater than", "Triangle" }; - - public Indicators() { - super("Indicators", category.render); - this.registerSetting(items = new GroupSetting("Items")); - this.registerSetting(renderArrows = new ButtonSetting(items, "Render arrows", true)); - this.registerSetting(renderPearls = new ButtonSetting(items, "Render ender pearls", true)); - this.registerSetting(renderFireballs = new ButtonSetting(items, "Render fireballs", true)); - this.registerSetting(renderEggs = new ButtonSetting(items, "Render eggs", false)); - this.registerSetting(renderSnowballs = new ButtonSetting(items, "Render snowballs", false)); - this.registerSetting(arrow = new SliderSetting("Arrow", 0, arrowTypes)); - this.registerSetting(radius = new SliderSetting("Circle radius", 50, 30, 200, 5)); - this.registerSetting(itemColors = new ButtonSetting("Item colors", true)); - this.registerSetting(renderItem = new ButtonSetting("Render item", true)); - this.registerSetting(renderDistance = new ButtonSetting("Render distance", true)); - this.registerSetting(threatsOnly = new ButtonSetting("Render only threats", true)); - this.registerSetting(renderOnlyOffScreen = new ButtonSetting("Render only offscreen", false)); - } - - public void onDisable() { - this.threats.clear(); - this.lastHeldItems.clear(); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent event) { - if (event.phase != TickEvent.Phase.END) { - return; - } - if (mc.currentScreen != null || !Utils.nullCheck()) { - return; - } - try { - for (Entity en : mc.theWorld.loadedEntityList) { - if (en == null || en == mc.thePlayer) { - continue; - } - ItemStack itemStack = null; - if (en instanceof EntityArrow) { - if (((IAccessorEntityArrow) en).getInGround()) { - threats.remove(en); - continue; - } - itemStack = new ItemStack(Items.arrow); - } - else if (en instanceof EntityFireball) { - itemStack = new ItemStack(Items.fire_charge); - } - else if (en instanceof EntityEnderPearl) { - itemStack = new ItemStack(Items.ender_pearl); - } - else if (en instanceof EntityEgg) { - itemStack = new ItemStack(Items.egg); - } - else if (en instanceof EntitySnowball) { - itemStack = new ItemStack(Items.snowball); - } - if (!threats.contains(en)) { - continue; - } - if (!mc.theWorld.loadedEntityList.contains(en) || !canRender(en)) { - threats.remove(en); - continue; - } - this.renderIndicatorFor(en, itemStack, event.renderTickTime); - } - } - catch (Exception e) {} - } - - @SubscribeEvent - public void onEntityJoin(EntityJoinWorldEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (e.entity == mc.thePlayer) { - this.threats.clear(); - } - else if (canRender(e.entity) && (mc.thePlayer.getDistanceSqToEntity(e.entity) > 36 || !threatsOnly.isToggled())) { - this.threats.add(e.entity); - } - } - - private boolean canRender(Entity entity) { - if (entity instanceof EntityArrow && !((IAccessorEntityArrow) entity).getInGround() && renderArrows.isToggled()) { - return true; - } - else if (entity instanceof EntityLargeFireball && renderFireballs.isToggled()) { - return true; - } - else if (entity instanceof EntityEnderPearl && renderPearls.isToggled()) { - return true; - } - else if (entity instanceof EntityEgg && renderEggs.isToggled()) { - return true; - } - else if (entity instanceof EntitySnowball && renderSnowballs.isToggled()) { - return true; - } - return false; - } - - private void renderIndicatorFor(Entity en, ItemStack itemStack, float partialTicks) { - if (!this.canRender(en)) { - return; - } - if (!this.shouldRender(en, itemStack)) { - return; - } - if (renderOnlyOffScreen.isToggled() && RenderUtils.isInViewFrustum(en)) { - return; - } - Color colorForStack = getColorForItem(itemStack); - int color = itemColors.isToggled() ? colorForStack.getRGB() : -1; - - double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; - double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY + en.height / 2; - double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; - - ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); - - ScaledResolution scaledResolution = new ScaledResolution(mc); - Vec3 vec = RenderUtils.convertTo2D(scaledResolution.getScaleFactor(), x, y, z); - - if (vec != null) { - mc.entityRenderer.setupOverlayRendering(); - ScaledResolution res = new ScaledResolution(mc); - - double dx = vec.xCoord - res.getScaledWidth() / 2.0; - double dy = vec.yCoord - res.getScaledHeight() / 2.0; - boolean inFrustum = vec.zCoord < 1.0003684; - - if (!inFrustum) { - dx *= -1.0; - dy *= -1.0; - } - - double angle1 = Math.atan2(dx, dy); - double angle2 = Math.atan2(dy, dx) * 57.295780181884766 + 90.0; - double hypotenuse = Math.hypot(dx, dy); - double radiusInput = radius.getInput(); - - if (renderItem.isToggled()) { - radiusInput += 20.0; - } - - if (inFrustum && hypotenuse < radiusInput + 15.0) { - return; - } - - double baseX = res.getScaledWidth() / 2.0; - double baseY = res.getScaledHeight() / 2.0; - double sinAng = Math.sin(angle1); - double cosAng = Math.cos(angle1); - double renderX = baseX + radiusInput * sinAng; - double renderY = baseY + radiusInput * cosAng; - - GlStateManager.pushMatrix(); - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.rotate((float) angle2, 0.0f, 0.0f, 1.0f); - GlStateManager.scale(1.0f, 1.0f, 1.0f); - - int arrowInput = (int) arrow.getInput(); - - if (arrowInput == 0) { - if (color == -1) { - GL11.glColor3d(1.0, 1.0, 1.0); - } - else { - GL11.glColor3d(colorForStack.getRed(), colorForStack.getGreen(), colorForStack.getBlue()); - } - - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_LINE_SMOOTH); - - double halfAngle = 0.6108652353286743; - double size = 9.0; - double offsetY = 5.0; - GL11.glLineWidth(3.0f); - GL11.glBegin(GL11.GL_LINE_STRIP); - GL11.glVertex2d(Math.sin(-halfAngle) * size, Math.cos(-halfAngle) * size - offsetY); - GL11.glVertex2d(0.0, -offsetY); - GL11.glVertex2d(Math.sin(halfAngle) * size, Math.cos(halfAngle) * size - offsetY); - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - } - else if (arrowInput == 1) { - GlStateManager.rotate(-90.0f, 0.0f, 0.0f, 1.0f); - GlStateManager.scale(1.5, 1.5, 1.5); - mc.fontRendererObj.drawString(">", -2.0f, -4.0f, color, false); - } - else if (arrowInput == 2) { - RenderUtils.draw2DPolygon(0.0, 0.0, 5.0, 3, Utils.mergeAlpha(color, 255)); - } - - GlStateManager.popMatrix(); - - renderX = baseX + (radiusInput - 13.0) * sinAng; - renderY = baseY + (radiusInput - 13.0) * cosAng; - - GlStateManager.pushMatrix(); - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.scale(0.8, 0.8, 0.8); - - if (renderDistance.isToggled()) { - String text = (int) mc.thePlayer.getDistanceToEntity(en) + "m"; - mc.fontRendererObj.drawString(text, (float) (-mc.fontRendererObj.getStringWidth(text) / 2), -4.0f, -1, true); - } - - GlStateManager.popMatrix(); - - if (renderItem.isToggled() && itemStack != null) { - GlStateManager.pushMatrix(); - if (itemStack.getItem() == Items.arrow) { - renderX = baseX + (radiusInput - 26.0) * sinAng; - renderY = baseY + (radiusInput - 26.0) * cosAng; - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.scale(1.0f, 1.0f, 1.0f); - GlStateManager.rotate((float) angle2 - 45.0f, 0.0f, 0.0f, 1.0f); - mc.getRenderItem().renderItemIntoGUI(itemStack, -12, -4); - } - else { - renderX = baseX + (radiusInput - 29.0) * sinAng; - renderY = baseY + (radiusInput - 29.0) * cosAng; - GlStateManager.translate(renderX, renderY, 0.0); - GlStateManager.scale(1.0f, 1.0f, 1.0f); - mc.getRenderItem().renderItemIntoGUI(itemStack, -8, -9); - } - GlStateManager.popMatrix(); - } - } - } - - private Color getColorForItem(ItemStack itemStack) { - if (itemStack == null) { - return Color.WHITE; - } - if (itemStack.getItem() == Items.ender_pearl) { - return new Color(210, 0, 255); - } - else if (itemStack.getItem() == Items.fire_charge) { - return new Color(255, 150, 0); - } - else if (itemStack.getItem() == Items.egg) { - return new Color(255, 238, 154); - } - else { - return Color.WHITE; - } - } - - private boolean shouldRender(Entity en, ItemStack stack) { - if (threatsOnly.isToggled() && stack != null && stack.getItem() == Items.fire_charge) { - double x = en.posX; - double y = en.posY; - double z = en.posZ; - final double dx = x - en.lastTickPosX; - final double dy = y - en.lastTickPosY; - final double dz = z - en.lastTickPosZ; - if (dx != 0.0 || dy != 0.0 || dz != 0.0) { - for (int i = 0; i < 400.0; ++i) { - final double dist = mc.thePlayer.getDistanceSq(x, y, z); - if (dist <= 36) { - return true; - } - final Block block = BlockUtils.getBlock(new BlockPos(x, y, z)); - if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid) && !(block instanceof BlockFire)) { - break; - } - x += dx * 0.5; - y += dy * 0.5; - z += dz * 0.5; - } - } - return false; - } - return true; - } +package keystrokesmod.module.impl.render; + +import keystrokesmod.mixin.impl.accessor.IAccessorEntityArrow; +import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.GroupSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockFire; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.projectile.*; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.HashSet; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class Indicators extends Module { + private GroupSetting items; + private ButtonSetting renderArrows; + private ButtonSetting renderPearls; + private ButtonSetting renderFireballs; + private ButtonSetting renderEggs; + private ButtonSetting renderSnowballs; + + private SliderSetting arrow; + private SliderSetting radius; + private ButtonSetting itemColors; + private ButtonSetting renderItem; + private ButtonSetting renderDistance; + private ButtonSetting threatsOnly; + private ButtonSetting renderOnlyOffScreen; + + private HashSet threats = new HashSet<>(); + private Map lastHeldItems = new ConcurrentHashMap<>(); + + private String[] arrowTypes = new String[] { "Caret", "Greater than", "Triangle" }; + + public Indicators() { + super("Indicators", category.render); + this.registerSetting(items = new GroupSetting("Items")); + this.registerSetting(renderArrows = new ButtonSetting(items, "Render arrows", true)); + this.registerSetting(renderPearls = new ButtonSetting(items, "Render ender pearls", true)); + this.registerSetting(renderFireballs = new ButtonSetting(items, "Render fireballs", true)); + this.registerSetting(renderEggs = new ButtonSetting(items, "Render eggs", false)); + this.registerSetting(renderSnowballs = new ButtonSetting(items, "Render snowballs", false)); + this.registerSetting(arrow = new SliderSetting("Arrow", 0, arrowTypes)); + this.registerSetting(radius = new SliderSetting("Circle radius", 50, 30, 200, 5)); + this.registerSetting(itemColors = new ButtonSetting("Item colors", true)); + this.registerSetting(renderItem = new ButtonSetting("Render item", true)); + this.registerSetting(renderDistance = new ButtonSetting("Render distance", true)); + this.registerSetting(threatsOnly = new ButtonSetting("Render only threats", true)); + this.registerSetting(renderOnlyOffScreen = new ButtonSetting("Render only offscreen", false)); + } + + public void onDisable() { + this.threats.clear(); + this.lastHeldItems.clear(); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + if (event.phase != TickEvent.Phase.END) { + return; + } + if (mc.currentScreen != null || !Utils.nullCheck()) { + return; + } + try { + for (Entity en : mc.theWorld.loadedEntityList) { + if (en == null || en == mc.thePlayer) { + continue; + } + ItemStack itemStack = null; + if (en instanceof EntityArrow) { + if (((IAccessorEntityArrow) en).getInGround()) { + threats.remove(en); + continue; + } + itemStack = new ItemStack(Items.arrow); + } + else if (en instanceof EntityFireball) { + itemStack = new ItemStack(Items.fire_charge); + } + else if (en instanceof EntityEnderPearl) { + itemStack = new ItemStack(Items.ender_pearl); + } + else if (en instanceof EntityEgg) { + itemStack = new ItemStack(Items.egg); + } + else if (en instanceof EntitySnowball) { + itemStack = new ItemStack(Items.snowball); + } + if (!threats.contains(en)) { + continue; + } + if (!mc.theWorld.loadedEntityList.contains(en) || !canRender(en)) { + threats.remove(en); + continue; + } + this.renderIndicatorFor(en, itemStack, event.renderTickTime); + } + } + catch (Exception e) {} + } + + @SubscribeEvent + public void onEntityJoin(EntityJoinWorldEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.entity == mc.thePlayer) { + this.threats.clear(); + } + else if (canRender(e.entity) && (mc.thePlayer.getDistanceSqToEntity(e.entity) > 36 || !threatsOnly.isToggled())) { + this.threats.add(e.entity); + } + } + + private boolean canRender(Entity entity) { + if (entity instanceof EntityArrow && !((IAccessorEntityArrow) entity).getInGround() && renderArrows.isToggled()) { + return true; + } + else if (entity instanceof EntityLargeFireball && renderFireballs.isToggled()) { + return true; + } + else if (entity instanceof EntityEnderPearl && renderPearls.isToggled()) { + return true; + } + else if (entity instanceof EntityEgg && renderEggs.isToggled()) { + return true; + } + else if (entity instanceof EntitySnowball && renderSnowballs.isToggled()) { + return true; + } + return false; + } + + private void renderIndicatorFor(Entity en, ItemStack itemStack, float partialTicks) { + if (!this.canRender(en)) { + return; + } + if (!this.shouldRender(en, itemStack)) { + return; + } + if (renderOnlyOffScreen.isToggled() && RenderUtils.isInViewFrustum(en)) { + return; + } + Color colorForStack = getColorForItem(itemStack); + int color = itemColors.isToggled() ? colorForStack.getRGB() : -1; + + double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; + double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY + en.height / 2; + double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; + + ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); + + ScaledResolution scaledResolution = new ScaledResolution(mc); + Vec3 vec = RenderUtils.convertTo2D(scaledResolution.getScaleFactor(), x, y, z); + + if (vec != null) { + mc.entityRenderer.setupOverlayRendering(); + ScaledResolution res = new ScaledResolution(mc); + + double dx = vec.xCoord - res.getScaledWidth() / 2.0; + double dy = vec.yCoord - res.getScaledHeight() / 2.0; + boolean inFrustum = vec.zCoord < 1.0003684; + + if (!inFrustum) { + dx *= -1.0; + dy *= -1.0; + } + + double angle1 = Math.atan2(dx, dy); + double angle2 = Math.atan2(dy, dx) * 57.295780181884766 + 90.0; + double hypotenuse = Math.hypot(dx, dy); + double radiusInput = radius.getInput(); + + if (renderItem.isToggled()) { + radiusInput += 20.0; + } + + if (inFrustum && hypotenuse < radiusInput + 15.0) { + return; + } + + double baseX = res.getScaledWidth() / 2.0; + double baseY = res.getScaledHeight() / 2.0; + double sinAng = Math.sin(angle1); + double cosAng = Math.cos(angle1); + double renderX = baseX + radiusInput * sinAng; + double renderY = baseY + radiusInput * cosAng; + + GlStateManager.pushMatrix(); + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.rotate((float) angle2, 0.0f, 0.0f, 1.0f); + GlStateManager.scale(1.0f, 1.0f, 1.0f); + + int arrowInput = (int) arrow.getInput(); + + if (arrowInput == 0) { + if (color == -1) { + GL11.glColor3d(1.0, 1.0, 1.0); + } + else { + GL11.glColor3d(colorForStack.getRed(), colorForStack.getGreen(), colorForStack.getBlue()); + } + + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + + double halfAngle = 0.6108652353286743; + double size = 9.0; + double offsetY = 5.0; + GL11.glLineWidth(3.0f); + GL11.glBegin(GL11.GL_LINE_STRIP); + GL11.glVertex2d(Math.sin(-halfAngle) * size, Math.cos(-halfAngle) * size - offsetY); + GL11.glVertex2d(0.0, -offsetY); + GL11.glVertex2d(Math.sin(halfAngle) * size, Math.cos(halfAngle) * size - offsetY); + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + } + else if (arrowInput == 1) { + GlStateManager.rotate(-90.0f, 0.0f, 0.0f, 1.0f); + GlStateManager.scale(1.5, 1.5, 1.5); + mc.fontRendererObj.drawString(">", -2.0f, -4.0f, color, false); + } + else if (arrowInput == 2) { + RenderUtils.draw2DPolygon(0.0, 0.0, 5.0, 3, Utils.mergeAlpha(color, 255)); + } + + GlStateManager.popMatrix(); + + renderX = baseX + (radiusInput - 13.0) * sinAng; + renderY = baseY + (radiusInput - 13.0) * cosAng; + + GlStateManager.pushMatrix(); + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.scale(0.8, 0.8, 0.8); + + if (renderDistance.isToggled()) { + String text = (int) mc.thePlayer.getDistanceToEntity(en) + "m"; + mc.fontRendererObj.drawString(text, (float) (-mc.fontRendererObj.getStringWidth(text) / 2), -4.0f, -1, true); + } + + GlStateManager.popMatrix(); + + if (renderItem.isToggled() && itemStack != null) { + GlStateManager.pushMatrix(); + if (itemStack.getItem() == Items.arrow) { + renderX = baseX + (radiusInput - 26.0) * sinAng; + renderY = baseY + (radiusInput - 26.0) * cosAng; + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.scale(1.0f, 1.0f, 1.0f); + GlStateManager.rotate((float) angle2 - 45.0f, 0.0f, 0.0f, 1.0f); + mc.getRenderItem().renderItemIntoGUI(itemStack, -12, -4); + } + else { + renderX = baseX + (radiusInput - 29.0) * sinAng; + renderY = baseY + (radiusInput - 29.0) * cosAng; + GlStateManager.translate(renderX, renderY, 0.0); + GlStateManager.scale(1.0f, 1.0f, 1.0f); + mc.getRenderItem().renderItemIntoGUI(itemStack, -8, -9); + } + GlStateManager.popMatrix(); + } + } + } + + private Color getColorForItem(ItemStack itemStack) { + if (itemStack == null) { + return Color.WHITE; + } + if (itemStack.getItem() == Items.ender_pearl) { + return new Color(210, 0, 255); + } + else if (itemStack.getItem() == Items.fire_charge) { + return new Color(255, 150, 0); + } + else if (itemStack.getItem() == Items.egg) { + return new Color(255, 238, 154); + } + else { + return Color.WHITE; + } + } + + private boolean shouldRender(Entity en, ItemStack stack) { + if (threatsOnly.isToggled() && stack != null && stack.getItem() == Items.fire_charge) { + double x = en.posX; + double y = en.posY; + double z = en.posZ; + final double dx = x - en.lastTickPosX; + final double dy = y - en.lastTickPosY; + final double dz = z - en.lastTickPosZ; + if (dx != 0.0 || dy != 0.0 || dz != 0.0) { + for (int i = 0; i < 400.0; ++i) { + final double dist = mc.thePlayer.getDistanceSq(x, y, z); + if (dist <= 36) { + return true; + } + final Block block = BlockUtils.getBlock(new BlockPos(x, y, z)); + if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid) && !(block instanceof BlockFire)) { + break; + } + x += dx * 0.5; + y += dy * 0.5; + z += dz * 0.5; + } + } + return false; + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/ItemESP.java b/src/main/java/keystrokesmod/module/impl/render/ItemESP.java index bdd8fea..63e2e1a 100644 --- a/src/main/java/keystrokesmod/module/impl/render/ItemESP.java +++ b/src/main/java/keystrokesmod/module/impl/render/ItemESP.java @@ -1,186 +1,186 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.player.Freecam; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.RenderUtils; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public class ItemESP extends Module { - private final ButtonSetting renderIron; - private final ButtonSetting renderGold; - - public ItemESP() { - super("ItemESP", category.render); - this.registerSetting(renderIron = new ButtonSetting("Render iron", true)); - this.registerSetting(renderGold = new ButtonSetting("Render gold", true)); - } - - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent e) { - HashMap> itemsMap = new HashMap<>(); - HashMap colorMap = new HashMap<>(); - - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity instanceof EntityItem) { - if (entity.ticksExisted < 3) { - continue; - } - EntityItem entityItem = (EntityItem) entity; - if (entityItem.getEntityItem().stackSize == 0) { - continue; - } - Item currentItem = entityItem.getEntityItem().getItem(); - if (currentItem == null) { - continue; - } - - int stackSize = entityItem.getEntityItem().stackSize; - double colorDouble = getColorForItem(currentItem, entity.posX, entity.posY, entity.posZ); - - Integer existingStackCount = colorMap.get(colorDouble); - int newStackCount; - if (existingStackCount == null) { - newStackCount = stackSize; - ArrayList itemList = itemsMap.get(currentItem); - if (itemList == null) { - itemList = new ArrayList<>(); - } - itemList.add(entityItem); - itemsMap.put(currentItem, itemList); - } - else { - newStackCount = existingStackCount + stackSize; - } - colorMap.put(colorDouble, newStackCount); - } - } - if (!itemsMap.isEmpty()) { - float renderPartialTicks = ((IAccessorMinecraft) mc).getTimer().renderPartialTicks; - for (Map.Entry> entry : itemsMap.entrySet()) { - Item item = entry.getKey(); - int boxColor; - int textColor; - if (item == Items.iron_ingot && renderIron.isToggled()) { - textColor = (boxColor = -1); - } - else if (item == Items.gold_ingot && renderGold.isToggled()) { - boxColor = -331703; - textColor = -152; - } - else if (item == Items.diamond) { - boxColor = -10362113; - textColor = -7667713; - } - else { - if (item != Items.emerald) { - continue; - } - boxColor = -15216030; - textColor = -14614644; - } - - for (EntityItem entityItem2 : entry.getValue()) { - double itemColor = getColorForItem(item, entityItem2.posX, entityItem2.posY, entityItem2.posZ); - double interpolatedX = entityItem2.lastTickPosX + (entityItem2.posX - entityItem2.lastTickPosX) * renderPartialTicks; - double interpolatedY = entityItem2.lastTickPosY + (entityItem2.posY - entityItem2.lastTickPosY) * renderPartialTicks; - double interpolatedZ = entityItem2.lastTickPosZ + (entityItem2.posZ - entityItem2.lastTickPosZ) * renderPartialTicks; - - EntityPlayer self = (Freecam.freeEntity == null) ? mc.thePlayer : Freecam.freeEntity; - double diffX = self.lastTickPosX + (self.posX - self.lastTickPosX) * renderPartialTicks - interpolatedX; - double diffY = self.lastTickPosY + (self.posY - self.lastTickPosY) * renderPartialTicks - interpolatedY; - double diffZ = self.lastTickPosZ + (self.posZ - self.lastTickPosZ) * renderPartialTicks - interpolatedZ; - - double dist = MathHelper.sqrt_double(diffX * diffX + diffY * diffY + diffZ * diffZ); - - GlStateManager.pushMatrix(); - drawBox(boxColor, textColor, colorMap.get(itemColor), interpolatedX, interpolatedY, interpolatedZ, dist); - GlStateManager.popMatrix(); - } - } - } - } - - public double getColor(double x, double y, double z) { - if (x == 0.0) { - x = 1.0; - } - if (y == 0.0) { - y = 1.0; - } - if (z == 0.0) { - z = 1.0; - } - return Math.round((x + 1.0) * Math.floor(y) * (z + 2.0)); - } - - private double getColorForItem(Item item, double x, double y, double z) { - double color = getColor(x, y, z); - if (item == Items.iron_ingot) { - color += 0.155; - } - else if (item == Items.gold_ingot) { - color += 0.255; - } - else if (item == Items.diamond) { - color += 0.355; - } - else if (item == Items.emerald) { - color += 0.455; - } - return color; - } - - public void drawBox(int boxColor, int textColor, int size, double posY, double posX, double posZ, double dist) { - posY -= mc.getRenderManager().viewerPosX; - posX -= mc.getRenderManager().viewerPosY; - posZ -= mc.getRenderManager().viewerPosZ; - GL11.glPushMatrix(); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_BLEND); - GL11.glLineWidth(2.0f); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(false); - float r = (boxColor >> 16 & 0xFF) / 255.0f; - float g = (boxColor >> 8 & 0xFF) / 255.0f; - float b = (boxColor & 0xFF) / 255.0f; - - float radius = Math.min(Math.max(0.2f, (float) (0.009999999776482582 * dist)), 0.4f); - RenderUtils.drawBoundingBox(new AxisAlignedBB(posY - radius, posX, posZ - radius, posY + radius, posX + radius * 2.0f, posZ + radius), r, g, b, 0.35f); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - GlStateManager.pushMatrix(); - GlStateManager.translate((float) posY, (float) posX + 0.3, (float) posZ); - GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate((mc.gameSettings.thirdPersonView == 2 ? -1 : 1) * mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); - float scale = Math.min(Math.max(0.02266667f, (float) (0.001500000013038516 * dist)), 0.07f); - GlStateManager.scale(-scale, -scale, -scale); - GlStateManager.depthMask(false); - GlStateManager.disableDepth(); - String value = String.valueOf(size); - mc.fontRendererObj.drawString(value, -(mc.fontRendererObj.getStringWidth(value) / 2) + scale * 3.5f, -(123.805f * scale - 2.47494f), textColor, true); - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.popMatrix(); - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.player.Freecam; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.RenderUtils; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class ItemESP extends Module { + private final ButtonSetting renderIron; + private final ButtonSetting renderGold; + + public ItemESP() { + super("ItemESP", category.render); + this.registerSetting(renderIron = new ButtonSetting("Render iron", true)); + this.registerSetting(renderGold = new ButtonSetting("Render gold", true)); + } + + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent e) { + HashMap> itemsMap = new HashMap<>(); + HashMap colorMap = new HashMap<>(); + + for (Entity entity : mc.theWorld.loadedEntityList) { + if (entity instanceof EntityItem) { + if (entity.ticksExisted < 3) { + continue; + } + EntityItem entityItem = (EntityItem) entity; + if (entityItem.getEntityItem().stackSize == 0) { + continue; + } + Item currentItem = entityItem.getEntityItem().getItem(); + if (currentItem == null) { + continue; + } + + int stackSize = entityItem.getEntityItem().stackSize; + double colorDouble = getColorForItem(currentItem, entity.posX, entity.posY, entity.posZ); + + Integer existingStackCount = colorMap.get(colorDouble); + int newStackCount; + if (existingStackCount == null) { + newStackCount = stackSize; + ArrayList itemList = itemsMap.get(currentItem); + if (itemList == null) { + itemList = new ArrayList<>(); + } + itemList.add(entityItem); + itemsMap.put(currentItem, itemList); + } + else { + newStackCount = existingStackCount + stackSize; + } + colorMap.put(colorDouble, newStackCount); + } + } + if (!itemsMap.isEmpty()) { + float renderPartialTicks = ((IAccessorMinecraft) mc).getTimer().renderPartialTicks; + for (Map.Entry> entry : itemsMap.entrySet()) { + Item item = entry.getKey(); + int boxColor; + int textColor; + if (item == Items.iron_ingot && renderIron.isToggled()) { + textColor = (boxColor = -1); + } + else if (item == Items.gold_ingot && renderGold.isToggled()) { + boxColor = -331703; + textColor = -152; + } + else if (item == Items.diamond) { + boxColor = -10362113; + textColor = -7667713; + } + else { + if (item != Items.emerald) { + continue; + } + boxColor = -15216030; + textColor = -14614644; + } + + for (EntityItem entityItem2 : entry.getValue()) { + double itemColor = getColorForItem(item, entityItem2.posX, entityItem2.posY, entityItem2.posZ); + double interpolatedX = entityItem2.lastTickPosX + (entityItem2.posX - entityItem2.lastTickPosX) * renderPartialTicks; + double interpolatedY = entityItem2.lastTickPosY + (entityItem2.posY - entityItem2.lastTickPosY) * renderPartialTicks; + double interpolatedZ = entityItem2.lastTickPosZ + (entityItem2.posZ - entityItem2.lastTickPosZ) * renderPartialTicks; + + EntityPlayer self = (Freecam.freeEntity == null) ? mc.thePlayer : Freecam.freeEntity; + double diffX = self.lastTickPosX + (self.posX - self.lastTickPosX) * renderPartialTicks - interpolatedX; + double diffY = self.lastTickPosY + (self.posY - self.lastTickPosY) * renderPartialTicks - interpolatedY; + double diffZ = self.lastTickPosZ + (self.posZ - self.lastTickPosZ) * renderPartialTicks - interpolatedZ; + + double dist = MathHelper.sqrt_double(diffX * diffX + diffY * diffY + diffZ * diffZ); + + GlStateManager.pushMatrix(); + drawBox(boxColor, textColor, colorMap.get(itemColor), interpolatedX, interpolatedY, interpolatedZ, dist); + GlStateManager.popMatrix(); + } + } + } + } + + public double getColor(double x, double y, double z) { + if (x == 0.0) { + x = 1.0; + } + if (y == 0.0) { + y = 1.0; + } + if (z == 0.0) { + z = 1.0; + } + return Math.round((x + 1.0) * Math.floor(y) * (z + 2.0)); + } + + private double getColorForItem(Item item, double x, double y, double z) { + double color = getColor(x, y, z); + if (item == Items.iron_ingot) { + color += 0.155; + } + else if (item == Items.gold_ingot) { + color += 0.255; + } + else if (item == Items.diamond) { + color += 0.355; + } + else if (item == Items.emerald) { + color += 0.455; + } + return color; + } + + public void drawBox(int boxColor, int textColor, int size, double posY, double posX, double posZ, double dist) { + posY -= mc.getRenderManager().viewerPosX; + posX -= mc.getRenderManager().viewerPosY; + posZ -= mc.getRenderManager().viewerPosZ; + GL11.glPushMatrix(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_BLEND); + GL11.glLineWidth(2.0f); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + float r = (boxColor >> 16 & 0xFF) / 255.0f; + float g = (boxColor >> 8 & 0xFF) / 255.0f; + float b = (boxColor & 0xFF) / 255.0f; + + float radius = Math.min(Math.max(0.2f, (float) (0.009999999776482582 * dist)), 0.4f); + RenderUtils.drawBoundingBox(new AxisAlignedBB(posY - radius, posX, posZ - radius, posY + radius, posX + radius * 2.0f, posZ + radius), r, g, b, 0.35f); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + GlStateManager.pushMatrix(); + GlStateManager.translate((float) posY, (float) posX + 0.3, (float) posZ); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0f, 1.0f, 0.0f); + GlStateManager.rotate((mc.gameSettings.thirdPersonView == 2 ? -1 : 1) * mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); + float scale = Math.min(Math.max(0.02266667f, (float) (0.001500000013038516 * dist)), 0.07f); + GlStateManager.scale(-scale, -scale, -scale); + GlStateManager.depthMask(false); + GlStateManager.disableDepth(); + String value = String.valueOf(size); + mc.fontRendererObj.drawString(value, -(mc.fontRendererObj.getStringWidth(value) / 2) + scale * 3.5f, -(123.805f * scale - 2.47494f), textColor, true); + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.popMatrix(); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/MobESP.java b/src/main/java/keystrokesmod/module/impl/render/MobESP.java index 616f001..8d94b70 100644 --- a/src/main/java/keystrokesmod/module/impl/render/MobESP.java +++ b/src/main/java/keystrokesmod/module/impl/render/MobESP.java @@ -1,121 +1,121 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.*; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.HashMap; -import java.util.Map; - -public class MobESP extends Module { - private ButtonSetting healthBar; - private ButtonSetting shaded; - private ButtonSetting blaze, creeper, enderman, ghast, silverfish, skeleton, slime, spider, zombie, zombiePigman; - - private final Map, MobSetting> mobRenders = new HashMap<>(); - - public MobESP() { - super("MobESP", category.render); - this.registerSetting(healthBar = new ButtonSetting("Health bar", false)); - this.registerSetting(shaded = new ButtonSetting("Shaded", false)); - this.registerSetting(blaze = new ButtonSetting("Blaze §6Orange", true)); - this.registerSetting(creeper = new ButtonSetting("Creeper §aGreen", true)); - this.registerSetting(enderman = new ButtonSetting("Enderman §7Black", true)); - this.registerSetting(ghast = new ButtonSetting("Ghast §fWhite", true)); - this.registerSetting(silverfish = new ButtonSetting("Silverfish §7Gray", true)); - this.registerSetting(skeleton = new ButtonSetting("Skeleton §fWhite", true)); - this.registerSetting(slime = new ButtonSetting("Slime §aGreen", true)); - this.registerSetting(spider = new ButtonSetting("Spider §7Black", true)); - this.registerSetting(zombie = new ButtonSetting("Zombie §1Blue", true)); - this.registerSetting(zombiePigman = new ButtonSetting("Zombie Pigman §dPink", true)); - - mobRenders.put(EntityBlaze.class, new MobSetting(blaze, Color.orange.getRGB(), 69.0D)); - mobRenders.put(EntityCreeper.class, new MobSetting(creeper, Color.green.getRGB(), 69.0D)); - mobRenders.put(EntityEnderman.class, new MobSetting(enderman, Color.black.getRGB(), 106.0D)); - mobRenders.put(EntityGhast.class, new MobSetting(ghast, Color.white.getRGB(), 143.0D)); - mobRenders.put(EntitySilverfish.class, new MobSetting(silverfish, Color.gray.getRGB(), 20.0D)); - mobRenders.put(EntitySkeleton.class, new MobSetting(skeleton, Color.white.getRGB(), 69.0D)); - mobRenders.put(EntitySlime.class, new MobSetting(slime, Color.green.getRGB())); - mobRenders.put(EntitySpider.class, new MobSetting(spider, Color.black.getRGB(), 40.0D)); - mobRenders.put(EntityCaveSpider.class, new MobSetting(spider, Color.black.getRGB(), 26.0D)); - mobRenders.put(EntityZombie.class, new MobSetting(zombie, Color.blue.getRGB())); - mobRenders.put(EntityPigZombie.class, new MobSetting(zombiePigman, Color.pink.getRGB())); - } - - private void renderMob(EntityLivingBase entity, double height, int rgb, float partialTicks) { - if (shaded.isToggled()) { - RenderUtils.renderEntity(entity, 2, 0.0, 0.0, rgb, false); - } - if (healthBar.isToggled()) { - drawHealthBar(entity, height, partialTicks); - } - } - - private void renderEntity(EntityLivingBase entity, float partialTicks) { - MobSetting mobSetting = mobRenders.get(entity.getClass()); - if (mobSetting != null && mobSetting.setting.isToggled()) { - renderMob(entity, mobSetting.height, mobSetting.color, partialTicks); - } - } - - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent e) { - if (!Utils.nullCheck()) { - return; - } - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity instanceof EntityLivingBase && entity != mc.thePlayer) { - if (((EntityLivingBase) entity).deathTime != 0) { - continue; - } - renderEntity((EntityLivingBase) entity, e.partialTicks); - } - } - } - - private void drawHealthBar(EntityLivingBase en, double mobHeight, float partialTicks) { - double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * (double) partialTicks - mc.getRenderManager().viewerPosX; - double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * (double) partialTicks - mc.getRenderManager().viewerPosY; - double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * (double) partialTicks - mc.getRenderManager().viewerPosZ; - GlStateManager.pushMatrix(); - int xOffset = 21; - double health = en.getHealth() / en.getMaxHealth(); - int height = (int) (mobHeight * health); - int healthColor = health < 0.3D ? Color.red.getRGB() : (health < 0.5D ? Color.orange.getRGB() : (health < 0.7D ? Color.yellow.getRGB() : Color.green.getRGB())); - GL11.glTranslated(x, y - 0.2D, z); - GL11.glRotated(-mc.getRenderManager().playerViewY, 0.0D, 1.0D, 0.0D); - GlStateManager.disableDepth(); - GL11.glScalef(0.03F, 0.03F, 0.03F); - net.minecraft.client.gui.Gui.drawRect(xOffset, -1, xOffset + 4, (int) (mobHeight + 1), Color.black.getRGB()); - net.minecraft.client.gui.Gui.drawRect(xOffset + 1, height, xOffset + 3, (int) mobHeight, Color.darkGray.getRGB()); - net.minecraft.client.gui.Gui.drawRect(xOffset + 1, 0, xOffset + 3, height, healthColor); - GlStateManager.enableDepth(); - GlStateManager.popMatrix(); - } - - private static class MobSetting { - ButtonSetting setting; - int color; - double height = 74.0D; - - public MobSetting(ButtonSetting setting, int color) { - this.setting = setting; - this.color = color; - } - - public MobSetting(ButtonSetting setting, int color, double height) { - this.setting = setting; - this.color = color; - this.height = height; - } - } +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.*; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class MobESP extends Module { + private ButtonSetting healthBar; + private ButtonSetting shaded; + private ButtonSetting blaze, creeper, enderman, ghast, silverfish, skeleton, slime, spider, zombie, zombiePigman; + + private final Map, MobSetting> mobRenders = new HashMap<>(); + + public MobESP() { + super("MobESP", category.render); + this.registerSetting(healthBar = new ButtonSetting("Health bar", false)); + this.registerSetting(shaded = new ButtonSetting("Shaded", false)); + this.registerSetting(blaze = new ButtonSetting("Blaze §6Orange", true)); + this.registerSetting(creeper = new ButtonSetting("Creeper §aGreen", true)); + this.registerSetting(enderman = new ButtonSetting("Enderman §7Black", true)); + this.registerSetting(ghast = new ButtonSetting("Ghast §fWhite", true)); + this.registerSetting(silverfish = new ButtonSetting("Silverfish §7Gray", true)); + this.registerSetting(skeleton = new ButtonSetting("Skeleton §fWhite", true)); + this.registerSetting(slime = new ButtonSetting("Slime §aGreen", true)); + this.registerSetting(spider = new ButtonSetting("Spider §7Black", true)); + this.registerSetting(zombie = new ButtonSetting("Zombie §1Blue", true)); + this.registerSetting(zombiePigman = new ButtonSetting("Zombie Pigman §dPink", true)); + + mobRenders.put(EntityBlaze.class, new MobSetting(blaze, Color.orange.getRGB(), 69.0D)); + mobRenders.put(EntityCreeper.class, new MobSetting(creeper, Color.green.getRGB(), 69.0D)); + mobRenders.put(EntityEnderman.class, new MobSetting(enderman, Color.black.getRGB(), 106.0D)); + mobRenders.put(EntityGhast.class, new MobSetting(ghast, Color.white.getRGB(), 143.0D)); + mobRenders.put(EntitySilverfish.class, new MobSetting(silverfish, Color.gray.getRGB(), 20.0D)); + mobRenders.put(EntitySkeleton.class, new MobSetting(skeleton, Color.white.getRGB(), 69.0D)); + mobRenders.put(EntitySlime.class, new MobSetting(slime, Color.green.getRGB())); + mobRenders.put(EntitySpider.class, new MobSetting(spider, Color.black.getRGB(), 40.0D)); + mobRenders.put(EntityCaveSpider.class, new MobSetting(spider, Color.black.getRGB(), 26.0D)); + mobRenders.put(EntityZombie.class, new MobSetting(zombie, Color.blue.getRGB())); + mobRenders.put(EntityPigZombie.class, new MobSetting(zombiePigman, Color.pink.getRGB())); + } + + private void renderMob(EntityLivingBase entity, double height, int rgb, float partialTicks) { + if (shaded.isToggled()) { + RenderUtils.renderEntity(entity, 2, 0.0, 0.0, rgb, false); + } + if (healthBar.isToggled()) { + drawHealthBar(entity, height, partialTicks); + } + } + + private void renderEntity(EntityLivingBase entity, float partialTicks) { + MobSetting mobSetting = mobRenders.get(entity.getClass()); + if (mobSetting != null && mobSetting.setting.isToggled()) { + renderMob(entity, mobSetting.height, mobSetting.color, partialTicks); + } + } + + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent e) { + if (!Utils.nullCheck()) { + return; + } + for (Entity entity : mc.theWorld.loadedEntityList) { + if (entity instanceof EntityLivingBase && entity != mc.thePlayer) { + if (((EntityLivingBase) entity).deathTime != 0) { + continue; + } + renderEntity((EntityLivingBase) entity, e.partialTicks); + } + } + } + + private void drawHealthBar(EntityLivingBase en, double mobHeight, float partialTicks) { + double x = en.lastTickPosX + (en.posX - en.lastTickPosX) * (double) partialTicks - mc.getRenderManager().viewerPosX; + double y = en.lastTickPosY + (en.posY - en.lastTickPosY) * (double) partialTicks - mc.getRenderManager().viewerPosY; + double z = en.lastTickPosZ + (en.posZ - en.lastTickPosZ) * (double) partialTicks - mc.getRenderManager().viewerPosZ; + GlStateManager.pushMatrix(); + int xOffset = 21; + double health = en.getHealth() / en.getMaxHealth(); + int height = (int) (mobHeight * health); + int healthColor = health < 0.3D ? Color.red.getRGB() : (health < 0.5D ? Color.orange.getRGB() : (health < 0.7D ? Color.yellow.getRGB() : Color.green.getRGB())); + GL11.glTranslated(x, y - 0.2D, z); + GL11.glRotated(-mc.getRenderManager().playerViewY, 0.0D, 1.0D, 0.0D); + GlStateManager.disableDepth(); + GL11.glScalef(0.03F, 0.03F, 0.03F); + net.minecraft.client.gui.Gui.drawRect(xOffset, -1, xOffset + 4, (int) (mobHeight + 1), Color.black.getRGB()); + net.minecraft.client.gui.Gui.drawRect(xOffset + 1, height, xOffset + 3, (int) mobHeight, Color.darkGray.getRGB()); + net.minecraft.client.gui.Gui.drawRect(xOffset + 1, 0, xOffset + 3, height, healthColor); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); + } + + private static class MobSetting { + ButtonSetting setting; + int color; + double height = 74.0D; + + public MobSetting(ButtonSetting setting, int color) { + this.setting = setting; + this.color = color; + } + + public MobSetting(ButtonSetting setting, int color, double height) { + this.setting = setting; + this.color = color; + this.height = height; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/NoCameraClip.java b/src/main/java/keystrokesmod/module/impl/render/NoCameraClip.java index f2130b0..560df22 100644 --- a/src/main/java/keystrokesmod/module/impl/render/NoCameraClip.java +++ b/src/main/java/keystrokesmod/module/impl/render/NoCameraClip.java @@ -1,9 +1,9 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; - -public class NoCameraClip extends Module { - public NoCameraClip() { - super("NoCameraClip", category.render); - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; + +public class NoCameraClip extends Module { + public NoCameraClip() { + super("NoCameraClip", category.render); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/NoHurtCam.java b/src/main/java/keystrokesmod/module/impl/render/NoHurtCam.java index 76419e1..4064c8d 100644 --- a/src/main/java/keystrokesmod/module/impl/render/NoHurtCam.java +++ b/src/main/java/keystrokesmod/module/impl/render/NoHurtCam.java @@ -1,14 +1,14 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; - -public class NoHurtCam extends Module { - public SliderSetting multiplier; - public NoHurtCam() { - super("NoHurtCam", category.render); - this.registerSetting(new DescriptionSetting("Default is 14x multiplier.")); - this.registerSetting(multiplier = new SliderSetting("Multiplier", 14, -40, 40, 1)); - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; + +public class NoHurtCam extends Module { + public SliderSetting multiplier; + public NoHurtCam() { + super("NoHurtCam", category.render); + this.registerSetting(new DescriptionSetting("Default is 14x multiplier.")); + this.registerSetting(multiplier = new SliderSetting("Multiplier", 14, -40, 40, 1)); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/Radar.java b/src/main/java/keystrokesmod/module/impl/render/Radar.java index 999b226..be336aa 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Radar.java +++ b/src/main/java/keystrokesmod/module/impl/render/Radar.java @@ -1,96 +1,96 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.clickgui.ClickGui; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class Radar extends Module { - private ButtonSetting tracerLines; - private int scale = 2; - private int rectColor = new Color(0, 0, 0, 125).getRGB(); - public Radar() { - super("Radar", category.render); - this.registerSetting(tracerLines = new ButtonSetting("Show tracer lines", false)); - } - - public void onUpdate() { - this.scale = new ScaledResolution(mc).getScaleFactor(); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent e) { - if (e.phase != TickEvent.Phase.END || !Utils.nullCheck()) { - return; - } - if (mc.currentScreen instanceof ClickGui) { - return; - } - if (mc.currentScreen != null || mc.gameSettings.showDebugInfo) { - return; - } - final int n = 5; - final int n2 = 70; - final int n3 = n + 100; - final int n4 = n2 + 100; - Gui.drawRect(n, n2, n3, n4, rectColor); - Gui.drawRect(n - 1, n2 - 1, n3 + 1, n2, -1); - Gui.drawRect(n - 1, n4, n3 + 1, n4 + 1, -1); - Gui.drawRect(n - 1, n2, n, n4, -1); - Gui.drawRect(n3, n2, n3 + 1, n4, -1); - RenderUtils.drawPolygon((double)(n3 / 2 + 3), (double)(n2 + 52), 5.0, 3, -1); - GL11.glPushMatrix(); - GL11.glEnable(3089); - GL11.glScissor(n * this.scale, mc.displayHeight - this.scale * 170, n3 * this.scale - this.scale * 5, this.scale * 100); - for (final EntityPlayer entityPlayer : mc.theWorld.playerEntities) { - if (entityPlayer != mc.thePlayer && entityPlayer.deathTime == 0) { - if (AntiBot.isBot(entityPlayer)) { - continue; - } - final double getDistanceSqToEntity = entityPlayer.getDistanceSqToEntity(mc.thePlayer); - if (getDistanceSqToEntity > 360.0) { - continue; - } - final double n5 = (mc.thePlayer.rotationYaw + Math.atan2(entityPlayer.posX - mc.thePlayer.posX, entityPlayer.posZ - mc.thePlayer.posZ) * 57.295780181884766) % 360.0; - final double n6 = getDistanceSqToEntity / 5.0; - final double n7 = n6 * Math.sin(Math.toRadians(n5)); - final double n8 = n6 * Math.cos(Math.toRadians(n5)); - if (tracerLines.isToggled()) { - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glEnable(2848); - GL11.glDisable(2929); - GL11.glDisable(3553); - GL11.glBlendFunc(770, 771); - GL11.glEnable(3042); - GL11.glLineWidth(0.5f); - GL11.glColor3d(1.0, 1.0, 1.0); - GL11.glBegin(2); - GL11.glVertex2d((double)(n3 / 2 + 3), (double)(n2 + 52)); - GL11.glVertex2d((double)(n3 / 2 + 3) - n7, (double)(n2 + 52) - n8); - GL11.glEnd(); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - GL11.glDisable(3042); - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDisable(2848); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - RenderUtils.drawPolygon((double)(n3 / 2 + 3) - n7, (double)(n2 + 52) - n8, 3.0, 4, Color.red.getRGB()); - } - } - GL11.glDisable(3089); - GL11.glPopMatrix(); - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.clickgui.ClickGui; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class Radar extends Module { + private ButtonSetting tracerLines; + private int scale = 2; + private int rectColor = new Color(0, 0, 0, 125).getRGB(); + public Radar() { + super("Radar", category.render); + this.registerSetting(tracerLines = new ButtonSetting("Show tracer lines", false)); + } + + public void onUpdate() { + this.scale = new ScaledResolution(mc).getScaleFactor(); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent e) { + if (e.phase != TickEvent.Phase.END || !Utils.nullCheck()) { + return; + } + if (mc.currentScreen instanceof ClickGui) { + return; + } + if (mc.currentScreen != null || mc.gameSettings.showDebugInfo) { + return; + } + final int n = 5; + final int n2 = 70; + final int n3 = n + 100; + final int n4 = n2 + 100; + Gui.drawRect(n, n2, n3, n4, rectColor); + Gui.drawRect(n - 1, n2 - 1, n3 + 1, n2, -1); + Gui.drawRect(n - 1, n4, n3 + 1, n4 + 1, -1); + Gui.drawRect(n - 1, n2, n, n4, -1); + Gui.drawRect(n3, n2, n3 + 1, n4, -1); + RenderUtils.drawPolygon((double)(n3 / 2 + 3), (double)(n2 + 52), 5.0, 3, -1); + GL11.glPushMatrix(); + GL11.glEnable(3089); + GL11.glScissor(n * this.scale, mc.displayHeight - this.scale * 170, n3 * this.scale - this.scale * 5, this.scale * 100); + for (final EntityPlayer entityPlayer : mc.theWorld.playerEntities) { + if (entityPlayer != mc.thePlayer && entityPlayer.deathTime == 0) { + if (AntiBot.isBot(entityPlayer)) { + continue; + } + final double getDistanceSqToEntity = entityPlayer.getDistanceSqToEntity(mc.thePlayer); + if (getDistanceSqToEntity > 360.0) { + continue; + } + final double n5 = (mc.thePlayer.rotationYaw + Math.atan2(entityPlayer.posX - mc.thePlayer.posX, entityPlayer.posZ - mc.thePlayer.posZ) * 57.295780181884766) % 360.0; + final double n6 = getDistanceSqToEntity / 5.0; + final double n7 = n6 * Math.sin(Math.toRadians(n5)); + final double n8 = n6 * Math.cos(Math.toRadians(n5)); + if (tracerLines.isToggled()) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(3042); + GL11.glLineWidth(0.5f); + GL11.glColor3d(1.0, 1.0, 1.0); + GL11.glBegin(2); + GL11.glVertex2d((double)(n3 / 2 + 3), (double)(n2 + 52)); + GL11.glVertex2d((double)(n3 / 2 + 3) - n7, (double)(n2 + 52) - n8); + GL11.glEnd(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + RenderUtils.drawPolygon((double)(n3 / 2 + 3) - n7, (double)(n2 + 52) - n8, 3.0, 4, Color.red.getRGB()); + } + } + GL11.glDisable(3089); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/Shaders.java b/src/main/java/keystrokesmod/module/impl/render/Shaders.java index df92960..c683f83 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Shaders.java +++ b/src/main/java/keystrokesmod/module/impl/render/Shaders.java @@ -1,73 +1,73 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class Shaders extends Module { - private SliderSetting shader; - private String[] shaderNames; - private ResourceLocation[] shaderLocations; - private boolean resetShader; - - public Shaders() { - super("Shaders", category.render); - shaderLocations = ((IAccessorEntityRenderer) mc.entityRenderer).getShaderResourceLocations(); - if (shaderLocations == null) { - return; - } - shaderNames = new String[shaderLocations.length]; - for (int i = 0; i < shaderLocations.length; ++i) { - shaderNames[i] = ((String[]) shaderLocations[i].getResourcePath().replaceFirst("shaders/post/", "").split("\\.json"))[0].toUpperCase(); - } - this.registerSetting(shader = new SliderSetting("Shader", 0, shaderNames)); - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (mc.thePlayer != null && e.getPacket() instanceof S08PacketPlayerPosLook) { - resetShader = true; - } - } - - public void onUpdate() { - if (resetShader) { - mc.entityRenderer.stopUseShader(); - resetShader = false; - } - if (!Utils.nullCheck() || mc.entityRenderer == null || shaderLocations == null) { - return; - } - try { - if (((IAccessorEntityRenderer) mc.entityRenderer).getShaderIndex() != (int) shader.getInput()) { - ((IAccessorEntityRenderer) mc.entityRenderer).setShaderIndex((int) shader.getInput()); - ((IAccessorEntityRenderer) mc.entityRenderer).callLoadShader(shaderLocations[(int) shader.getInput()]); - } - else if (!((IAccessorEntityRenderer) mc.entityRenderer).getUseShader()) { - ((IAccessorEntityRenderer) mc.entityRenderer).setUseShader(true); - } - } - catch (Exception ex) { - ex.printStackTrace(); - Utils.sendMessage("&cError loading shader."); - this.disable(); - } - } - - public void onDisable() { - mc.entityRenderer.stopUseShader(); - } - - public void onEnable() { - if (!OpenGlHelper.shadersSupported) { - Utils.sendMessage("&cShaders not supported."); - this.disable(); - } - } +package keystrokesmod.module.impl.render; + +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.mixin.impl.accessor.IAccessorEntityRenderer; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class Shaders extends Module { + private SliderSetting shader; + private String[] shaderNames; + private ResourceLocation[] shaderLocations; + private boolean resetShader; + + public Shaders() { + super("Shaders", category.render); + shaderLocations = ((IAccessorEntityRenderer) mc.entityRenderer).getShaderResourceLocations(); + if (shaderLocations == null) { + return; + } + shaderNames = new String[shaderLocations.length]; + for (int i = 0; i < shaderLocations.length; ++i) { + shaderNames[i] = ((String[]) shaderLocations[i].getResourcePath().replaceFirst("shaders/post/", "").split("\\.json"))[0].toUpperCase(); + } + this.registerSetting(shader = new SliderSetting("Shader", 0, shaderNames)); + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (mc.thePlayer != null && e.getPacket() instanceof S08PacketPlayerPosLook) { + resetShader = true; + } + } + + public void onUpdate() { + if (resetShader) { + mc.entityRenderer.stopUseShader(); + resetShader = false; + } + if (!Utils.nullCheck() || mc.entityRenderer == null || shaderLocations == null) { + return; + } + try { + if (((IAccessorEntityRenderer) mc.entityRenderer).getShaderIndex() != (int) shader.getInput()) { + ((IAccessorEntityRenderer) mc.entityRenderer).setShaderIndex((int) shader.getInput()); + ((IAccessorEntityRenderer) mc.entityRenderer).callLoadShader(shaderLocations[(int) shader.getInput()]); + } + else if (!((IAccessorEntityRenderer) mc.entityRenderer).getUseShader()) { + ((IAccessorEntityRenderer) mc.entityRenderer).setUseShader(true); + } + } + catch (Exception ex) { + ex.printStackTrace(); + Utils.sendMessage("&cError loading shader."); + this.disable(); + } + } + + public void onDisable() { + mc.entityRenderer.stopUseShader(); + } + + public void onEnable() { + if (!OpenGlHelper.shadersSupported) { + Utils.sendMessage("&cShaders not supported."); + this.disable(); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/render/TargetHUD.java b/src/main/java/keystrokesmod/module/impl/render/TargetInfo.java similarity index 87% rename from src/main/java/keystrokesmod/module/impl/render/TargetHUD.java rename to src/main/java/keystrokesmod/module/impl/render/TargetInfo.java index 382ab00..5974dc4 100644 --- a/src/main/java/keystrokesmod/module/impl/render/TargetHUD.java +++ b/src/main/java/keystrokesmod/module/impl/render/TargetInfo.java @@ -1,304 +1,326 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.Timer; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.shader.BlurUtils; -import keystrokesmod.utility.shader.RoundedUtils; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.client.config.GuiButtonExt; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; - -public class TargetHUD extends Module { - private SliderSetting mode; - private SliderSetting theme; - private ButtonSetting renderEsp; - private ButtonSetting showStatus; - private ButtonSetting healthColor; - private Timer fadeTimer; - private Timer healthBarTimer = null; - private EntityLivingBase target; - private long lastAliveMS; - private double lastHealth; - private float lastHealthBar; - public EntityLivingBase renderEntity; - public int posX = 70; - public int posY = 30; - private String[] modes = new String[]{ "Modern", "Legacy" }; - - public TargetHUD() { - super("TargetHUD", category.render); - this.registerSetting(new DescriptionSetting("Only works with KillAura.")); - this.registerSetting(mode = new SliderSetting("Mode", 1, modes)); - this.registerSetting(theme = new SliderSetting("Theme", 0, Theme.themes)); - this.registerSetting(new ButtonSetting("Edit position", () -> { - mc.displayGuiScreen(new EditScreen()); - })); - this.registerSetting(renderEsp = new ButtonSetting("Render ESP", true)); - this.registerSetting(showStatus = new ButtonSetting("Show win or loss", true)); - this.registerSetting(healthColor = new ButtonSetting("Traditional health color", false)); - } - - public void onDisable() { - reset(); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (!Utils.nullCheck()) { - reset(); - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - reset(); - return; - } - if (KillAura.attackingEntity != null) { - target = KillAura.attackingEntity; - lastAliveMS = System.currentTimeMillis(); - fadeTimer = null; - } else if (target != null) { - if (System.currentTimeMillis() - lastAliveMS >= 400 && fadeTimer == null) { - (fadeTimer = new Timer(400)).start(); - } - } - else { - return; - } - String playerInfo = target.getDisplayName().getFormattedText(); - double health = target.getHealth() / target.getMaxHealth(); - if (target.isDead) { - health = 0; - } - if (health != lastHealth) { - (healthBarTimer = new Timer(mode.getInput() == 0 ? 500 : 350)).start(); - } - lastHealth = health; - playerInfo += " " + Utils.getHealthStr(target, true); - drawTargetHUD(fadeTimer, playerInfo, health); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderWorld(RenderWorldLastEvent renderWorldLastEvent) { - if (!renderEsp.isToggled() || !Utils.nullCheck()) { - return; - } - if (KillAura.target != null) { - RenderUtils.renderEntity(KillAura.target, 2, 0.0, 0.0, Theme.getGradient((int) theme.getInput(), 0), false); - } - else if (renderEntity != null) { - RenderUtils.renderEntity(renderEntity, 2, 0.0, 0.0, Theme.getGradient((int) theme.getInput(), 0), false); - } - } - - private void drawTargetHUD(Timer fadeTimer, String string, double health) { - if (showStatus.isToggled()) { - string = string + " " + ((health <= Utils.getTotalHealth(mc.thePlayer) / mc.thePlayer.getMaxHealth()) ? "§aW" : "§cL"); - } - final ScaledResolution scaledResolution = new ScaledResolution(mc); - final int padding = 8; - final int targetStrWithPadding = mc.fontRendererObj.getStringWidth(string) + padding; - final int x = (scaledResolution.getScaledWidth() / 2 - targetStrWithPadding / 2) + posX; - final int y = (scaledResolution.getScaledHeight() / 2 + 15) + posY; - final int n6 = x - padding; - final int n7 = y - padding; - final int n8 = x + targetStrWithPadding; - final int n9 = y + (mc.fontRendererObj.FONT_HEIGHT + 5) - 6 + padding; - final int alpha = (fadeTimer == null) ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); - if (alpha > 0) { - final int maxAlphaOutline = (alpha > 110) ? 110 : alpha; - final int maxAlphaBackground = (alpha > 210) ? 210 : alpha; - final int[] gradientColors = Theme.getGradients((int) theme.getInput()); - switch ((int) mode.getInput()) { - case 0: - float bloomRadius = (fadeTimer == null) ? 2f : (2f * alpha / 255f); - float blurRadius = (fadeTimer == null) ? 3 : (3f * alpha / 255f); - BlurUtils.prepareBloom(); - RoundedUtils.drawRound((float) n6, (float) n7, Math.abs((float) n6 - n8), Math.abs((float) n7 - (n9 + 13)), 8.0f, true, new Color(0, 0, 0, maxAlphaBackground)); - BlurUtils.bloomEnd(3, bloomRadius); - BlurUtils.prepareBlur(); - RoundedUtils.drawRound((float) n6, (float) n7, Math.abs((float) n6 - n8), Math.abs((float) n7 - (n9 + 13)), 8.0f, true, new Color(Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline))); - BlurUtils.blurEnd(2, blurRadius); - break; - case 1: - RenderUtils.drawRoundedGradientOutlinedRectangle((float) n6, (float) n7, (float) n8, (float) (n9 + 13), 10.0f, Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline), Utils.mergeAlpha(gradientColors[0], alpha), Utils.mergeAlpha(gradientColors[1], alpha)); - break; - } - final int n13 = n6 + 6; - final int n14 = n8 - 6; - final int n15 = n9; - - // Bar background - RenderUtils.drawRoundedRectangle((float) n13, (float) n15, (float) n14, (float) (n15 + 5), 4.0f, Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline)); - int mergedGradientLeft = Utils.mergeAlpha(gradientColors[0], maxAlphaBackground); - int mergedGradientRight = Utils.mergeAlpha(gradientColors[1], maxAlphaBackground); - float healthBar = (float) (int) (n14 + (n13 - n14) * (1 - health)); - boolean smoothBack = false; - if (healthBar != lastHealthBar && lastHealthBar - n13 >= 3 && healthBarTimer != null ) { - int type = mode.getInput() == 0 ? 4 : 1; - float diff = lastHealthBar - healthBar; - if (diff > 0) { - lastHealthBar = lastHealthBar - healthBarTimer.getValueFloat(0, diff, type); - } - else { - smoothBack = true; - lastHealthBar = healthBarTimer.getValueFloat(lastHealthBar, healthBar, type); - } - } - else { - lastHealthBar = healthBar; - } - if (healthColor.isToggled()) { - mergedGradientLeft = mergedGradientRight = Utils.mergeAlpha(Utils.getColorForHealth(health), maxAlphaBackground); - } - if (lastHealthBar > n14) { // exceeds total width then clamp - lastHealthBar = n14; - } - - switch ((int) mode.getInput()) { // health bar - case 0: - RenderUtils.drawRoundedRectangle((float) n13, (float) n15, lastHealthBar, (float) (n15 + 5), 4.0f, Utils.darkenColor(mergedGradientRight, 25)); - RenderUtils.drawRoundedGradientRect((float) n13, (float) n15, smoothBack ? lastHealthBar : healthBar, (float) (n15 + 5), 4.0f, mergedGradientLeft, mergedGradientLeft, mergedGradientRight, mergedGradientRight); - break; - case 1: - RenderUtils.drawRoundedGradientRect((float) n13, (float) n15, lastHealthBar, (float) (n15 + 5), 4.0f, mergedGradientLeft, mergedGradientLeft, mergedGradientRight, mergedGradientRight); - break; - } - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - mc.fontRendererObj.drawString(string, (float) x, (float) y, (new Color(220, 220, 220, 255).getRGB() & 0xFFFFFF) | Utils.clamp(alpha + 15) << 24, true); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - else { - target = null; - healthBarTimer = null; - } - } - - private void reset() { - fadeTimer = null; - target = null; - healthBarTimer = null; - renderEntity = null; - } - - class EditScreen extends GuiScreen { - GuiButtonExt resetPosition; - boolean d = false; - int miX = 0; - int miY = 0; - int maX = 0; - int maY = 0; - int aX = 70; - int aY = 30; - int laX = 0; - int laY = 0; - int lmX = 0; - int lmY = 0; - int clickMinX = 0; - - public void initGui() { - super.initGui(); - this.buttonList.add(this.resetPosition = new GuiButtonExt(1, this.width - 90, this.height - 25, 85, 20, "Reset position")); - this.aX = posX; - this.aY = posY; - } - - public void drawScreen(int mX, int mY, float pt) { - ScaledResolution res = new ScaledResolution(this.mc); - drawRect(0, 0, this.width, this.height, -1308622848); - int miX = this.aX; - int miY = this.aY; - String playerInfo = mc.thePlayer.getDisplayName().getFormattedText(); - double health = mc.thePlayer.getHealth() / mc.thePlayer.getMaxHealth(); - if (mc.thePlayer.isDead) { - health = 0; - } - lastHealth = health; - playerInfo += " " + Utils.getHealthStr(mc.thePlayer, true); - drawTargetHUD(null, playerInfo, health); - if (showStatus.isToggled()) { - playerInfo = playerInfo + " " + ((health <= Utils.getTotalHealth(mc.thePlayer) / mc.thePlayer.getMaxHealth()) ? "§aW" : "§cL"); - } - int stringWidth = mc.fontRendererObj.getStringWidth(playerInfo) + 8; - int maX = (res.getScaledWidth() / 2 - stringWidth / 2) + miX + mc.fontRendererObj.getStringWidth(playerInfo) + 8; - int maY = (res.getScaledHeight() / 2 + 15) + miY + (mc.fontRendererObj.FONT_HEIGHT + 5) - 6 + 8; - this.miX = miX; - this.miY = miY; - this.maX = maX; - this.maY = maY; - this.clickMinX = miX; - posX = miX; - posY = miY; - String edit = "Edit the HUD position by dragging."; - int x = res.getScaledWidth() / 2 - fontRendererObj.getStringWidth(edit) / 2; - int y = res.getScaledHeight() / 2 - 20; - RenderUtils.drawColoredString(edit, '-', x, y, 2L, 0L, true, this.mc.fontRendererObj); - - try { - this.handleInput(); - } - catch (IOException var12) { - } - - super.drawScreen(mX, mY, pt); - } - - protected void mouseClickMove(int mX, int mY, int b, long t) { - super.mouseClickMove(mX, mY, b, t); - if (b == 0) { - if (this.d) { - this.aX = this.laX + (mX - this.lmX); - this.aY = this.laY + (mY - this.lmY); - } - else if (mX > this.clickMinX && mX < this.maX && mY > this.miY && mY < this.maY) { - this.d = true; - this.lmX = mX; - this.lmY = mY; - this.laX = this.aX; - this.laY = this.aY; - } - - } - } - - protected void mouseReleased(int mX, int mY, int s) { - super.mouseReleased(mX, mY, s); - if (s == 0) { - this.d = false; - } - - } - - public void actionPerformed(GuiButton b) { - if (b == this.resetPosition) { - this.aX = posX = 70; - this.aY = posY = 30; - } - - } - - public boolean doesGuiPauseGame() { - return false; - } - } -} +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.combat.KillAura; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.utility.RenderUtils; +import keystrokesmod.utility.Theme; +import keystrokesmod.utility.Timer; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.shader.BlurUtils; +import keystrokesmod.utility.shader.RoundedUtils; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.client.config.GuiButtonExt; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; + +public class TargetInfo extends Module { + private SliderSetting mode; + private SliderSetting theme; + private ButtonSetting renderHUD, renderESP; + private SliderSetting espMode; + private ButtonSetting showStatus; + private ButtonSetting healthColor; + private Timer fadeTimer; + private Timer healthBarTimer = null; + private EntityLivingBase target; + private long lastAliveMS; + private double lastHealth; + private float lastHealthBar; + public int posX = 70; + public int posY = 30; + private String[] modes = new String[]{ "Modern", "Legacy" }; + private String[] espModes = new String[]{ "Theme", "Team", "Hurttime" }; + private SliderSetting min; + + public TargetInfo() { + super("TargetInfo", category.render); + this.registerSetting(new DescriptionSetting("Only works with KillAura.")); + this.registerSetting(renderHUD = new ButtonSetting("Render HUD", true)); + this.registerSetting(mode = new SliderSetting("Mode", 1, modes)); + this.registerSetting(theme = new SliderSetting("Theme", 0, Theme.themes)); + this.registerSetting(new ButtonSetting("Edit position", () -> { + mc.displayGuiScreen(new EditScreen()); + })); + this.registerSetting(renderESP = new ButtonSetting("Render ESP", true)); + this.registerSetting(espMode = new SliderSetting("ESP mode", 1, espModes)); + this.registerSetting(min = new SliderSetting("Minimum hurttime", 1, 1, 9, 1)); + this.registerSetting(showStatus = new ButtonSetting("Show win or loss", true)); + this.registerSetting(healthColor = new ButtonSetting("Traditional health color", false)); + } + + public void guiUpdate() { + this.min.setVisible(espMode.getInput() == 2, this); + } + + public void onDisable() { + reset(); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck()) { + reset(); + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + reset(); + return; + } + if (KillAura.attackingEntity != null) { + target = KillAura.attackingEntity; + lastAliveMS = System.currentTimeMillis(); + fadeTimer = null; + } else if (target != null) { + if (System.currentTimeMillis() - lastAliveMS >= 400 && fadeTimer == null) { + (fadeTimer = new Timer(400)).start(); + } + } + else { + return; + } + String playerInfo = target.getDisplayName().getFormattedText(); + double health = target.getHealth() / target.getMaxHealth(); + if (target.isDead) { + health = 0; + } + if (health != lastHealth) { + (healthBarTimer = new Timer(mode.getInput() == 0 ? 500 : 350)).start(); + } + lastHealth = health; + playerInfo += " " + Utils.getHealthStr(target, true); + if (renderHUD.isToggled()) { + drawTargetHUD(fadeTimer, playerInfo, health); + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderWorld(RenderWorldLastEvent renderWorldLastEvent) { + if (!renderESP.isToggled() || !Utils.nullCheck()) { + return; + } + if (KillAura.target != null) { + RenderUtils.renderEntity(KillAura.target, 2, 0.0, 0.0, returnColor(), false); + } + } + + private int returnColor() { + if (espMode.getInput() == 0) { + return Theme.getGradient((int) theme.getInput(), 0); + } + if (espMode.getInput() == 1) { + return Utils.mergeAlpha(Utils.getColorFromEntity(KillAura.target), 255); + } + if (espMode.getInput() == 2) { + int dc = new Color(251, 86, 86, 255).getRGB(); + int nc = new Color(107, 255, 103, 255).getRGB(); + return (Utils.getHurttime(KillAura.target) >= min.getInput() ? dc : nc); + } + return 0; + } + + private void drawTargetHUD(Timer fadeTimer, String string, double health) { + if (showStatus.isToggled()) { + string = string + " " + ((health <= Utils.getTotalHealth(mc.thePlayer) / mc.thePlayer.getMaxHealth()) ? "§aW" : "§cL"); + } + final ScaledResolution scaledResolution = new ScaledResolution(mc); + final int padding = 8; + final int targetStrWithPadding = mc.fontRendererObj.getStringWidth(string) + padding; + final int x = (scaledResolution.getScaledWidth() / 2 - targetStrWithPadding / 2) + posX; + final int y = (scaledResolution.getScaledHeight() / 2 + 15) + posY; + final int n6 = x - padding; + final int n7 = y - padding; + final int n8 = x + targetStrWithPadding; + final int n9 = y + (mc.fontRendererObj.FONT_HEIGHT + 5) - 6 + padding; + final int alpha = (fadeTimer == null) ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); + if (alpha > 0) { + final int maxAlphaOutline = (alpha > 110) ? 110 : alpha; + final int maxAlphaBackground = (alpha > 210) ? 210 : alpha; + final int[] gradientColors = Theme.getGradients((int) theme.getInput()); + switch ((int) mode.getInput()) { + case 0: + float bloomRadius = (fadeTimer == null) ? 2f : (2f * alpha / 255f); + float blurRadius = (fadeTimer == null) ? 3 : (3f * alpha / 255f); + BlurUtils.prepareBloom(); + RoundedUtils.drawRound((float) n6, (float) n7, Math.abs((float) n6 - n8), Math.abs((float) n7 - (n9 + 13)), 8.0f, true, new Color(0, 0, 0, maxAlphaBackground)); + BlurUtils.bloomEnd(3, bloomRadius); + BlurUtils.prepareBlur(); + RoundedUtils.drawRound((float) n6, (float) n7, Math.abs((float) n6 - n8), Math.abs((float) n7 - (n9 + 13)), 8.0f, true, new Color(Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline))); + BlurUtils.blurEnd(2, blurRadius); + break; + case 1: + RenderUtils.drawRoundedGradientOutlinedRectangle((float) n6, (float) n7, (float) n8, (float) (n9 + 13), 10.0f, Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline), Utils.mergeAlpha(gradientColors[0], alpha), Utils.mergeAlpha(gradientColors[1], alpha)); + break; + } + final int n13 = n6 + 6; + final int n14 = n8 - 6; + final int n15 = n9; + + // Bar background + RenderUtils.drawRoundedRectangle((float) n13, (float) n15, (float) n14, (float) (n15 + 5), 4.0f, Utils.mergeAlpha(Color.black.getRGB(), maxAlphaOutline)); + int mergedGradientLeft = Utils.mergeAlpha(gradientColors[0], maxAlphaBackground); + int mergedGradientRight = Utils.mergeAlpha(gradientColors[1], maxAlphaBackground); + float healthBar = (float) (int) (n14 + (n13 - n14) * (1 - health)); + boolean smoothBack = false; + if (healthBar != lastHealthBar && lastHealthBar - n13 >= 3 && healthBarTimer != null ) { + int type = mode.getInput() == 0 ? 4 : 1; + float diff = lastHealthBar - healthBar; + if (diff > 0) { + lastHealthBar = lastHealthBar - healthBarTimer.getValueFloat(0, diff, type); + } + else { + smoothBack = true; + lastHealthBar = healthBarTimer.getValueFloat(lastHealthBar, healthBar, type); + } + } + else { + lastHealthBar = healthBar; + } + if (healthColor.isToggled()) { + mergedGradientLeft = mergedGradientRight = Utils.mergeAlpha(Utils.getColorForHealth(health), maxAlphaBackground); + } + if (lastHealthBar > n14) { // exceeds total width then clamp + lastHealthBar = n14; + } + + switch ((int) mode.getInput()) { // health bar + case 0: + RenderUtils.drawRoundedRectangle((float) n13, (float) n15, lastHealthBar, (float) (n15 + 5), 4.0f, Utils.darkenColor(mergedGradientRight, 25)); + RenderUtils.drawRoundedGradientRect((float) n13, (float) n15, smoothBack ? lastHealthBar : healthBar, (float) (n15 + 5), 4.0f, mergedGradientLeft, mergedGradientLeft, mergedGradientRight, mergedGradientRight); + break; + case 1: + RenderUtils.drawRoundedGradientRect((float) n13, (float) n15, lastHealthBar, (float) (n15 + 5), 4.0f, mergedGradientLeft, mergedGradientLeft, mergedGradientRight, mergedGradientRight); + break; + } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + mc.fontRendererObj.drawString(string, (float) x, (float) y, (new Color(220, 220, 220, 255).getRGB() & 0xFFFFFF) | Utils.clamp(alpha + 15) << 24, true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + else { + target = null; + healthBarTimer = null; + } + } + + private void reset() { + fadeTimer = null; + target = null; + healthBarTimer = null; + } + + class EditScreen extends GuiScreen { + GuiButtonExt resetPosition; + boolean d = false; + int miX = 0; + int miY = 0; + int maX = 0; + int maY = 0; + int aX = 70; + int aY = 30; + int laX = 0; + int laY = 0; + int lmX = 0; + int lmY = 0; + int clickMinX = 0; + + public void initGui() { + super.initGui(); + this.buttonList.add(this.resetPosition = new GuiButtonExt(1, this.width - 90, this.height - 25, 85, 20, "Reset position")); + this.aX = posX; + this.aY = posY; + } + + public void drawScreen(int mX, int mY, float pt) { + ScaledResolution res = new ScaledResolution(this.mc); + drawRect(0, 0, this.width, this.height, -1308622848); + int miX = this.aX; + int miY = this.aY; + String playerInfo = mc.thePlayer.getDisplayName().getFormattedText(); + double health = mc.thePlayer.getHealth() / mc.thePlayer.getMaxHealth(); + if (mc.thePlayer.isDead) { + health = 0; + } + lastHealth = health; + playerInfo += " " + Utils.getHealthStr(mc.thePlayer, true); + drawTargetHUD(null, playerInfo, health); + if (showStatus.isToggled()) { + playerInfo = playerInfo + " " + ((health <= Utils.getTotalHealth(mc.thePlayer) / mc.thePlayer.getMaxHealth()) ? "§aW" : "§cL"); + } + int stringWidth = mc.fontRendererObj.getStringWidth(playerInfo) + 8; + int maX = (res.getScaledWidth() / 2 - stringWidth / 2) + miX + mc.fontRendererObj.getStringWidth(playerInfo) + 8; + int maY = (res.getScaledHeight() / 2 + 15) + miY + (mc.fontRendererObj.FONT_HEIGHT + 5) - 6 + 8; + this.miX = miX; + this.miY = miY; + this.maX = maX; + this.maY = maY; + this.clickMinX = miX; + posX = miX; + posY = miY; + String edit = "Edit the HUD position by dragging."; + int x = res.getScaledWidth() / 2 - fontRendererObj.getStringWidth(edit) / 2; + int y = res.getScaledHeight() / 2 - 20; + RenderUtils.drawColoredString(edit, '-', x, y, 2L, 0L, true, this.mc.fontRendererObj); + + try { + this.handleInput(); + } + catch (IOException var12) { + } + + super.drawScreen(mX, mY, pt); + } + + protected void mouseClickMove(int mX, int mY, int b, long t) { + super.mouseClickMove(mX, mY, b, t); + if (b == 0) { + if (this.d) { + this.aX = this.laX + (mX - this.lmX); + this.aY = this.laY + (mY - this.lmY); + } + else if (mX > this.clickMinX && mX < this.maX && mY > this.miY && mY < this.maY) { + this.d = true; + this.lmX = mX; + this.lmY = mY; + this.laX = this.aX; + this.laY = this.aY; + } + + } + } + + protected void mouseReleased(int mX, int mY, int s) { + super.mouseReleased(mX, mY, s); + if (s == 0) { + this.d = false; + } + + } + + public void actionPerformed(GuiButton b) { + if (b == this.resetPosition) { + this.aX = posX = 70; + this.aY = posY = 30; + } + + } + + public boolean doesGuiPauseGame() { + return false; + } + } +} diff --git a/src/main/java/keystrokesmod/module/impl/render/Trajectories.java b/src/main/java/keystrokesmod/module/impl/render/Trajectories.java index 65d80eb..d8dff1f 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Trajectories.java +++ b/src/main/java/keystrokesmod/module/impl/render/Trajectories.java @@ -1,231 +1,231 @@ -package keystrokesmod.module.impl.render; - -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.world.AntiBot; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.Utils; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.*; -import net.minecraft.util.*; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; -import java.util.List; - -public class Trajectories extends Module { - private ButtonSetting autoScale; - private ButtonSetting disableUnchargedBow; - private ButtonSetting highlightEntities; - private ButtonSetting shortenLine; - - public Trajectories() { - super("Trajectories", category.render); - this.registerSetting(autoScale = new ButtonSetting("Auto-scale", true)); - this.registerSetting(disableUnchargedBow = new ButtonSetting("Disable uncharged bow", true)); - this.registerSetting(highlightEntities = new ButtonSetting("Highlight on entity", true)); - this.registerSetting(shortenLine = new ButtonSetting("Shorten line", false)); - } - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent e) { - if (!Utils.nullCheck() || mc.thePlayer.getHeldItem() == null) { - return; - } - Item item = mc.thePlayer.getHeldItem().getItem(); - boolean usingBow = item instanceof ItemBow; - if (!usingBow && !(item instanceof ItemSnowball) && !(item instanceof ItemEgg) && !(item instanceof ItemEnderPearl)) { - return; - } - if (usingBow && disableUnchargedBow.isToggled() && !mc.thePlayer.isUsingItem()) { - return; - } - float yaw = (float)Math.toRadians(mc.thePlayer.rotationYaw); - float pitch = (float)Math.toRadians(mc.thePlayer.rotationPitch); - double arrowPosX = mc.thePlayer.lastTickPosX + (mc.thePlayer.posX - mc.thePlayer.lastTickPosX) * e.partialTicks - MathHelper.cos(yaw) * 0.16f; - double arrowPosY = mc.thePlayer.lastTickPosY + (mc.thePlayer.posY - mc.thePlayer.lastTickPosY) * e.partialTicks + mc.thePlayer.getEyeHeight() - 0.1; - double arrowPosZ = mc.thePlayer.lastTickPosZ + (mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ) * e.partialTicks - MathHelper.sin(yaw) * 0.16f; - float arrowMotionFactor = usingBow ? 1.0f : 0.4f; - float arrowMotionX = -MathHelper.sin(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; - float arrowMotionY = -MathHelper.sin(pitch) * arrowMotionFactor; - float arrowMotionZ = MathHelper.cos(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; - double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ); - arrowMotionX /= arrowMotion; - arrowMotionY /= arrowMotion; - arrowMotionZ /= arrowMotion; - if (usingBow) { - float bowPower = (72000 - mc.thePlayer.getItemInUseCount()) / 20.0f; - bowPower = (bowPower * bowPower + bowPower * 2.0f) / 3.0f; - if (bowPower > 1.0f) { - bowPower = 1.0f; - } - bowPower *= 3.0f; - arrowMotionX *= bowPower; - arrowMotionY *= bowPower; - arrowMotionZ *= bowPower; - } - else { - arrowMotionX *= 1.5; - arrowMotionY *= 1.5; - arrowMotionZ *= 1.5; - } - GL11.glPushMatrix(); - GL11.glEnable(2848); - GL11.glBlendFunc(770, 771); - GL11.glEnable(3042); - GL11.glDisable(3553); - GL11.glDisable(2929); - GL11.glEnable(32925); - GL11.glDepthMask(false); - RenderManager renderManager = mc.getRenderManager(); - double gravity = usingBow ? 0.05 : 0.03; - List posList = new ArrayList<>(); - MovingObjectPosition block = null; - Entity entity = null; - EnumFacing facingEntity = null; - EnumFacing facingBlock = null; - for (int i = 0; i < 750; ++i) { - posList.add(new double[] { arrowPosX - renderManager.viewerPosX, arrowPosY - renderManager.viewerPosY, arrowPosZ - renderManager.viewerPosZ }); - Vec3 arrowVec = new Vec3(arrowPosX, arrowPosY, arrowPosZ); - Vec3 arrowVecNext = new Vec3(arrowPosX + arrowMotionX, arrowPosY + arrowMotionY, arrowPosZ + arrowMotionZ); - arrowPosX = arrowVecNext.xCoord; - arrowPosY = arrowVecNext.yCoord; - arrowPosZ = arrowVecNext.zCoord; - arrowMotionX *= 0.99; - arrowMotionY *= 0.99; - arrowMotionZ *= 0.99; - arrowMotionY -= gravity; - double size = 0.5; - AxisAlignedBB arrowBox = new AxisAlignedBB(arrowPosX - size, arrowPosY - size, arrowPosZ - size, arrowPosX + size, arrowPosY + size, arrowPosZ + size).addCoord((double)arrowMotionX, (double)arrowMotionY, (double)arrowMotionZ).expand(1.0, 1.0, 1.0); - List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), arrowBox); - double minDistSq = 0.0; - for (final Entity en : list) { - if (en instanceof EntityLivingBase && !(en instanceof EntityArmorStand) && en.canBeCollidedWith()) { - if (((EntityLivingBase)en).deathTime != 0) { - continue; - } - if (en instanceof EntityPlayer && AntiBot.isBot(en)) { - continue; - } - AxisAlignedBB axis = en.getEntityBoundingBox().expand(0.30000001192092896, 0.30000001192092896, 0.30000001192092896); - MovingObjectPosition mop = axis.calculateIntercept(arrowVec, arrowVecNext); - if (mop == null) { - continue; - } - if (minDistSq == 0.0) { - entity = en; - facingEntity = mop.sideHit; - } - else { - double distSq = arrowVec.squareDistanceTo(mop.hitVec); - if (distSq >= minDistSq) { - continue; - } - entity = en; - facingEntity = mop.sideHit; - minDistSq = distSq; - } - } - } - block = mc.theWorld.rayTraceBlocks(arrowVec, arrowVecNext); - if (block != null) { - facingBlock = block.sideHit; - } - if (entity != null) { - break; - } - if (block != null) { - break; - } - } - if (entity != null && block != null) { - if (mc.thePlayer.getDistanceSqToEntity(entity) >= mc.thePlayer.getDistanceSqToCenter(block.getBlockPos())) { - entity = null; - facingEntity = null; - } - else { - block = null; - facingBlock = null; - } - } - EnumFacing facing = (facingEntity == null) ? facingBlock : facingEntity; - if (entity != null && highlightEntities.isToggled()) { - GL11.glColor3d(1.0, 0.0, 0.0); - GL11.glLineWidth(2.5f); - } - else { - if (facingBlock == EnumFacing.UP) { - GL11.glColor3d(0, 1.0, 0); - } - else { - GL11.glColor3d(1.0, 1.0, 1.0); - } - GL11.glLineWidth(1.8f); - } - GL11.glBegin(3); - for (int j = 0; j < posList.size(); ++j) { - if (j != 0 || !shortenLine.isToggled()) { - double[] pos = posList.get(j); - GL11.glVertex3d(pos[0], pos[1], pos[2]); - } - } - double renderX = arrowPosX - renderManager.viewerPosX; - double renderY = arrowPosY - renderManager.viewerPosY; - double renderZ = arrowPosZ - renderManager.viewerPosZ; - double distSq2 = 0.0; - if (entity != null) { - distSq2 = mc.thePlayer.getDistanceSq(entity.getPosition()); - } - else if (block != null) { - distSq2 = mc.thePlayer.getDistanceSq(block.getBlockPos()); - } - if (facing != null) { - double size2 = autoScale.isToggled() ? Math.min(0.1 * (1.0 + distSq2 / 500.0), 0.5) : 0.1; - switch (facing) { - case WEST: - case EAST: { - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX, renderY - size2, renderZ - size2); - GL11.glVertex3d(renderX, renderY + size2, renderZ + size2); - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX, renderY - size2, renderZ + size2); - GL11.glVertex3d(renderX, renderY + size2, renderZ - size2); - break; - } - case NORTH: - case SOUTH: { - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX - size2, renderY - size2, renderZ); - GL11.glVertex3d(renderX + size2, renderY + size2, renderZ); - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX + size2, renderY - size2, renderZ); - GL11.glVertex3d(renderX - size2, renderY + size2, renderZ); - break; - } - case DOWN: - case UP: { - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX - size2, renderY, renderZ - size2); - GL11.glVertex3d(renderX + size2, renderY, renderZ + size2); - GL11.glVertex3d(renderX, renderY, renderZ); - GL11.glVertex3d(renderX + size2, renderY, renderZ - size2); - GL11.glVertex3d(renderX - size2, renderY, renderZ + size2); - break; - } - } - } - GL11.glEnd(); - GL11.glDisable(3042); - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDisable(32925); - GL11.glDepthMask(true); - GL11.glDisable(2848); - GL11.glPopMatrix(); - } +package keystrokesmod.module.impl.render; + +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.world.AntiBot; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.Utils; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.*; +import net.minecraft.util.*; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import java.util.ArrayList; +import java.util.List; + +public class Trajectories extends Module { + private ButtonSetting autoScale; + private ButtonSetting disableUnchargedBow; + private ButtonSetting highlightEntities; + private ButtonSetting shortenLine; + + public Trajectories() { + super("Trajectories", category.render); + this.registerSetting(autoScale = new ButtonSetting("Auto-scale", true)); + this.registerSetting(disableUnchargedBow = new ButtonSetting("Disable uncharged bow", true)); + this.registerSetting(highlightEntities = new ButtonSetting("Highlight on entity", true)); + this.registerSetting(shortenLine = new ButtonSetting("Shorten line", false)); + } + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent e) { + if (!Utils.nullCheck() || mc.thePlayer.getHeldItem() == null) { + return; + } + Item item = mc.thePlayer.getHeldItem().getItem(); + boolean usingBow = item instanceof ItemBow; + if (!usingBow && !(item instanceof ItemSnowball) && !(item instanceof ItemEgg) && !(item instanceof ItemEnderPearl)) { + return; + } + if (usingBow && disableUnchargedBow.isToggled() && !mc.thePlayer.isUsingItem()) { + return; + } + float yaw = (float)Math.toRadians(mc.thePlayer.rotationYaw); + float pitch = (float)Math.toRadians(mc.thePlayer.rotationPitch); + double arrowPosX = mc.thePlayer.lastTickPosX + (mc.thePlayer.posX - mc.thePlayer.lastTickPosX) * e.partialTicks - MathHelper.cos(yaw) * 0.16f; + double arrowPosY = mc.thePlayer.lastTickPosY + (mc.thePlayer.posY - mc.thePlayer.lastTickPosY) * e.partialTicks + mc.thePlayer.getEyeHeight() - 0.1; + double arrowPosZ = mc.thePlayer.lastTickPosZ + (mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ) * e.partialTicks - MathHelper.sin(yaw) * 0.16f; + float arrowMotionFactor = usingBow ? 1.0f : 0.4f; + float arrowMotionX = -MathHelper.sin(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; + float arrowMotionY = -MathHelper.sin(pitch) * arrowMotionFactor; + float arrowMotionZ = MathHelper.cos(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; + double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ); + arrowMotionX /= arrowMotion; + arrowMotionY /= arrowMotion; + arrowMotionZ /= arrowMotion; + if (usingBow) { + float bowPower = (72000 - mc.thePlayer.getItemInUseCount()) / 20.0f; + bowPower = (bowPower * bowPower + bowPower * 2.0f) / 3.0f; + if (bowPower > 1.0f) { + bowPower = 1.0f; + } + bowPower *= 3.0f; + arrowMotionX *= bowPower; + arrowMotionY *= bowPower; + arrowMotionZ *= bowPower; + } + else { + arrowMotionX *= 1.5; + arrowMotionY *= 1.5; + arrowMotionZ *= 1.5; + } + GL11.glPushMatrix(); + GL11.glEnable(2848); + GL11.glBlendFunc(770, 771); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glEnable(32925); + GL11.glDepthMask(false); + RenderManager renderManager = mc.getRenderManager(); + double gravity = usingBow ? 0.05 : 0.03; + List posList = new ArrayList<>(); + MovingObjectPosition block = null; + Entity entity = null; + EnumFacing facingEntity = null; + EnumFacing facingBlock = null; + for (int i = 0; i < 750; ++i) { + posList.add(new double[] { arrowPosX - renderManager.viewerPosX, arrowPosY - renderManager.viewerPosY, arrowPosZ - renderManager.viewerPosZ }); + Vec3 arrowVec = new Vec3(arrowPosX, arrowPosY, arrowPosZ); + Vec3 arrowVecNext = new Vec3(arrowPosX + arrowMotionX, arrowPosY + arrowMotionY, arrowPosZ + arrowMotionZ); + arrowPosX = arrowVecNext.xCoord; + arrowPosY = arrowVecNext.yCoord; + arrowPosZ = arrowVecNext.zCoord; + arrowMotionX *= 0.99; + arrowMotionY *= 0.99; + arrowMotionZ *= 0.99; + arrowMotionY -= gravity; + double size = 0.5; + AxisAlignedBB arrowBox = new AxisAlignedBB(arrowPosX - size, arrowPosY - size, arrowPosZ - size, arrowPosX + size, arrowPosY + size, arrowPosZ + size).addCoord((double)arrowMotionX, (double)arrowMotionY, (double)arrowMotionZ).expand(1.0, 1.0, 1.0); + List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), arrowBox); + double minDistSq = 0.0; + for (final Entity en : list) { + if (en instanceof EntityLivingBase && !(en instanceof EntityArmorStand) && en.canBeCollidedWith()) { + if (((EntityLivingBase)en).deathTime != 0) { + continue; + } + if (en instanceof EntityPlayer && AntiBot.isBot(en)) { + continue; + } + AxisAlignedBB axis = en.getEntityBoundingBox().expand(0.30000001192092896, 0.30000001192092896, 0.30000001192092896); + MovingObjectPosition mop = axis.calculateIntercept(arrowVec, arrowVecNext); + if (mop == null) { + continue; + } + if (minDistSq == 0.0) { + entity = en; + facingEntity = mop.sideHit; + } + else { + double distSq = arrowVec.squareDistanceTo(mop.hitVec); + if (distSq >= minDistSq) { + continue; + } + entity = en; + facingEntity = mop.sideHit; + minDistSq = distSq; + } + } + } + block = mc.theWorld.rayTraceBlocks(arrowVec, arrowVecNext); + if (block != null) { + facingBlock = block.sideHit; + } + if (entity != null) { + break; + } + if (block != null) { + break; + } + } + if (entity != null && block != null) { + if (mc.thePlayer.getDistanceSqToEntity(entity) >= mc.thePlayer.getDistanceSqToCenter(block.getBlockPos())) { + entity = null; + facingEntity = null; + } + else { + block = null; + facingBlock = null; + } + } + EnumFacing facing = (facingEntity == null) ? facingBlock : facingEntity; + if (entity != null && highlightEntities.isToggled()) { + GL11.glColor3d(1.0, 0.0, 0.0); + GL11.glLineWidth(2.5f); + } + else { + if (facingBlock == EnumFacing.UP) { + GL11.glColor3d(0, 1.0, 0); + } + else { + GL11.glColor3d(1.0, 1.0, 1.0); + } + GL11.glLineWidth(1.8f); + } + GL11.glBegin(3); + for (int j = 0; j < posList.size(); ++j) { + if (j != 0 || !shortenLine.isToggled()) { + double[] pos = posList.get(j); + GL11.glVertex3d(pos[0], pos[1], pos[2]); + } + } + double renderX = arrowPosX - renderManager.viewerPosX; + double renderY = arrowPosY - renderManager.viewerPosY; + double renderZ = arrowPosZ - renderManager.viewerPosZ; + double distSq2 = 0.0; + if (entity != null) { + distSq2 = mc.thePlayer.getDistanceSq(entity.getPosition()); + } + else if (block != null) { + distSq2 = mc.thePlayer.getDistanceSq(block.getBlockPos()); + } + if (facing != null) { + double size2 = autoScale.isToggled() ? Math.min(0.1 * (1.0 + distSq2 / 500.0), 0.5) : 0.1; + switch (facing) { + case WEST: + case EAST: { + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX, renderY - size2, renderZ - size2); + GL11.glVertex3d(renderX, renderY + size2, renderZ + size2); + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX, renderY - size2, renderZ + size2); + GL11.glVertex3d(renderX, renderY + size2, renderZ - size2); + break; + } + case NORTH: + case SOUTH: { + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX - size2, renderY - size2, renderZ); + GL11.glVertex3d(renderX + size2, renderY + size2, renderZ); + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX + size2, renderY - size2, renderZ); + GL11.glVertex3d(renderX - size2, renderY + size2, renderZ); + break; + } + case DOWN: + case UP: { + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX - size2, renderY, renderZ - size2); + GL11.glVertex3d(renderX + size2, renderY, renderZ + size2); + GL11.glVertex3d(renderX, renderY, renderZ); + GL11.glVertex3d(renderX + size2, renderY, renderZ - size2); + GL11.glVertex3d(renderX - size2, renderY, renderZ + size2); + break; + } + } + } + GL11.glEnd(); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(32925); + GL11.glDepthMask(true); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/world/Weather.java b/src/main/java/keystrokesmod/module/impl/world/Weather.java index a76c154..0eb7f00 100644 --- a/src/main/java/keystrokesmod/module/impl/world/Weather.java +++ b/src/main/java/keystrokesmod/module/impl/world/Weather.java @@ -1,18 +1,18 @@ -package keystrokesmod.module.impl.world; - -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.SliderSetting; - -public class Weather extends Module { - public SliderSetting time; - public SliderSetting lightning; - public ButtonSetting rain; - - public Weather() { - super("Weather", category.world); - this.registerSetting(time = new SliderSetting("Time", 0, 0, 24, 0.1)); - this.registerSetting(lightning = new SliderSetting("Lightning", 0, 0, 1, 0.01)); - this.registerSetting(rain = new ButtonSetting("Rain", false)); - } -} +package keystrokesmod.module.impl.world; + +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.SliderSetting; + +public class Weather extends Module { + public SliderSetting time; + public SliderSetting lightning; + public ButtonSetting rain; + + public Weather() { + super("Weather", category.world); + this.registerSetting(time = new SliderSetting("Time", 0, 0, 24, 0.1)); + this.registerSetting(lightning = new SliderSetting("Lightning", 0, 0, 1, 0.01)); + this.registerSetting(rain = new ButtonSetting("Rain", false)); + } +} diff --git a/src/main/java/keystrokesmod/module/setting/impl/GroupSetting.java b/src/main/java/keystrokesmod/module/setting/impl/GroupSetting.java index 8df4414..a216bc0 100644 --- a/src/main/java/keystrokesmod/module/setting/impl/GroupSetting.java +++ b/src/main/java/keystrokesmod/module/setting/impl/GroupSetting.java @@ -1,29 +1,29 @@ -package keystrokesmod.module.setting.impl; - -import com.google.gson.JsonObject; -import keystrokesmod.module.setting.Setting; - -import java.util.List; - -public class GroupSetting extends Setting { - private List settings; - - public GroupSetting(String name) { - super(name); - } - - public List getSettings() { - return settings; - } - - public void addSetting(Setting setting) { - settings.add(setting); - } - - public void removeSetting(Setting setting) { - settings.remove(setting); - } - - @Override - public void loadProfile(JsonObject data) {} -} +package keystrokesmod.module.setting.impl; + +import com.google.gson.JsonObject; +import keystrokesmod.module.setting.Setting; + +import java.util.List; + +public class GroupSetting extends Setting { + private List settings; + + public GroupSetting(String name) { + super(name); + } + + public List getSettings() { + return settings; + } + + public void addSetting(Setting setting) { + settings.add(setting); + } + + public void removeSetting(Setting setting) { + settings.remove(setting); + } + + @Override + public void loadProfile(JsonObject data) {} +} diff --git a/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java b/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java index c1fcc0c..69ac86a 100644 --- a/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java +++ b/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java @@ -1,58 +1,58 @@ -package keystrokesmod.module.setting.impl; - -import com.google.gson.JsonObject; -import keystrokesmod.module.setting.Setting; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -public class KeySetting extends Setting { - private int key; - public GroupSetting group; - - public KeySetting(String name, int key) { - super(name); - this.key = key; - } - - public KeySetting(GroupSetting group, String name, int key) { - super(name); - this.group = group; - this.key = key; - } - - public int getKey() { - return this.key; - } - - public String getName() { - return super.getName(); - } - - public void setKey(int key) { - this.key = key; - } - - public boolean isPressed() { - if (this.getKey() == 0) { - return false; - } - if (this.getKey() >= 1000) { - return Mouse.isButtonDown(this.getKey() - 1000); - } - else { - return Keyboard.isKeyDown(this.getKey()); - } - } - - @Override - public void loadProfile(JsonObject data) { - if (data.has(getName()) && data.get(getName()).isJsonPrimitive()) { - int keyValue = this.key; - try { - keyValue = data.getAsJsonPrimitive(getName()).getAsInt(); - } - catch (Exception ignored) {} - this.key = keyValue; - } - } -} +package keystrokesmod.module.setting.impl; + +import com.google.gson.JsonObject; +import keystrokesmod.module.setting.Setting; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +public class KeySetting extends Setting { + private int key; + public GroupSetting group; + + public KeySetting(String name, int key) { + super(name); + this.key = key; + } + + public KeySetting(GroupSetting group, String name, int key) { + super(name); + this.group = group; + this.key = key; + } + + public int getKey() { + return this.key; + } + + public String getName() { + return super.getName(); + } + + public void setKey(int key) { + this.key = key; + } + + public boolean isPressed() { + if (this.getKey() == 0) { + return false; + } + if (this.getKey() >= 1000) { + return Mouse.isButtonDown(this.getKey() - 1000); + } + else { + return Keyboard.isKeyDown(this.getKey()); + } + } + + @Override + public void loadProfile(JsonObject data) { + if (data.has(getName()) && data.get(getName()).isJsonPrimitive()) { + int keyValue = this.key; + try { + keyValue = data.getAsJsonPrimitive(getName()).getAsInt(); + } + catch (Exception ignored) {} + this.key = keyValue; + } + } +} diff --git a/src/main/java/keystrokesmod/script/JavaSourceFromString.java b/src/main/java/keystrokesmod/script/JavaSourceFromString.java index bbed556..092a1c8 100644 --- a/src/main/java/keystrokesmod/script/JavaSourceFromString.java +++ b/src/main/java/keystrokesmod/script/JavaSourceFromString.java @@ -1,23 +1,23 @@ -package keystrokesmod.script; - -import javax.tools.SimpleJavaFileObject; -import java.net.URI; - -public class JavaSourceFromString extends SimpleJavaFileObject -{ - private final String code; - public final String name; - public int extraLines; - - @Override - public CharSequence getCharContent(boolean ignoreEncodingErrors) { - return this.code; - } - - public JavaSourceFromString(final String name, final String code, int extraLines) { - super(URI.create("string:///" + name + ".java"), Kind.SOURCE); - this.code = code; - this.name = name; - this.extraLines = extraLines; - } +package keystrokesmod.script; + +import javax.tools.SimpleJavaFileObject; +import java.net.URI; + +public class JavaSourceFromString extends SimpleJavaFileObject +{ + private final String code; + public final String name; + public int extraLines; + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return this.code; + } + + public JavaSourceFromString(final String name, final String code, int extraLines) { + super(URI.create("string:///" + name + ".java"), Kind.SOURCE); + this.code = code; + this.name = name; + this.extraLines = extraLines; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/Manager.java b/src/main/java/keystrokesmod/script/Manager.java index 7c8c38d..e70884a 100644 --- a/src/main/java/keystrokesmod/script/Manager.java +++ b/src/main/java/keystrokesmod/script/Manager.java @@ -1,173 +1,173 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.script.model.Entity; -import keystrokesmod.script.model.Image; -import keystrokesmod.script.model.NetworkPlayer; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.profile.ProfileModule; -import org.lwjgl.Sys; - -import java.awt.*; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -public class Manager extends Module { - public static ButtonSetting enableHttpRequests; - public static ButtonSetting enableWebSockets; - - public final String DOCUMENTATION_URL = "https://blowsy.gitbook.io/raven"; - private final String CONFIG_DIR = mc.mcDataDir + File.separator + "keystrokes" + File.separator + "settings.txt"; - private final String SEPARATOR = ":"; - private final String SEPARATOR_FULL = SEPARATOR + " "; - - private long lastLoad = 0; - - public Manager() { - super("Manager", category.scripts); - this.registerSetting(new ButtonSetting("Load scripts", () -> { - if (Raven.scriptManager.compiler == null) { - Utils.sendMessage("&cCompiler error, JDK not found"); - } - else { - final long currentTimeMillis = System.currentTimeMillis(); - if (Utils.timeBetween(this.lastLoad, currentTimeMillis) > 1500) { - this.lastLoad = currentTimeMillis; - Raven.scriptManager.loadScripts(); - if (Raven.scriptManager.scripts.isEmpty()) { - Utils.sendMessage("&7No scripts found."); - } - else { - double timeTaken = Utils.round((System.currentTimeMillis() - currentTimeMillis) / 1000.0, 1); - Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "" : "s") + " in &b" + Utils.asWholeNum(timeTaken) + "&7s."); - } - Entity.clearCache(); - NetworkPlayer.clearCache(); - Image.clearCache(); - ScriptDefaults.reloadModules(); - if (Raven.currentProfile != null && Raven.currentProfile.getModule() != null) { - ((ProfileModule) Raven.currentProfile.getModule()).saved = false; - } - } - else { - Utils.sendMessage("&cYou are on cooldown."); - } - } - })); - this.registerSetting(new ButtonSetting("Open folder", () -> { - try { - Desktop.getDesktop().open(Raven.scriptManager.directory); - } - catch (IOException ex) { - Raven.scriptManager.directory.mkdirs(); - Utils.sendMessage("&cError locating folder, recreated."); - } - })); - this.registerSetting(new ButtonSetting("View documentation", () -> { - try { - Desktop.getDesktop().browse(new URI(DOCUMENTATION_URL)); - } - catch (Throwable t) { - Sys.openURL(DOCUMENTATION_URL); - } - })); - this.registerSetting(new DescriptionSetting("Privacy")); - this.registerSetting(enableHttpRequests = new ButtonSetting("Enable http requests", true)); - this.registerSetting(enableWebSockets = new ButtonSetting("Enable websockets", true)); - this.canBeEnabled = false; - this.ignoreOnSave = true; - - retrieveSettings(); - } - - @Override - public void guiButtonToggled(ButtonSetting s) { - updateSettingFile(); - } - - private boolean updateSettingFile() { - return set("enable-http-requests", String.valueOf(enableHttpRequests.isToggled())) & set("enable-websockets", String.valueOf(enableWebSockets.isToggled())); - } - - private void ensureConfigFileExists() throws IOException { - final Path configPath = Paths.get(CONFIG_DIR); - if (Files.notExists(configPath)) { - Files.createDirectories(configPath.getParent()); - Files.createFile(configPath); - } - } - - private boolean set(String key, String value) { - if (key == null || key.isEmpty()) { - return false; - } - key = key.replace(SEPARATOR, ""); - final String entry = key + SEPARATOR_FULL + value; - try { - ensureConfigFileExists(); - final Path configPath = new File(CONFIG_DIR).toPath(); - final List lines = new ArrayList<>(Files.readAllLines(configPath)); - boolean keyExists = false; - for (int i = 0; i < lines.size(); ++i) { - final String line = lines.get(i); - if (line.startsWith(key + SEPARATOR_FULL)) { - lines.set(i, entry); - keyExists = true; - break; - } - } - if (!keyExists) { - lines.add(entry); - } - Files.write(configPath, lines); - return true; - } - catch (IOException ex) { - return false; - } - } - - private void retrieveSettings() { - String requestState = retrieveSetting("enable-http-requests"); - String webSocketsState = retrieveSetting("enable-websockets"); - if (requestState != null) { - enableHttpRequests.setEnabled(parseBoolean(requestState, true)); - } - if (webSocketsState != null) { - enableWebSockets.setEnabled(parseBoolean(webSocketsState, true)); - } - } - - private boolean parseBoolean(String parse, boolean defaultVal) { - try { - return Boolean.parseBoolean(parse); - } - catch (Exception e) { - return defaultVal; - } - } - - private String retrieveSetting(String key) { - try { - ensureConfigFileExists(); - final Path configPath = new File(CONFIG_DIR).toPath(); - final List lines = Files.readAllLines(configPath); - for (final String line : lines) { - if (line.startsWith(key + SEPARATOR_FULL)) { - return line.substring((key + SEPARATOR_FULL).length()); - } - } - } - catch (IOException ex) {} - return null; - } +package keystrokesmod.script; + +import keystrokesmod.Raven; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.script.model.Entity; +import keystrokesmod.script.model.Image; +import keystrokesmod.script.model.NetworkPlayer; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.profile.ProfileModule; +import org.lwjgl.Sys; + +import java.awt.*; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +public class Manager extends Module { + public static ButtonSetting enableHttpRequests; + public static ButtonSetting enableWebSockets; + + public final String DOCUMENTATION_URL = "https://blowsy.gitbook.io/raven"; + private final String CONFIG_DIR = mc.mcDataDir + File.separator + "keystrokes" + File.separator + "settings.txt"; + private final String SEPARATOR = ":"; + private final String SEPARATOR_FULL = SEPARATOR + " "; + + private long lastLoad = 0; + + public Manager() { + super("Manager", category.scripts); + this.registerSetting(new ButtonSetting("Load scripts", () -> { + if (Raven.scriptManager.compiler == null) { + Utils.sendMessage("&cCompiler error, JDK not found"); + } + else { + final long currentTimeMillis = System.currentTimeMillis(); + if (Utils.timeBetween(this.lastLoad, currentTimeMillis) > 1500) { + this.lastLoad = currentTimeMillis; + Raven.scriptManager.loadScripts(); + if (Raven.scriptManager.scripts.isEmpty()) { + Utils.sendMessage("&7No scripts found."); + } + else { + double timeTaken = Utils.round((System.currentTimeMillis() - currentTimeMillis) / 1000.0, 1); + Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "" : "s") + " in &b" + Utils.asWholeNum(timeTaken) + "&7s."); + } + Entity.clearCache(); + NetworkPlayer.clearCache(); + Image.clearCache(); + ScriptDefaults.reloadModules(); + if (Raven.currentProfile != null && Raven.currentProfile.getModule() != null) { + ((ProfileModule) Raven.currentProfile.getModule()).saved = false; + } + } + else { + Utils.sendMessage("&cYou are on cooldown."); + } + } + })); + this.registerSetting(new ButtonSetting("Open folder", () -> { + try { + Desktop.getDesktop().open(Raven.scriptManager.directory); + } + catch (IOException ex) { + Raven.scriptManager.directory.mkdirs(); + Utils.sendMessage("&cError locating folder, recreated."); + } + })); + this.registerSetting(new ButtonSetting("View documentation", () -> { + try { + Desktop.getDesktop().browse(new URI(DOCUMENTATION_URL)); + } + catch (Throwable t) { + Sys.openURL(DOCUMENTATION_URL); + } + })); + this.registerSetting(new DescriptionSetting("Privacy")); + this.registerSetting(enableHttpRequests = new ButtonSetting("Enable http requests", true)); + this.registerSetting(enableWebSockets = new ButtonSetting("Enable websockets", true)); + this.canBeEnabled = false; + this.ignoreOnSave = true; + + retrieveSettings(); + } + + @Override + public void guiButtonToggled(ButtonSetting s) { + updateSettingFile(); + } + + private boolean updateSettingFile() { + return set("enable-http-requests", String.valueOf(enableHttpRequests.isToggled())) & set("enable-websockets", String.valueOf(enableWebSockets.isToggled())); + } + + private void ensureConfigFileExists() throws IOException { + final Path configPath = Paths.get(CONFIG_DIR); + if (Files.notExists(configPath)) { + Files.createDirectories(configPath.getParent()); + Files.createFile(configPath); + } + } + + private boolean set(String key, String value) { + if (key == null || key.isEmpty()) { + return false; + } + key = key.replace(SEPARATOR, ""); + final String entry = key + SEPARATOR_FULL + value; + try { + ensureConfigFileExists(); + final Path configPath = new File(CONFIG_DIR).toPath(); + final List lines = new ArrayList<>(Files.readAllLines(configPath)); + boolean keyExists = false; + for (int i = 0; i < lines.size(); ++i) { + final String line = lines.get(i); + if (line.startsWith(key + SEPARATOR_FULL)) { + lines.set(i, entry); + keyExists = true; + break; + } + } + if (!keyExists) { + lines.add(entry); + } + Files.write(configPath, lines); + return true; + } + catch (IOException ex) { + return false; + } + } + + private void retrieveSettings() { + String requestState = retrieveSetting("enable-http-requests"); + String webSocketsState = retrieveSetting("enable-websockets"); + if (requestState != null) { + enableHttpRequests.setEnabled(parseBoolean(requestState, true)); + } + if (webSocketsState != null) { + enableWebSockets.setEnabled(parseBoolean(webSocketsState, true)); + } + } + + private boolean parseBoolean(String parse, boolean defaultVal) { + try { + return Boolean.parseBoolean(parse); + } + catch (Exception e) { + return defaultVal; + } + } + + private String retrieveSetting(String key) { + try { + ensureConfigFileExists(); + final Path configPath = new File(CONFIG_DIR).toPath(); + final List lines = Files.readAllLines(configPath); + for (final String line : lines) { + if (line.startsWith(key + SEPARATOR_FULL)) { + return line.substring((key + SEPARATOR_FULL).length()); + } + } + } + catch (IOException ex) {} + return null; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/Script.java b/src/main/java/keystrokesmod/script/Script.java index 3a4d781..e6bc53e 100644 --- a/src/main/java/keystrokesmod/script/Script.java +++ b/src/main/java/keystrokesmod/script/Script.java @@ -1,241 +1,241 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; -import keystrokesmod.utility.Utils; -import net.minecraft.launchwrapper.Launch; - -import javax.tools.StandardJavaFileManager; -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLDecoder; -import java.util.*; - -public class Script { - public String name; - public Class clazz; - public Object instance; - public String scriptName; - public String codeStr; - public boolean error = false; - public int STARTING_LINE; - public ScriptEvents event; - public File file; - - public Script(String name) { - this.name = name; - this.scriptName = "sc_" + name.replace(" ", "").replace(")", "_").replace("(", "_") + "_" + Utils.generateRandomString(5); - } - - public boolean run() { - try { - if (this.scriptName == null || this.codeStr == null) { - return false; - } - final File file = new File(Raven.scriptManager.COMPILED_DIR); - if (!file.exists() || !file.isDirectory()) { - file.mkdir(); - } - if (Raven.scriptManager.compiler == null) { - return false; - } - final ScriptDiagnosticListener bp = new ScriptDiagnosticListener(); - final StandardJavaFileManager fileManager = Raven.scriptManager.compiler.getStandardFileManager(bp, null, null); - final ArrayList compilationOptions = new ArrayList<>(); - compilationOptions.add("-d"); - compilationOptions.add(Raven.scriptManager.COMPILED_DIR); - compilationOptions.add("-XDuseUnsharedTable"); - if (!(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { - compilationOptions.add("-classpath"); - String s = Raven.scriptManager.jarPath; - try { - s = URLDecoder.decode(s, "UTF-8"); - } - catch (UnsupportedOperationException ex2) {} - compilationOptions.add(s); - } - boolean success = Raven.scriptManager.compiler.getTask(null, fileManager, bp, compilationOptions, null, Arrays.asList(new JavaSourceFromString(this.scriptName, this.codeStr, this.STARTING_LINE))).call(); - if (!success) { - this.error = true; - return false; - } - try { - final SecureClassLoader secureClassLoader = new SecureClassLoader(new URL[]{file.toURI().toURL()}, Launch.classLoader); - this.clazz = secureClassLoader.loadClass(this.scriptName); - this.instance = this.clazz.newInstance(); - secureClassLoader.close(); - fileManager.close(); - } - catch (Throwable e) { - e.printStackTrace(); - Utils.sendMessage("&7Script &b" + Utils.extractFileName(this.name) + " &7blocked, &cunsafe code&7 detected!"); - this.error = true; - return false; - } - return true; - } - catch (Exception ex) { - this.error = true; - return !error; - } - } - - public int getBoolean(final String s, final Object... array) { - if (this.clazz == null || this.instance == null) { - return -1; - } - Method method = null; - for (final Method method2 : this.clazz.getDeclaredMethods()) { - if (method2.getName().equalsIgnoreCase(s) && method2.getParameterCount() == array.length && method2.getReturnType().equals(Boolean.TYPE)) { - method = method2; - break; - } - } - if (method != null) { - try { - method.setAccessible(true); - final Object invoke = method.invoke(this.instance, array); - if (invoke instanceof Boolean) { - return ((boolean)invoke) ? 1 : 0; - } - } - catch (IllegalAccessException | InvocationTargetException ex) { - ReflectiveOperationException er = ex; - Utils.sendMessage("&7Runtime error during script &b" + this.name); - if (er.getCause() == null) { - Utils.sendMessage(" &7err: &cThrowable"); - } - else { - Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); - final StackTraceElement[] stArr = er.getCause().getStackTrace(); - if (stArr.length > 0) { - StackTraceElement st = stArr[0]; - for (final StackTraceElement element : er.getCause().getStackTrace()) { - if (element.getClassName().equalsIgnoreCase(this.scriptName)) { - st = element; - break; - } - } - Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); - Utils.sendMessage(" &7src: &c" + st.getMethodName()); - } - } - } - } - return -1; - } - - public Float[] getFloatArray(String methodName, Object... args) { - if (this.clazz == null || this.instance == null) { - return null; - } - Method method = null; - for (Method _method : this.clazz.getDeclaredMethods()) { - if (_method.getName().equals(methodName) && _method.getReturnType().equals(Float[].class) && _method.getParameterCount() == args.length) { - method = _method; - break; - } - } - if (method != null) { - try { - method.setAccessible(true); - Object result = method.invoke(this.instance, args); - if (result instanceof Float[]) { - return (Float[])result; - } - } - catch (IllegalAccessException | InvocationTargetException ex) { - ReflectiveOperationException er = ex; - Utils.sendMessage("&7Runtime error during script &b" + this.name); - if (er.getCause() == null) { - Utils.sendMessage(" &7err: &cThrowable"); - } - else { - Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); - StackTraceElement[] stArr = er.getCause().getStackTrace(); - if (stArr.length > 0) { - StackTraceElement st = stArr[0]; - for (StackTraceElement element : er.getCause().getStackTrace()) { - if (element.getClassName().equalsIgnoreCase(this.scriptName)) { - st = element; - break; - } - } - Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); - Utils.sendMessage(" &7src: &c" + st.getMethodName()); - } - } - } - } - return null; - } - - public void delete() { - this.clazz = null; - this.instance = null; - final File file = new File(Raven.scriptManager.COMPILED_DIR + File.separator + this.scriptName + ".class"); - if (file.exists()) { - file.delete(); - } - } - - public void setCode(String code) { - STARTING_LINE = 0; - StringBuilder fileCodeContents = new StringBuilder(); - Iterator iterator = Raven.scriptManager.imports.iterator(); - while (iterator.hasNext()) { - STARTING_LINE++; - fileCodeContents.append("import ").append(iterator.next()).append(";\n"); - } - fileCodeContents.append("import keystrokesmod.script.model.*;\n"); - fileCodeContents.append("import keystrokesmod.script.packet.clientbound.*;\n"); - fileCodeContents.append("import keystrokesmod.script.packet.serverbound.*;\n"); - String name = Utils.extractFileName(this.name); - this.codeStr = fileCodeContents + "public class " + this.scriptName + " extends " + ScriptDefaults.class.getName() + " {public static final " + ScriptDefaults.modules.class.getName().replace("$", ".") + " modules = new " + ScriptDefaults.modules.class.getName().replace("$", ".") + "(\"" + name + "\");public static final String scriptName = \"" + name + "\";\n" + code + "\n}"; - STARTING_LINE += 4; - } - - public boolean invoke(final String s, final Object... array) { - if (this.clazz == null || this.instance == null) { - return false; - } - Method method = null; - for (final Method method2 : this.clazz.getDeclaredMethods()) { - if (method2.getName().equalsIgnoreCase(s) && method2.getParameterCount() == array.length && method2.getReturnType().equals(Void.TYPE)) { - method = method2; - break; - } - } - if (method != null) { - try { - method.setAccessible(true); - method.invoke(this.instance, array); - return true; - } - catch (IllegalAccessException | InvocationTargetException ex) { - ReflectiveOperationException er = ex; - Utils.sendMessage("&7Runtime error during script &b" + this.name); - if (er.getCause() == null) { - Utils.sendMessage(" &7err: &cThrowable"); - } - else { - Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); - final StackTraceElement[] stArr = er.getCause().getStackTrace(); - if (stArr.length > 0) { - StackTraceElement st = stArr[0]; - for (final StackTraceElement element : er.getCause().getStackTrace()) { - if (element.getClassName().equalsIgnoreCase(this.scriptName)) { - st = element; - break; - } - } - Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); - Utils.sendMessage(" &7src: &c" + st.getMethodName()); - } - } - } - } - return false; - } -} +package keystrokesmod.script; + +import keystrokesmod.Raven; +import keystrokesmod.utility.Utils; +import net.minecraft.launchwrapper.Launch; + +import javax.tools.StandardJavaFileManager; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLDecoder; +import java.util.*; + +public class Script { + public String name; + public Class clazz; + public Object instance; + public String scriptName; + public String codeStr; + public boolean error = false; + public int STARTING_LINE; + public ScriptEvents event; + public File file; + + public Script(String name) { + this.name = name; + this.scriptName = "sc_" + name.replace(" ", "").replace(")", "_").replace("(", "_") + "_" + Utils.generateRandomString(5); + } + + public boolean run() { + try { + if (this.scriptName == null || this.codeStr == null) { + return false; + } + final File file = new File(Raven.scriptManager.COMPILED_DIR); + if (!file.exists() || !file.isDirectory()) { + file.mkdir(); + } + if (Raven.scriptManager.compiler == null) { + return false; + } + final ScriptDiagnosticListener bp = new ScriptDiagnosticListener(); + final StandardJavaFileManager fileManager = Raven.scriptManager.compiler.getStandardFileManager(bp, null, null); + final ArrayList compilationOptions = new ArrayList<>(); + compilationOptions.add("-d"); + compilationOptions.add(Raven.scriptManager.COMPILED_DIR); + compilationOptions.add("-XDuseUnsharedTable"); + if (!(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { + compilationOptions.add("-classpath"); + String s = Raven.scriptManager.jarPath; + try { + s = URLDecoder.decode(s, "UTF-8"); + } + catch (UnsupportedOperationException ex2) {} + compilationOptions.add(s); + } + boolean success = Raven.scriptManager.compiler.getTask(null, fileManager, bp, compilationOptions, null, Arrays.asList(new JavaSourceFromString(this.scriptName, this.codeStr, this.STARTING_LINE))).call(); + if (!success) { + this.error = true; + return false; + } + try { + final SecureClassLoader secureClassLoader = new SecureClassLoader(new URL[]{file.toURI().toURL()}, Launch.classLoader); + this.clazz = secureClassLoader.loadClass(this.scriptName); + this.instance = this.clazz.newInstance(); + secureClassLoader.close(); + fileManager.close(); + } + catch (Throwable e) { + e.printStackTrace(); + Utils.sendMessage("&7Script &b" + Utils.extractFileName(this.name) + " &7blocked, &cunsafe code&7 detected!"); + this.error = true; + return false; + } + return true; + } + catch (Exception ex) { + this.error = true; + return !error; + } + } + + public int getBoolean(final String s, final Object... array) { + if (this.clazz == null || this.instance == null) { + return -1; + } + Method method = null; + for (final Method method2 : this.clazz.getDeclaredMethods()) { + if (method2.getName().equalsIgnoreCase(s) && method2.getParameterCount() == array.length && method2.getReturnType().equals(Boolean.TYPE)) { + method = method2; + break; + } + } + if (method != null) { + try { + method.setAccessible(true); + final Object invoke = method.invoke(this.instance, array); + if (invoke instanceof Boolean) { + return ((boolean)invoke) ? 1 : 0; + } + } + catch (IllegalAccessException | InvocationTargetException ex) { + ReflectiveOperationException er = ex; + Utils.sendMessage("&7Runtime error during script &b" + this.name); + if (er.getCause() == null) { + Utils.sendMessage(" &7err: &cThrowable"); + } + else { + Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); + final StackTraceElement[] stArr = er.getCause().getStackTrace(); + if (stArr.length > 0) { + StackTraceElement st = stArr[0]; + for (final StackTraceElement element : er.getCause().getStackTrace()) { + if (element.getClassName().equalsIgnoreCase(this.scriptName)) { + st = element; + break; + } + } + Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); + Utils.sendMessage(" &7src: &c" + st.getMethodName()); + } + } + } + } + return -1; + } + + public Float[] getFloatArray(String methodName, Object... args) { + if (this.clazz == null || this.instance == null) { + return null; + } + Method method = null; + for (Method _method : this.clazz.getDeclaredMethods()) { + if (_method.getName().equals(methodName) && _method.getReturnType().equals(Float[].class) && _method.getParameterCount() == args.length) { + method = _method; + break; + } + } + if (method != null) { + try { + method.setAccessible(true); + Object result = method.invoke(this.instance, args); + if (result instanceof Float[]) { + return (Float[])result; + } + } + catch (IllegalAccessException | InvocationTargetException ex) { + ReflectiveOperationException er = ex; + Utils.sendMessage("&7Runtime error during script &b" + this.name); + if (er.getCause() == null) { + Utils.sendMessage(" &7err: &cThrowable"); + } + else { + Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); + StackTraceElement[] stArr = er.getCause().getStackTrace(); + if (stArr.length > 0) { + StackTraceElement st = stArr[0]; + for (StackTraceElement element : er.getCause().getStackTrace()) { + if (element.getClassName().equalsIgnoreCase(this.scriptName)) { + st = element; + break; + } + } + Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); + Utils.sendMessage(" &7src: &c" + st.getMethodName()); + } + } + } + } + return null; + } + + public void delete() { + this.clazz = null; + this.instance = null; + final File file = new File(Raven.scriptManager.COMPILED_DIR + File.separator + this.scriptName + ".class"); + if (file.exists()) { + file.delete(); + } + } + + public void setCode(String code) { + STARTING_LINE = 0; + StringBuilder fileCodeContents = new StringBuilder(); + Iterator iterator = Raven.scriptManager.imports.iterator(); + while (iterator.hasNext()) { + STARTING_LINE++; + fileCodeContents.append("import ").append(iterator.next()).append(";\n"); + } + fileCodeContents.append("import keystrokesmod.script.model.*;\n"); + fileCodeContents.append("import keystrokesmod.script.packet.clientbound.*;\n"); + fileCodeContents.append("import keystrokesmod.script.packet.serverbound.*;\n"); + String name = Utils.extractFileName(this.name); + this.codeStr = fileCodeContents + "public class " + this.scriptName + " extends " + ScriptDefaults.class.getName() + " {public static final " + ScriptDefaults.modules.class.getName().replace("$", ".") + " modules = new " + ScriptDefaults.modules.class.getName().replace("$", ".") + "(\"" + name + "\");public static final String scriptName = \"" + name + "\";\n" + code + "\n}"; + STARTING_LINE += 4; + } + + public boolean invoke(final String s, final Object... array) { + if (this.clazz == null || this.instance == null) { + return false; + } + Method method = null; + for (final Method method2 : this.clazz.getDeclaredMethods()) { + if (method2.getName().equalsIgnoreCase(s) && method2.getParameterCount() == array.length && method2.getReturnType().equals(Void.TYPE)) { + method = method2; + break; + } + } + if (method != null) { + try { + method.setAccessible(true); + method.invoke(this.instance, array); + return true; + } + catch (IllegalAccessException | InvocationTargetException ex) { + ReflectiveOperationException er = ex; + Utils.sendMessage("&7Runtime error during script &b" + this.name); + if (er.getCause() == null) { + Utils.sendMessage(" &7err: &cThrowable"); + } + else { + Utils.sendMessage(" &7err: &c" + er.getCause().getClass().getSimpleName()); + final StackTraceElement[] stArr = er.getCause().getStackTrace(); + if (stArr.length > 0) { + StackTraceElement st = stArr[0]; + for (final StackTraceElement element : er.getCause().getStackTrace()) { + if (element.getClassName().equalsIgnoreCase(this.scriptName)) { + st = element; + break; + } + } + Utils.sendMessage(" &7line: &c" + (st.getLineNumber() - STARTING_LINE)); + Utils.sendMessage(" &7src: &c" + st.getMethodName()); + } + } + } + } + return false; + } +} diff --git a/src/main/java/keystrokesmod/script/ScriptDefaults.java b/src/main/java/keystrokesmod/script/ScriptDefaults.java index 4ab1198..c6487c9 100644 --- a/src/main/java/keystrokesmod/script/ScriptDefaults.java +++ b/src/main/java/keystrokesmod/script/ScriptDefaults.java @@ -1,1633 +1,1650 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; -import keystrokesmod.clickgui.ClickGui; -import keystrokesmod.clickgui.components.impl.CategoryComponent; -import keystrokesmod.clickgui.components.impl.ModuleComponent; -import keystrokesmod.helper.RotationHelper; -import keystrokesmod.mixin.impl.accessor.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; -import keystrokesmod.module.setting.Setting; -import keystrokesmod.module.setting.impl.*; -import keystrokesmod.script.model.*; -import keystrokesmod.script.model.Vec3; -import keystrokesmod.script.packet.clientbound.SPacket; -import keystrokesmod.script.packet.serverbound.CPacket; -import keystrokesmod.script.packet.serverbound.PacketHandler; -import keystrokesmod.utility.*; -import keystrokesmod.utility.shader.BlurUtils; -import keystrokesmod.utility.shader.RoundedUtils; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.*; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.resources.ResourcePackRepository; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.ContainerWorkbench; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.network.Packet; -import net.minecraft.realms.RealmsBridge; -import net.minecraft.scoreboard.Team; -import net.minecraft.util.*; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.GL11; -import org.lwjgl.util.glu.GLU; - -import java.io.File; -import java.io.IOException; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.file.*; -import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class ScriptDefaults { - private static ExecutorService cachedExecutor; - private static final Minecraft mc = Minecraft.getMinecraft(); - public static final Bridge bridge = new Bridge(); - private static final LinkedHashMap modulesMap = new LinkedHashMap<>(); - - public static void reloadModules() { - modulesMap.clear(); - for (Module module : Raven.getModuleManager().getModules()) { - modulesMap.put(module.getName(), module); - } - for (Module module : Raven.scriptManager.scripts.values()) { - modulesMap.put(module.getName(), module); - } - } - - public static class client { - public static boolean allowFlying() { - return mc.thePlayer.capabilities.allowFlying; - } - - public static void removePotionEffect(int id) { - if (mc.thePlayer == null) { - return; - } - mc.thePlayer.removePotionEffectClient(id); - } - - public static int getUID() { - return 4; - } - - public static String getUser() { - return "mic"; - } - - public static void addEnemy(String username) { - Utils.addEnemy(username); - } - - public static void addFriend(String username) { - Utils.addFriend(username); - } - - public static void async(final Runnable method) { - if (cachedExecutor == null) { - cachedExecutor = Executors.newCachedThreadPool(); - } - cachedExecutor.execute(method); - } - - public static int getFPS() { - return Minecraft.getDebugFPS(); - } - - public static void chat(String message) { - mc.thePlayer.sendChatMessage(message); - } - - public static void print(String string) { - Utils.sendRawMessage(string); - } - - public static void print(Message component) { - mc.thePlayer.addChatMessage(component.component); - } - - public static void print(Object object) { - String s = String.valueOf(object); - Utils.sendRawMessage(s); - } - - public static boolean isDiagonal() { - return Utils.isDiagonal(false); - } - - public static void setTimer(float timer) { - ((IAccessorMinecraft) mc).getTimer().timerSpeed = timer; - } - - public static boolean isCreative() { - return mc.thePlayer.capabilities.isCreativeMode; - } - - public static void processPacket(SPacket packet) { - packet.packet.processPacket((((IAccessorNetworkManager) (mc.getNetHandler().getNetworkManager())).getPacketListener())); - } - - public static void processPacketNoEvent(SPacket packet) { - PacketUtils.receivePacketNoEvent(packet.packet); - } - - public static String getTitle() { - return ((IAccessorGuiIngame) mc.ingameGUI).getDisplayedTitle(); - } - - public static String getSubTitle() { - return ((IAccessorGuiIngame) mc.ingameGUI).getDisplayedSubTitle(); - } - - public static String getRecordPlaying() { - return ((IAccessorGuiIngame) mc.ingameGUI).getRecordPlaying(); - } - - public static boolean isFlying() { - return mc.thePlayer.capabilities.isFlying; - } - - public static void attack(Entity entity) { - Utils.attackEntity(entity.entity, true, true); - } - - public static boolean isSinglePlayer() { - return mc.isSingleplayer(); - } - - public static boolean isSpectator() { - return mc.thePlayer.isSpectator(); - } - - public static void setFlying(boolean flying) { - mc.thePlayer.capabilities.isFlying = flying; - } - - public static void setJump(boolean jump) { - mc.thePlayer.movementInput.jump = jump; - } - - public static void setJumping(boolean jump) { - mc.thePlayer.setJumping(jump); - } - - public static void setRenderArmPitch(float pitch) { - mc.thePlayer.prevRenderArmPitch = pitch; - mc.thePlayer.renderArmPitch = pitch; - } - - public static float getEquippedProgress() { - return ((IAccessorItemRenderer) mc.getItemRenderer()).getEquippedProgress(); - } - - public static void disconnect() { - boolean isLocal = mc.isIntegratedServerRunning(); - boolean isRealms = mc.isConnectedToRealms(); - mc.theWorld.sendQuittingDisconnectingPacket(); - mc.loadWorld(null); - if (isLocal) { - mc.displayGuiScreen(new GuiMainMenu()); - return; - } - if (isRealms) { - new RealmsBridge().switchToRealms(new GuiMainMenu()); - return; - } - mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu())); - } - - public static float getRenderArmPitch() { - return mc.thePlayer.renderArmPitch; - } - - public static void setRenderArmYaw(float yaw) { - mc.thePlayer.prevRenderArmYaw = yaw; - mc.thePlayer.renderArmYaw = yaw; - } - - public static float getRenderArmYaw() { - return mc.thePlayer.renderArmYaw; - } - - public static long getTotalMemory() { - return Runtime.getRuntime().totalMemory(); - } - - public static long getFreeMemory() { - return Runtime.getRuntime().freeMemory(); - } - - public static long getMaxMemory() { - return Runtime.getRuntime().maxMemory(); - } - - public static List getResourcePacks() { - List packs = new ArrayList<>(); - if (mc.getResourcePackRepository().getRepositoryEntries() == null || mc.getResourcePackRepository().getRepositoryEntries().isEmpty()) { - packs.add(new String[] { mc.mcDefaultResourcePack.getPackName(), "" } ); - } - else { - for (ResourcePackRepository.Entry entry : mc.getResourcePackRepository().getRepositoryEntries()) { - packs.add(new String[] { entry.getResourcePackName(), entry.getTexturePackDescription() } ); - } - } - Collections.reverse(packs); // reverse it to match the correct order - return packs; - } - - public static void jump() { - mc.thePlayer.jump(); - } - - public static boolean allowEditing() { - if (mc.thePlayer == null || mc.thePlayer.capabilities == null) { - return false; - } - return mc.thePlayer.capabilities.allowEdit; - } - - public static void setItemInUseCount(int count) { - ((IAccessorEntityPlayer) mc.thePlayer).setItemInUseCount(count); - } - - public static int getItemInUseCount() { - return mc.thePlayer.getItemInUseCount(); - } - - public static int getItemInUseDuration() { - return mc.thePlayer.getItemInUseDuration(); - } - - public static void log(final Object obj) { - Utils.log.info(obj); - } - - public static void setSneaking(boolean sneak) { - mc.thePlayer.setSneaking(sneak); - } - - public static void setSneak(boolean sneak) { - mc.thePlayer.movementInput.sneak = sneak; - } - - public static boolean isSneak() { - return mc.thePlayer.movementInput.sneak; - } - - public static Entity getPlayer() { - if (mc == null || mc.thePlayer == null) { - return null; - } - return Entity.convert(mc.thePlayer); - } - - public static void removeEnemy(String username) { - Utils.removeEnemy(username); - } - - public static void removeFriend(String username) { - Utils.removeFriend(username); - } - - public static boolean isRiding() { - return mc.thePlayer.isRiding(); - } - - public static Vec3 getMotion() { - return new Vec3(mc.thePlayer.motionX, mc.thePlayer.motionY, mc.thePlayer.motionZ); - } - - public static void sleep(long ms) { - try { - Thread.sleep(ms); - } - catch (InterruptedException ignored) {} - } - - public static void ping() { - mc.thePlayer.playSound("note.pling", 1.0f, 1.0f); - } - - public static void playSound(String name, float volume, float pitch) { - mc.thePlayer.playSound(name, volume, pitch); - } - - public static boolean isMoving() { - return Utils.isMoving(); - } - - public static boolean isJump() { - return mc.thePlayer.movementInput.jump; - } - - public static float getStrafe() { - return mc.thePlayer.movementInput.moveStrafe; - } - - public static void sleep(int ms) { - try { - Thread.sleep(ms); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - public static String getTabHeader() { - if (mc == null || mc.ingameGUI == null || mc.ingameGUI.getTabList() == null) { - return ""; - } - IChatComponent header = ((IAccessorGuiPlayerTabOverlay) mc.ingameGUI.getTabList()).getHeader(); - if (header != null) { - return header.getUnformattedText(); - } - return ""; - } - - public static String getTabFooter() { - if (mc == null || mc.ingameGUI == null || mc.ingameGUI.getTabList() == null) { - return ""; - } - IChatComponent footer = ((IAccessorGuiPlayerTabOverlay) mc.ingameGUI.getTabList()).getFooter(); - if (footer != null) { - return footer.getUnformattedText(); - } - return ""; - } - - public static float getForward() { - return mc.thePlayer.movementInput.moveForward; - } - - public static void closeScreen() { - if (mc.currentScreen instanceof ClickGui) { - mc.displayGuiScreen(null); - return; - } - mc.thePlayer.closeScreen(); - } - - public static String getScreen() { - return mc.currentScreen == null ? "" : mc.currentScreen.getClass().getSimpleName(); - } - - public static float[] getRotationsToEntity(Entity entity) { - return RotationUtils.getRotations(entity.entity); - } - - public static void sendPacket(CPacket packet) { - Packet packet1 = PacketHandler.convertCPacket(packet); - if (packet1 == null) { - return; - } - mc.thePlayer.sendQueue.addToSendQueue(packet1); - } - - public static void sendPacketNoEvent(CPacket packet) { - Packet packet1 = PacketHandler.convertCPacket(packet); - if (packet1 == null) { - return; - } - PacketUtils.sendPacketNoEvent(packet1); - } - - public static boolean inFocus() { - return mc.inGameHasFocus; - } - - public static void dropItem(boolean dropStack) { - mc.thePlayer.dropOneItem(dropStack); - } - - public static void setMotion(double x, double y, double z) { - mc.thePlayer.motionX = x; - mc.thePlayer.motionY = y; - mc.thePlayer.motionZ = z; - } - - public static void setSpeed(double speed) { - Utils.setSpeed(speed); - } - - public static void setForward(float forward) { - mc.thePlayer.movementInput.moveForward = forward; - } - - public static void setStrafe(float strafe) { - mc.thePlayer.movementInput.moveStrafe = strafe; - } - - public static String getServerIP() { - if (mc.getCurrentServerData() == null || mc.isSingleplayer()) { - return ""; - } - return mc.getCurrentServerData().serverIP; - } - - public static int[] getDisplaySize() { - final ScaledResolution scaledResolution = new ScaledResolution(mc); - return new int[]{scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; - } - - public static float getServerDirection(PlayerState state) { - return state.yaw; - } - - public static Object[] raycastBlock(final double distance) { - return raycastBlock(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); - } - - public static Object[] raycastBlock(final double distance, final float yaw, final float pitch) { - final net.minecraft.util.Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); - final net.minecraft.util.Vec3 lookVec = Utils.getLookVec(yaw, pitch); - final net.minecraft.util.Vec3 sumVec = eyeVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance); - final MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(eyeVec, sumVec, false, false, false); - if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { - return null; - } - final Vec3 pos = new Vec3(mop.getBlockPos()); - final Vec3 offset = new Vec3(mop.hitVec.xCoord - pos.x, mop.hitVec.yCoord - pos.y, mop.hitVec.zCoord - pos.z); - return new Object[] { pos, offset, mop.sideHit.name() }; - } - - public static Object[] raycastEntity(final double distance) { - return raycastEntity(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); - } - - public static Object[] raycastEntity(final double distance, final float yaw, final float pitch) { - net.minecraft.entity.Entity pointedEntity = null; - MovingObjectPosition mop = mc.thePlayer.rayTrace(distance, 1.0f); - final net.minecraft.util.Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); - final net.minecraft.util.Vec3 lookVec = Utils.getLookVec(yaw, pitch); - final net.minecraft.util.Vec3 vec32 = eyeVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance); - net.minecraft.util.Vec3 vec33 = null; - final List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), mc.getRenderViewEntity().getEntityBoundingBox().addCoord(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance).expand(1.0, 1.0, 1.0)); - double d2 = distance; - for (int i = 0; i < list.size(); ++i) { - final net.minecraft.entity.Entity entity = (net.minecraft.entity.Entity) list.get(i); - if (entity instanceof EntityLivingBase && entity.canBeCollidedWith()) { - if (((EntityLivingBase)entity).deathTime == 0) { - final float cbs = entity.getCollisionBorderSize(); - final AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand((double)cbs, (double)cbs, (double)cbs); - final MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(eyeVec, vec32); - if (axisalignedbb.isVecInside(eyeVec)) { - if (0.0 < d2 || d2 == 0.0) { - pointedEntity = entity; - vec33 = ((movingobjectposition == null) ? eyeVec : movingobjectposition.hitVec); - d2 = 0.0; - } - } - else if (movingobjectposition != null) { - final double d3 = eyeVec.distanceTo(movingobjectposition.hitVec); - if (d3 < d2 || d2 == 0.0) { - if (entity == mc.getRenderViewEntity().ridingEntity && !entity.canRiderInteract()) { - if (d2 == 0.0) { - pointedEntity = entity; - vec33 = movingobjectposition.hitVec; - } - } - else { - pointedEntity = entity; - vec33 = movingobjectposition.hitVec; - d2 = d3; - } - } - } - } - } - } - if (pointedEntity != null && (d2 < distance || mop == null)) { - mop = new MovingObjectPosition(pointedEntity, vec33); - final Vec3 offset = new Vec3(mop.hitVec.xCoord - pointedEntity.posX, mop.hitVec.yCoord - pointedEntity.posY, mop.hitVec.zCoord - pointedEntity.posZ); - return new Object[] { new Entity(mop.entityHit), offset, eyeVec.squareDistanceTo(mop.hitVec) }; - } - return null; - } - - public static boolean placeBlock(Vec3 targetPos, String side, Vec3 hitVec) { - return mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem(), Vec3.getBlockPos(targetPos), Utils.getEnum(EnumFacing.class, side), Vec3.getVec3(hitVec)); - } - - public static void enableMovementFix() { - RotationHelper.get().forceMovementFix = true; - } - - public static float[] getRotationsToBlock(Vec3 position) { - return RotationUtils.getRotations(new BlockPos(position.x, position.y, position.z)); - } - - public static void setSprinting(boolean sprinting) { - mc.thePlayer.setSprinting(sprinting); - } - - public static void swing() { - mc.thePlayer.swingItem(); - } - - public static long time() { - return System.currentTimeMillis(); - } - - public static boolean isFriend(String username) { - return Utils.isFriended(username); - } - - public static boolean isEnemy(String username) { - return Utils.isEnemy(username); - } - } - - public static class world { - public static Block getBlockAt(int x, int y, int z) { - IBlockState state = BlockUtils.getBlockState(new BlockPos(x, y, z)); - if (state == null) { - return new Block(Blocks.air, new BlockPos(x, y, z)); - } - return new Block(state, new BlockPos(x, y, z)); - } - - public static Block getBlockAt(Vec3 pos) { - IBlockState state = BlockUtils.getBlockState(new BlockPos(pos.x, pos.y, pos.z)); - if (state == null) { - return new Block(Blocks.air, new BlockPos(pos.x, pos.y, pos.z)); - } - return new Block(state, new BlockPos(pos.x, pos.y, pos.z)); - } - - public static String getDimension() { - if (mc.theWorld == null) { - return ""; - } - return mc.theWorld.provider.getDimensionName(); - } - - public static List getEntities() { - List entities = new ArrayList<>(); - if (mc.theWorld == null) { - return entities; - } - for (net.minecraft.entity.Entity entity : mc.theWorld.loadedEntityList) { - entities.add(Entity.convert(entity)); - } - return entities; - } - - public static Entity getEntityById(int entityId) { - if (mc.theWorld == null) { - return null; - } - return Entity.convert(mc.theWorld.getEntityByID(entityId)); - } - - public static List getNetworkPlayers() { - List entities = new ArrayList<>(); - for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(false)) { - entities.add(NetworkPlayer.convert(networkPlayerInfo)); - } - return entities; - } - - public static List getPlayerEntities() { - List entities = new ArrayList<>(); - for (net.minecraft.entity.Entity entity : mc.theWorld.playerEntities) { - entities.add(Entity.convert(entity)); - } - return entities; - } - - public static List getScoreboard() { - List sidebarLines = Utils.getSidebarLines(); - if (sidebarLines.isEmpty()) { - return null; - } - return sidebarLines; - } - - public static Map> getTeams() { - Map> teams = new HashMap<>(); - for (Team team : mc.theWorld.getScoreboard().getTeams()) { - List members = new ArrayList<>(); - for (String member : team.getMembershipCollection()) { - members.add(member); - } - teams.put(team.getRegisteredName(), members); - } - return teams; - } - - public static List getTileEntities() { - List tileEntities = new ArrayList<>(); - for (net.minecraft.tileentity.TileEntity entity : mc.theWorld.loadedTileEntityList) { - tileEntities.add(new TileEntity(entity)); - } - return tileEntities; - } - } - - public static class modules { - private String superName; - - public modules(String superName) { - this.superName = superName; - } - - private static Module getModule(String moduleName) { - return modulesMap.get(moduleName); - } - - private static Module getScript(String name) { - return modulesMap.get(name); - } - - private static Setting getSetting(Module module, String settingName) { - if (module == null) { - return null; - } - for (Setting setting : module.getSettings()) { - if (setting.getName().equals(settingName)) { - return setting; - } - } - return null; - } - - private GroupSetting getGroupForString(String group) { - if (group.isEmpty()) { - return null; - } - List settings = getScript(this.superName).getSettings(); - for (Setting setting : settings) { - if (!(setting instanceof GroupSetting)) { - continue; - } - if (setting.getName().equals(group)) { - return (GroupSetting) setting; - } - } - return null; - } - - public void enable(String moduleName) { - if (getModule(moduleName) == null) { - return; - } - getModule(moduleName).enable(); - } - - public void disable(String moduleName) { - if (getModule(moduleName) == null) { - return; - } - getModule(moduleName).disable(); - } - - public boolean isEnabled(String moduleName) { - if (getModule(moduleName) == null) { - return false; - } - return getModule(moduleName).isEnabled(); - } - - public Entity getKillAuraTarget() { - if (KillAura.target == null) { - return null; - } - return Entity.convert(KillAura.target); - } - - public Map getSettings(String name) { - Map settings = new HashMap<>(); - Module module = getModule(name); - if (module == null) { - return settings; - } - for (Setting setting : module.getSettings()) { - if (setting instanceof SliderSetting) { - settings.put(setting.getName(), ((SliderSetting) setting).getInput()); - } - else if (setting instanceof ButtonSetting) { - settings.put(setting.getName(), ((ButtonSetting) setting).isToggled()); - } - } - return settings; - } - - public Map> getCategories() { - Map> categories = new HashMap<>(); - for (CategoryComponent categoryComponent : ClickGui.categories) { - List modules = new ArrayList<>(); - for (ModuleComponent module : categoryComponent.modules) { - modules.add(module.mod.getName()); - } - categories.put(categoryComponent.category.name(), modules); - } - return categories; - } - - public Vec3 getBedAuraPosition() { - BlockPos blockPos = ModuleManager.bedAura.currentBlock; - if (ModuleManager.bedAura == null || !ModuleManager.bedAura.isEnabled() || ModuleManager.bedAura.currentBlock == null) { - return null; - } - return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - } - - public boolean isScaffolding() { - return ModuleManager.scaffold.isEnabled(); - } - - public boolean isTowering() { - return ModuleManager.tower.canTower(); - } - - public boolean isHidden(String moduleName) { - Module module = getModule(moduleName); - if (module != null) { - return module.isHidden(); - } - return false; - } - - public float[] getBedAuraProgress() { - if (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled()) { - return new float[]{ModuleManager.bedAura.breakProgress, ModuleManager.bedAura.vanillaProgress}; - } - return new float[]{0, 0}; - } - - public void registerGroup(String name) { - getScript(this.superName).registerSetting(new GroupSetting(name)); - } - - public void registerButton(String name, boolean defaultValue) { - getScript(this.superName).registerSetting(new ButtonSetting(name, defaultValue)); - } - - public void registerButton(String group, String name, boolean defaultValue) { - getScript(this.superName).registerSetting(new ButtonSetting(getGroupForString(group), name, defaultValue)); - } - - public void registerKey(String group, String name, int defaultKey) { - getScript(this.superName).registerSetting(new KeySetting(getGroupForString(group), name, defaultKey)); - } - - public void registerKey(String name, int defaultKey) { - getScript(this.superName).registerSetting(new KeySetting(name, defaultKey)); - } - - // main slider constructors - - public void registerSlider(String group, String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { - getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, minimum, maximum, interval)); - } - - public void registerSlider(String group, String name, String suffix, int defaultValue, String[] stringArray) { - getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, stringArray)); - } - - // rest - - public void registerSlider(String name, double defaultValue, double minimum, double maximum, double interval) { - this.registerSlider("", name, "", defaultValue, minimum, maximum, interval); - } - - public void registerSlider(String name, int defaultValue, String[] stringArray) { - this.registerSlider("", name, "", defaultValue, stringArray); - } - - public void registerSlider(String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { - this.registerSlider("", name, suffix, defaultValue, minimum, maximum, interval); - } - - public void registerSlider(String name, String suffix, int defaultValue, String[] stringArray) { - this.registerSlider("", name, suffix, defaultValue, stringArray); - } - - public void registerDescription(String description) { - getScript(this.superName).registerSetting(new DescriptionSetting(description)); - } - - public boolean getButton(String moduleName, String name) { - ButtonSetting setting = (ButtonSetting) getSetting(getModule(moduleName), name); - if (setting == null) { - return false; - } - boolean buttonState = setting.isToggled(); - return buttonState; - } - - public double getSlider(String moduleName, String name) { - SliderSetting setting = ((SliderSetting) getSetting(getModule(moduleName), name)); - if (setting == null) { - return 0; - } - double sliderValue = setting.getInput(); - return sliderValue; - } - - public boolean getKeyPressed(String moduleName, String name) { - KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); - if (setting == null) { - return false; - } - return setting.isPressed(); - } - - public void setButton(String moduleName, String name, boolean value) { - ButtonSetting setting = (ButtonSetting) getSetting(getModule(moduleName), name); - if (setting == null) { - return; - } - setting.setEnabled(value); - } - - public void setSlider(String moduleName, String name, double value) { - SliderSetting setting = ((SliderSetting) getSetting(getModule(moduleName), name)); - if (setting == null) { - return; - } - setting.setValueRawWithEvent(value); - } - - public void setKey(String moduleName, String name, int code) { - KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); - if (setting == null) { - return; - } - setting.setKey(code); - } - } - - public static class gl { - public static void alpha(boolean alpha) { - if (alpha) { - GlStateManager.enableAlpha(); - } - else { - GlStateManager.disableAlpha(); - } - } - - public static void begin(int mode) { - GL11.glBegin(mode); - } - - public static void blend(boolean blend) { - if (blend) { - GlStateManager.enableBlend(); - } - else { - GlStateManager.disableBlend(); - } - } - - public static void color(float r, float g, float b, float a) { - GlStateManager.color(r, g, b, a); - } - - public static void cull(boolean cull) { - if (cull) { - GlStateManager.enableCull(); - } - else { - GlStateManager.disableCull(); - } - } - - public static void depth(boolean depth) { - if (depth) { - GlStateManager.enableDepth(); - } - else { - GlStateManager.disableDepth(); - } - } - - public static void depthMask(boolean depthMask) { - GlStateManager.depthMask(depthMask); - } - - public static void disable(int cap) { - GL11.glDisable(cap); - } - - public static void disableItemLighting() { - RenderHelper.disableStandardItemLighting(); - } - - public static void enable(int cap) { - GL11.glEnable(cap); - } - - public static void enableItemLighting(boolean gui) { - if (gui) { - RenderHelper.enableGUIStandardItemLighting(); - } - else { - RenderHelper.enableStandardItemLighting(); - } - } - - public static void end() { - GL11.glEnd(); - } - - public static void lighting(boolean lighting) { - if (lighting) { - GlStateManager.enableLighting(); - } - else { - GlStateManager.disableLighting(); - } - } - - public static void lineSmooth(boolean lineSmooth) { - setGLEnable(GL11.GL_LINE_SMOOTH, lineSmooth); - } - - public static void lineWidth(float width) { - GL11.glLineWidth(width); - } - - public static void normal(float x, float y, float z) { - GL11.glNormal3f(x, y, z); - } - - public static void pop() { - GL11.glPopMatrix(); - } - - public static void push() { - GL11.glPushMatrix(); - } - - public static void rotate(float angle, float x, float y, float z) { - GL11.glRotatef(angle, x, y, z); - } - - public static void scale(float x, float y, float z) { - GL11.glScalef(x, y, z); - } - - public static void scissor(int x, int y, int width, int height) { - GL11.glScissor(x, y, width, height); - } - - public static void scissor(boolean scissor) { - setGLEnable(GL11.GL_SCISSOR_TEST, scissor); - } - - public static void texture2d(boolean texture2d) { - if (texture2d) { - GlStateManager.enableTexture2D(); - } - else { - GlStateManager.disableTexture2D(); - } - } - - public static void translate(float x, float y, float z) { - GL11.glTranslatef(x, y, z); - } - - public static void vertex2(float x, float y) { - GL11.glVertex2f(x, y); - } - - public static void vertex3(float x, float y, float z) { - GL11.glVertex3f(x, y, z); - } - - private static void setGLEnable(int cap, boolean enable) { - if (enable) { - GL11.glEnable(cap); - } - else { - GL11.glDisable(cap); - } - } - } - - public static class config { - private static String CONFIG_DIR = mc.mcDataDir + File.separator + "keystrokes" + File.separator + "script_config.txt"; - private static String SEPARATOR = ":"; - private static String SEPARATOR_FULL = SEPARATOR + " "; - - private static void ensureConfigFileExists() throws IOException { - final Path configPath = Paths.get(config.CONFIG_DIR); - if (Files.notExists(configPath)) { - Files.createDirectories(configPath.getParent()); - Files.createFile(configPath); - } - } - - public static boolean set(String key, final String value) { - if (key == null || key.isEmpty()) { - return false; - } - key = key.replace(SEPARATOR, ""); - final String entry = key + config.SEPARATOR_FULL + value; - try { - ensureConfigFileExists(); - final Path configPath = new File(config.CONFIG_DIR).toPath(); - final List lines = new ArrayList<>(Files.readAllLines(configPath)); - boolean keyExists = false; - for (int i = 0; i < lines.size(); ++i) { - final String line = lines.get(i); - if (line.startsWith(key + config.SEPARATOR_FULL)) { - lines.set(i, entry); - keyExists = true; - break; - } - } - if (!keyExists) { - lines.add(entry); - } - Files.write(configPath, lines); - return true; - } - catch (IOException ex) { - return false; - } - } - - public static String get(final String key) { - if (key == null || key.isEmpty()) { - return null; - } - try { - ensureConfigFileExists(); - final Path configPath = new File(config.CONFIG_DIR).toPath(); - final List lines = Files.readAllLines(configPath); - for (final String line : lines) { - if (line.startsWith(key + config.SEPARATOR_FULL)) { - return line.substring((key + config.SEPARATOR_FULL).length()); - } - } - } - catch (IOException ex) {} - return null; - } - } - - public static class render { - private static final IntBuffer VIEWPORT = GLAllocation.createDirectIntBuffer(16); - private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16); - private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16); - private static final FloatBuffer SCREEN_COORDS = GLAllocation.createDirectFloatBuffer(3); - - public static void block(Vec3 position, int color, boolean outline, boolean shade) { - RenderUtils.renderBlock(new BlockPos(position.x, position.y, position.z), color, outline, shade); - } - - public static void block(int x, int y, int z, int color, boolean outline, boolean shade) { - RenderUtils.renderBlock(new BlockPos(x, y, z), color, outline, shade); - } - - public static void entity(Entity en, int color, float partialTicks, boolean outline, boolean shade) { - net.minecraft.entity.Entity e = en.entity; - double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; - double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY; - double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; - AxisAlignedBB bbox = e.getEntityBoundingBox().expand(0.1, 0.1, 0.1); - AxisAlignedBB axis = new AxisAlignedBB(bbox.minX - e.posX + x, bbox.minY - e.posY + y, bbox.minZ - e.posZ + z, bbox.maxX - e.posX + x, bbox.maxY - e.posY + y, bbox.maxZ - e.posZ + z); - GL11.glPushMatrix(); - GL11.glBlendFunc(770, 771); - GL11.glEnable(3042); - GL11.glDisable(3553); - GL11.glDisable(2929); - GL11.glDepthMask(false); - GL11.glLineWidth(2.0f); - float a = (color >> 24 & 0xFF) / 255.0f; - float r = (color >> 16 & 0xFF) / 255.0f; - float g = (color >> 8 & 0xFF) / 255.0f; - float b = (color & 0xFF) / 255.0f; - GL11.glColor4f(r, g, b, a); - if (outline) { - RenderGlobal.drawSelectionBoundingBox(axis); - } - if (shade) { - RenderUtils.drawBoundingBox(axis, r, g, b); - } - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDepthMask(true); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - - public static void entityGui(Entity en, int x, int y, float mouseX, float mouseY, int scale) { - if (!en.isLiving) { - return; - } - GL11.glPushMatrix(); - GuiInventory.drawEntityOnScreen(x, y, scale, mouseX, mouseY, (EntityLivingBase) en.entity); - GL11.glPopMatrix(); - } - - public static void resetEquippedProgress() { - mc.getItemRenderer().resetEquippedProgress(); - } - - public static void tracer(Entity entity, float lineWidth, int color, float partialTicks) { - RenderUtils.drawTracerLine(entity.entity, color, lineWidth, partialTicks); - } - - public static void showGui() { - mc.displayGuiScreen(new EmptyGuiScreen()); - } - - private static class EmptyGuiScreen extends GuiScreen { - } - - public static void item(ItemStack item, float x, float y, float scale) { - mc.entityRenderer.setupOverlayRendering(); - GlStateManager.pushMatrix(); - if (scale != 1.0f) { - GlStateManager.scale(scale, scale, scale); - } - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.disableBlend(); - GlStateManager.translate(x / scale, y / scale, 0); - mc.getRenderItem().renderItemIntoGUI(item.itemStack, 0, 0); - GlStateManager.enableBlend(); - RenderHelper.disableStandardItemLighting(); - if (scale != 1.0f) { - GlStateManager.scale(scale, scale, scale); - } - GlStateManager.popMatrix(); - } - - public static void image(Image image, float x, float y, float width, float height) { - if (image == null || !image.isLoaded()) { - return; - } - if (image.textureId == -1) { - final DynamicTexture dynamicTexture = new DynamicTexture(image.bufferedImage); - GL11.glTexParameteri(3553, 10240, 9728); - dynamicTexture.updateDynamicTexture(); - image.textureId = dynamicTexture.getGlTextureId(); - } - GlStateManager.pushMatrix(); - GlStateManager.enableTexture2D(); - GlStateManager.bindTexture(image.textureId); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GL11.glTexParameteri(3553, 10240, 9728); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x, (y + height), 0.0).tex(0.0, 1.0).color(255, 255, 255, 255).endVertex(); - worldrenderer.pos((x + width), (y + height), 0.0).tex(1.0, 1.0).color(255, 255, 255, 255).endVertex(); - worldrenderer.pos((x + width), y, 0.0).tex(1.0, 0.0).color(255, 255, 255, 255).endVertex(); - worldrenderer.pos(x, y, 0.0).tex(0.0, 0.0).color(255, 255, 255, 255).endVertex(); - tessellator.draw(); - GlStateManager.popMatrix(); - } - - public static Vec3 worldToScreen(double x, double y, double z, int scaleFactor, float partialTicks) { - x -= mc.getRenderManager().viewerPosX; - y -= mc.getRenderManager().viewerPosY; - z -= mc.getRenderManager().viewerPosZ; - ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); - GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, MODELVIEW); - GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, PROJECTION); - GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT); - if (GLU.gluProject((float)x, (float)y, (float)z, render.MODELVIEW, render.PROJECTION, render.VIEWPORT, render.SCREEN_COORDS)) { - Vec3 vec = new Vec3(render.SCREEN_COORDS.get(0) / scaleFactor, (Display.getHeight() - render.SCREEN_COORDS.get(1)) / scaleFactor, render.SCREEN_COORDS.get(2)); - mc.entityRenderer.setupOverlayRendering(); - return vec; - } - return null; - } - - public static void roundedRect(float startX, float startY, float endX, float endY, float radius, int color) { - RoundedUtils.drawRoundedRectRise(startX, startY, Math.abs(startX - endX), Math.abs(startY - endY), radius, color); - } - - public static void gradientRect(float startX, float startY, float endX, float endY, int leftColor, int rightColor) { - gradientRect(startX, startY, endX, endY, leftColor, leftColor, rightColor, rightColor); - } - - public static void gradientRect(float startX, float startY, float endX, float endY, int topLeftColor, int bottomLeftColor, int topRightColor, int bottomRightColor) { - RenderUtils.drawRoundedGradientRect(startX, startY, endX, endY, 0, topLeftColor, bottomLeftColor, topRightColor, bottomRightColor); - } - - public static double[] getRotations() { - return new double[] { mc.getRenderManager().playerViewY, mc.getRenderManager().playerViewX }; - } - - public static double[] getCameraRotations() { - return new double[] { Utils.getCameraYaw(), Utils.getCameraPitch() }; - } - - public static int getFontWidth(String text) { - return mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text); - } - - public static int getFontHeight() { - return mc.fontRendererObj.FONT_HEIGHT; - } - - public static Vec3 getPosition() { - net.minecraft.util.Vec3 position = Utils.getCameraPos(((IAccessorMinecraft) mc).getTimer().renderPartialTicks); - return new Vec3(position); - } - - public static void text2d(String text, float x, float y, float scale, int color, boolean shadow) { - GlStateManager.pushMatrix(); - if (scale != 1.0f) { - GlStateManager.scale(scale, scale, scale); - } - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - mc.fontRendererObj.drawString(text, x / scale, y / scale, color, shadow); - GlStateManager.disableBlend(); - if (scale != 1.0f) { - GlStateManager.scale(1.0f, 1.0f, 1.0f); - } - GlStateManager.popMatrix(); - } - - public static void text3d(String text, Vec3 position, float scale, boolean shadow, boolean depth, boolean background, int color) { - ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); - GlStateManager.pushMatrix(); - float partialTicks = ((IAccessorMinecraft) mc).getTimer().renderPartialTicks; - double px = mc.thePlayer.prevPosX + (mc.thePlayer.posX - mc.thePlayer.prevPosX) * partialTicks; - double py = mc.thePlayer.prevPosY + (mc.thePlayer.posY - mc.thePlayer.prevPosY) * partialTicks; - double pz = mc.thePlayer.prevPosZ + (mc.thePlayer.posZ - mc.thePlayer.prevPosZ) * partialTicks; - GlStateManager.translate((float)position.x - px, (float)position.y - py, (float)position.z - pz); - GL11.glNormal3f(0.0F, 1.0F, 0.0F); - GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); - float f1 = 0.02666667F; - GlStateManager.scale(-f1, -f1, f1); - if (depth) { - GlStateManager.depthMask(false); - GlStateManager.disableDepth(); - } - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (background) { - GlStateManager.disableTexture2D(); - int width = mc.fontRendererObj.getStringWidth(text); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos(-1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldrenderer.pos(-1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldrenderer.pos(width + 1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldrenderer.pos(width + 1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - } - if (scale != 1) { - GlStateManager.scale(scale, scale, scale); - } - mc.fontRendererObj.drawString(text, 0, 0, color, shadow); - if (scale != 1) { - GlStateManager.scale(1, 1, 1); - } - if (depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.disableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - } - - public static void rect(float startX, float startY, float endX, float endY, final int color) { - if (startX < endX) { - final float i = startX; - startX = endX; - endX = i; - } - if (startY < endY) { - final float j = startY; - startY = endY; - endY = j; - } - final float f3 = (color >> 24 & 0xFF) / 255.0f; - final float f4 = (color >> 16 & 0xFF) / 255.0f; - final float f5 = (color >> 8 & 0xFF) / 255.0f; - final float f6 = (color & 0xFF) / 255.0f; - final Tessellator tessellator = Tessellator.getInstance(); - final WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GL11.glPushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(f4, f5, f6, f3); - worldrenderer.begin(7, DefaultVertexFormats.POSITION); - worldrenderer.pos((double)startX, (double)endY, 0.0).endVertex(); - worldrenderer.pos((double)endX, (double)endY, 0.0).endVertex(); - worldrenderer.pos((double)endX, (double)startY, 0.0).endVertex(); - worldrenderer.pos((double)startX, (double)startY, 0.0).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GL11.glPopMatrix(); - } - - public static void line2D(double startX, double startY, double endX, double endY, float lineWidth, int color) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LINE_SMOOTH); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - RenderUtils.glColor(color); - GL11.glLineWidth(lineWidth); - GL11.glBegin(GL11.GL_LINES); - GL11.glVertex2d(startX, startY); - GL11.glVertex2d(endX, endY); - GL11.glEnd(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - GL11.glPopMatrix(); - } - - public static void line3D(Vec3 pos1, Vec3 pos2, float lineWidth, int color) { - line3D(pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z, lineWidth, color); - } - - public static void line3D(final double startX, final double startY, final double startZ, double endX, double endY, double endZ, final float lineWidth, final int color) { - endX -= mc.getRenderManager().viewerPosX; - endY -= mc.getRenderManager().viewerPosY; - endZ -= mc.getRenderManager().viewerPosZ; - final float a = (color >> 24 & 0xFF) / 255.0f; - final float r = (color >> 16 & 0xFF) / 255.0f; - final float g = (color >> 8 & 0xFF) / 255.0f; - final float b = (color & 0xFF) / 255.0f; - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glEnable(2848); - GL11.glDisable(2929); - GL11.glDisable(3553); - GL11.glBlendFunc(770, 771); - GL11.glLineWidth(lineWidth); - GlStateManager.color(r, g, b, a); - GL11.glBegin(2); - GL11.glVertex3d(startX - mc.thePlayer.posX, startY - mc.thePlayer.posY, startZ - mc.thePlayer.posZ); - GL11.glVertex3d(endX, endY, endZ); - GL11.glEnd(); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GL11.glEnable(3553); - GL11.glEnable(2929); - GL11.glDisable(2848); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - - public static boolean isInView(Entity en) { - return RenderUtils.isInViewFrustum(en.entity); - } - - public static class blur { - public static void prepare() { - BlurUtils.prepareBlur(); - } - - public static void apply(final int passes, final float radius) { - BlurUtils.blurEnd(passes, radius); - } - } - - public static class bloom { - public static void prepare() { - BlurUtils.prepareBloom(); - } - - public static void apply(final int passes, final float radius) { - BlurUtils.bloomEnd(passes, radius); - } - } - } - - public static class inventory { - public static int getSlot() { - return mc.thePlayer.inventory.currentItem; - } - - public static void setSlot(int slot) { - mc.thePlayer.inventory.currentItem = slot; - } - - public static void click(int slot, int button, int mode) { - mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot, button, mode, mc.thePlayer); - } - - public static List getBookContents() { - if (mc.currentScreen instanceof GuiScreenBook) { - List contents = new ArrayList<>(); - List bookContents = ((IAccessorGuiScreenBook) mc.currentScreen).getBookContents(); - if (bookContents == null) { - return contents; - } - int max = Math.min(128 / mc.fontRendererObj.FONT_HEIGHT, bookContents.size()); - for (int line = 0; line < max; ++line) { - IChatComponent lineStr = bookContents.get(line); - contents.add(lineStr.getUnformattedText()); - } - if (!contents.isEmpty()) { - return contents; - } - } - return null; - } - - public static String getChest() { - if (mc.thePlayer.openContainer instanceof ContainerChest) { - ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; - if (chest == null) { - return ""; - } - return chest.getLowerChestInventory().getDisplayName().getUnformattedText(); - } - return ""; - } - - public static String getContainer() { - if (mc.currentScreen instanceof GuiContainerCreative) { - CreativeTabs creativetabs = CreativeTabs.creativeTabArray[((GuiContainerCreative) mc.currentScreen).getSelectedTabIndex()]; - if (creativetabs != null) { - return I18n.format(creativetabs.getTranslatedTabLabel()); - } - } - else if (mc.currentScreen != null) { - try { - return ((IInventory) ReflectionUtils.containerInventoryPlayer.get(mc.currentScreen.getClass()).get(mc.currentScreen)).getDisplayName().getUnformattedText(); - } catch (Exception e) { - } - } - return ""; - } - - public static int getSize() { - return mc.thePlayer.inventory.getSizeInventory(); - } - - public static int getChestSize() { - if (mc.thePlayer.openContainer instanceof ContainerChest) { - ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; - if (chest == null) { - return -1; - } - return chest.getLowerChestInventory().getSizeInventory(); - } - return -1; - } - - public static ItemStack getStackInSlot(int slot) { - if (mc.thePlayer.inventory.getStackInSlot(slot) == null) { - return null; - } - return new ItemStack(mc.thePlayer.inventory.getStackInSlot(slot), (byte) 0); - } - - public static ItemStack getStackInChestSlot(int slot) { - if (mc.thePlayer.openContainer instanceof ContainerChest) { - ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; - if (chest.getLowerChestInventory().getStackInSlot(slot) == null) { - return null; - } - return new ItemStack(chest.getLowerChestInventory().getStackInSlot(slot), (byte) 0); - } - return null; - } - - public static ItemStack getStackInCraftingSlot(int slot) { - if (mc.thePlayer.openContainer instanceof ContainerWorkbench) { - InventoryCrafting craftMatrix = ((ContainerWorkbench) mc.thePlayer.openContainer).craftMatrix; - if (craftMatrix.getStackInSlot(slot) == null) { - return null; - } - return new ItemStack(craftMatrix.getStackInSlot(slot), (byte) 0); - } - return null; - } - - public static ItemStack getCraftResult() { - if (mc.thePlayer.openContainer instanceof ContainerWorkbench) { - IInventory craftResult = ((ContainerWorkbench) mc.thePlayer.openContainer).craftResult; - if (craftResult.getStackInSlot(0) == null) { - return null; - } - return new ItemStack(craftResult.getStackInSlot(0), (byte) 0); - } - return null; - } - - public static void open() { - KeyBinding inventoryKey = mc.gameSettings.keyBindInventory; - int originalKeyCode = inventoryKey.getKeyCode(); - - if (originalKeyCode == 0) { - inventoryKey.setKeyCode(13); - KeyBinding.resetKeyBindingArrayAndHash(); - } - - KeyBinding.setKeyBindState(inventoryKey.getKeyCode(), true); - KeyBinding.onTick(inventoryKey.getKeyCode()); - KeyBinding.setKeyBindState(inventoryKey.getKeyCode(), false); - - if (originalKeyCode == 0) { - inventoryKey.setKeyCode(0); - KeyBinding.resetKeyBindingArrayAndHash(); - } - } - } - - public static class keybinds { - public static int[] getMousePosition() { - return new int[] { Mouse.getX(), Mouse.getY() }; - } - - public static boolean isPressed(final String key) { - KeyBinding keyBind = ReflectionUtils.keybinds.get(key); - return keyBind != null && keyBind.isKeyDown(); - } - - public static void setPressed(final String key, final boolean pressed) { - KeyBinding keyBind = ReflectionUtils.keybinds.get(key); - if (keyBind != null) { - KeyBinding.setKeyBindState(keyBind.getKeyCode(), pressed); - if (pressed) { - KeyBinding.onTick(keyBind.getKeyCode()); - } - } - } - - public static int getKeyCode(final String key) { - final KeyBinding keyBind = ReflectionUtils.keybinds.get(key); - if (keyBind != null) { - return keyBind.getKeyCode(); - } - return -1; - } - - public static int getKeyIndex(String key) { - return Keyboard.getKeyIndex(key); - } - - public static boolean isMouseDown(int mouseButton) { - return Mouse.isButtonDown(mouseButton); - } - - public static boolean isKeyDown(int key) { - return Keyboard.isKeyDown(key); - } - - public static void rightClick() { - ((IAccessorMinecraft) mc).callRightClickMouse(); - } - - public static void leftClick() { - ((IAccessorMinecraft) mc).callClickMouse(); - } - - public static int getScroll() { - return Mouse.getDWheel(); - } - } - - public static class util { - public static final String colorSymbol = "§"; - - public static String color(String message) { - return Utils.formatColor(message); - } - - public static String strip(String string) { - return Utils.stripColor(string); - } - - public static double round(double value, int decimals) { - return Utils.round(value, decimals); - } - - public static int randomInt(int min, int max) { - return Utils.randomizeInt(min, max); - } - - public static double randomDouble(double min, double max) { - return Utils.randomizeDouble(min, max); - } - } -} +package keystrokesmod.script; + +import keystrokesmod.Raven; +import keystrokesmod.clickgui.ClickGui; +import keystrokesmod.clickgui.components.impl.CategoryComponent; +import keystrokesmod.clickgui.components.impl.ModuleComponent; +import keystrokesmod.helper.RotationHelper; +import keystrokesmod.mixin.impl.accessor.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.combat.KillAura; +import keystrokesmod.module.setting.Setting; +import keystrokesmod.module.setting.impl.*; +import keystrokesmod.script.model.*; +import keystrokesmod.script.model.Vec3; +import keystrokesmod.script.packet.clientbound.SPacket; +import keystrokesmod.script.packet.serverbound.CPacket; +import keystrokesmod.script.packet.serverbound.PacketHandler; +import keystrokesmod.utility.*; +import keystrokesmod.utility.shader.BlurUtils; +import keystrokesmod.utility.shader.RoundedUtils; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.*; +import net.minecraft.client.gui.inventory.*; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.resources.ResourcePackRepository; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.ContainerWorkbench; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemBlock; +import net.minecraft.network.Packet; +import net.minecraft.realms.RealmsBridge; +import net.minecraft.scoreboard.Team; +import net.minecraft.util.*; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +import java.io.File; +import java.io.IOException; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.file.*; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ScriptDefaults { + private static ExecutorService cachedExecutor; + private static final Minecraft mc = Minecraft.getMinecraft(); + public static final Bridge bridge = new Bridge(); + private static final LinkedHashMap modulesMap = new LinkedHashMap<>(); + + public static void reloadModules() { + modulesMap.clear(); + for (Module module : Raven.getModuleManager().getModules()) { + modulesMap.put(module.getName(), module); + } + for (Module module : Raven.scriptManager.scripts.values()) { + modulesMap.put(module.getName(), module); + } + } + + public static class client { + public static boolean allowFlying() { + return mc.thePlayer.capabilities.allowFlying; + } + + public static void removePotionEffect(int id) { + if (mc.thePlayer == null) { + return; + } + mc.thePlayer.removePotionEffectClient(id); + } + + public static int getUID() { + return 4; + } + + public static String getUser() { + return "mic"; + } + + public static void addEnemy(String username) { + Utils.addEnemy(username); + } + + public static void addFriend(String username) { + Utils.addFriend(username); + } + + public static void async(final Runnable method) { + if (cachedExecutor == null) { + cachedExecutor = Executors.newCachedThreadPool(); + } + cachedExecutor.execute(method); + } + + public static int getFPS() { + return Minecraft.getDebugFPS(); + } + + public static void chat(String message) { + mc.thePlayer.sendChatMessage(message); + } + + public static void print(String string) { + Utils.sendRawMessage(string); + } + + public static void print(Message component) { + mc.thePlayer.addChatMessage(component.component); + } + + public static void print(Object object) { + String s = String.valueOf(object); + Utils.sendRawMessage(s); + } + + public static boolean isDiagonal() { + return Utils.isDiagonal(false); + } + + public static void setTimer(float timer) { + ((IAccessorMinecraft) mc).getTimer().timerSpeed = timer; + } + + public static boolean isCreative() { + return mc.thePlayer.capabilities.isCreativeMode; + } + + public static void processPacket(SPacket packet) { + packet.packet.processPacket((((IAccessorNetworkManager) (mc.getNetHandler().getNetworkManager())).getPacketListener())); + } + + public static void multiplyMotion(double factor) { + mc.thePlayer.motionZ *= factor; + mc.thePlayer.motionX *= factor; + } + + public static void processPacketNoEvent(SPacket packet) { + PacketUtils.receivePacketNoEvent(packet.packet); + } + + public static String getTitle() { + return ((IAccessorGuiIngame) mc.ingameGUI).getDisplayedTitle(); + } + + public static String getSubTitle() { + return ((IAccessorGuiIngame) mc.ingameGUI).getDisplayedSubTitle(); + } + + public static String getRecordPlaying() { + return ((IAccessorGuiIngame) mc.ingameGUI).getRecordPlaying(); + } + + public static boolean isFlying() { + return mc.thePlayer.capabilities.isFlying; + } + + public static void attack(Entity entity) { + Utils.attackEntity(entity.entity, true, true); + } + + public static boolean isSinglePlayer() { + return mc.isSingleplayer(); + } + + public static boolean isSpectator() { + return mc.thePlayer.isSpectator(); + } + + public static void setFlying(boolean flying) { + mc.thePlayer.capabilities.isFlying = flying; + } + + public static void setJump(boolean jump) { + mc.thePlayer.movementInput.jump = jump; + } + + public static void setJumping(boolean jump) { + mc.thePlayer.setJumping(jump); + } + + public static void setRenderArmPitch(float pitch) { + mc.thePlayer.prevRenderArmPitch = pitch; + mc.thePlayer.renderArmPitch = pitch; + } + + public static float getEquippedProgress() { + return ((IAccessorItemRenderer) mc.getItemRenderer()).getEquippedProgress(); + } + + public static void disconnect() { + boolean isLocal = mc.isIntegratedServerRunning(); + boolean isRealms = mc.isConnectedToRealms(); + mc.theWorld.sendQuittingDisconnectingPacket(); + mc.loadWorld(null); + if (isLocal) { + mc.displayGuiScreen(new GuiMainMenu()); + return; + } + if (isRealms) { + new RealmsBridge().switchToRealms(new GuiMainMenu()); + return; + } + mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu())); + } + + public static float getRenderArmPitch() { + return mc.thePlayer.renderArmPitch; + } + + public static void setRenderArmYaw(float yaw) { + mc.thePlayer.prevRenderArmYaw = yaw; + mc.thePlayer.renderArmYaw = yaw; + } + + public static float getRenderArmYaw() { + return mc.thePlayer.renderArmYaw; + } + + public static long getTotalMemory() { + return Runtime.getRuntime().totalMemory(); + } + + public static long getFreeMemory() { + return Runtime.getRuntime().freeMemory(); + } + + public static long getMaxMemory() { + return Runtime.getRuntime().maxMemory(); + } + + public static List getResourcePacks() { + List packs = new ArrayList<>(); + if (mc.getResourcePackRepository().getRepositoryEntries() == null || mc.getResourcePackRepository().getRepositoryEntries().isEmpty()) { + packs.add(new String[] { mc.mcDefaultResourcePack.getPackName(), "" } ); + } + else { + for (ResourcePackRepository.Entry entry : mc.getResourcePackRepository().getRepositoryEntries()) { + packs.add(new String[] { entry.getResourcePackName(), entry.getTexturePackDescription() } ); + } + } + Collections.reverse(packs); // reverse it to match the correct order + return packs; + } + + public static void jump() { + mc.thePlayer.jump(); + } + + public static boolean allowEditing() { + if (mc.thePlayer == null || mc.thePlayer.capabilities == null) { + return false; + } + return mc.thePlayer.capabilities.allowEdit; + } + + public static void setItemInUseCount(int count) { + ((IAccessorEntityPlayer) mc.thePlayer).setItemInUseCount(count); + } + + public static int getItemInUseCount() { + return mc.thePlayer.getItemInUseCount(); + } + + public static int getItemInUseDuration() { + return mc.thePlayer.getItemInUseDuration(); + } + + public static void log(final Object obj) { + Utils.log.info(obj); + } + + public static void setSneaking(boolean sneak) { + mc.thePlayer.setSneaking(sneak); + } + + public static void setSneak(boolean sneak) { + mc.thePlayer.movementInput.sneak = sneak; + } + + public static boolean isSneak() { + return mc.thePlayer.movementInput.sneak; + } + + public static Entity getPlayer() { + if (mc == null || mc.thePlayer == null) { + return null; + } + return Entity.convert(mc.thePlayer); + } + + public static void removeEnemy(String username) { + Utils.removeEnemy(username); + } + + public static void removeFriend(String username) { + Utils.removeFriend(username); + } + + public static boolean isRiding() { + return mc.thePlayer.isRiding(); + } + + public static Vec3 getMotion() { + return new Vec3(mc.thePlayer.motionX, mc.thePlayer.motionY, mc.thePlayer.motionZ); + } + + public static void sleep(long ms) { + try { + Thread.sleep(ms); + } + catch (InterruptedException ignored) {} + } + + public static void ping() { + mc.thePlayer.playSound("note.pling", 1.0f, 1.0f); + } + + public static void playSound(String name, float volume, float pitch) { + mc.thePlayer.playSound(name, volume, pitch); + } + + public static boolean isMoving() { + return Utils.isMoving(); + } + + public static boolean isJump() { + return mc.thePlayer.movementInput.jump; + } + + public static float getStrafe() { + return mc.thePlayer.movementInput.moveStrafe; + } + + public static void sleep(int ms) { + try { + Thread.sleep(ms); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + public static float getForward() { + return mc.thePlayer.movementInput.moveForward; + } + + public static void closeScreen() { + if (mc.currentScreen instanceof ClickGui) { + mc.displayGuiScreen(null); + return; + } + mc.thePlayer.closeScreen(); + } + + public static String getScreen() { + return mc.currentScreen == null ? "" : mc.currentScreen.getClass().getSimpleName(); + } + + public static float[] getRotationsToEntity(Entity entity) { + return RotationUtils.getRotations(entity.entity); + } + + public static void sendPacket(CPacket packet) { + Packet packet1 = PacketHandler.convertCPacket(packet); + if (packet1 == null) { + return; + } + mc.thePlayer.sendQueue.addToSendQueue(packet1); + } + + public static void sendPacketNoEvent(CPacket packet) { + Packet packet1 = PacketHandler.convertCPacket(packet); + if (packet1 == null) { + return; + } + PacketUtils.sendPacketNoEvent(packet1); + } + + public static boolean inFocus() { + return mc.inGameHasFocus; + } + + public static void dropItem(boolean dropStack) { + mc.thePlayer.dropOneItem(dropStack); + } + + public static void setMotion(double x, double y, double z) { + mc.thePlayer.motionX = x; + mc.thePlayer.motionY = y; + mc.thePlayer.motionZ = z; + } + + public static void setSpeed(double speed) { + Utils.setSpeed(speed); + } + + public static void setForward(float forward) { + mc.thePlayer.movementInput.moveForward = forward; + } + + public static void setStrafe(float strafe) { + mc.thePlayer.movementInput.moveStrafe = strafe; + } + + public static String getServerIP() { + if (mc.getCurrentServerData() == null || mc.isSingleplayer()) { + return ""; + } + return mc.getCurrentServerData().serverIP; + } + + public static int[] getDisplaySize() { + final ScaledResolution scaledResolution = new ScaledResolution(mc); + return new int[]{scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + } + + public static float getServerDirection(PlayerState state) { + return state.yaw; + } + + public static Object[] raycastBlock(final double distance) { + return raycastBlock(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); + } + + public static Object[] raycastBlock(final double distance, final float yaw, final float pitch) { + final net.minecraft.util.Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); + final net.minecraft.util.Vec3 lookVec = Utils.getLookVec(yaw, pitch); + final net.minecraft.util.Vec3 sumVec = eyeVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance); + final MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(eyeVec, sumVec, false, false, false); + if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) { + return null; + } + final Vec3 pos = new Vec3(mop.getBlockPos()); + final Vec3 offset = new Vec3(mop.hitVec.xCoord - pos.x, mop.hitVec.yCoord - pos.y, mop.hitVec.zCoord - pos.z); + return new Object[] { pos, offset, mop.sideHit.name() }; + } + + public static Object[] raycastEntity(final double distance) { + return raycastEntity(distance, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); + } + + public static Object[] raycastEntity(final double distance, final float yaw, final float pitch) { + net.minecraft.entity.Entity pointedEntity = null; + MovingObjectPosition mop = mc.thePlayer.rayTrace(distance, 1.0f); + final net.minecraft.util.Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); + final net.minecraft.util.Vec3 lookVec = Utils.getLookVec(yaw, pitch); + final net.minecraft.util.Vec3 vec32 = eyeVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance); + net.minecraft.util.Vec3 vec33 = null; + final List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), mc.getRenderViewEntity().getEntityBoundingBox().addCoord(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance).expand(1.0, 1.0, 1.0)); + double d2 = distance; + for (int i = 0; i < list.size(); ++i) { + final net.minecraft.entity.Entity entity = (net.minecraft.entity.Entity) list.get(i); + if (entity instanceof EntityLivingBase && entity.canBeCollidedWith()) { + if (((EntityLivingBase)entity).deathTime == 0) { + final float cbs = entity.getCollisionBorderSize(); + final AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand((double)cbs, (double)cbs, (double)cbs); + final MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(eyeVec, vec32); + if (axisalignedbb.isVecInside(eyeVec)) { + if (0.0 < d2 || d2 == 0.0) { + pointedEntity = entity; + vec33 = ((movingobjectposition == null) ? eyeVec : movingobjectposition.hitVec); + d2 = 0.0; + } + } + else if (movingobjectposition != null) { + final double d3 = eyeVec.distanceTo(movingobjectposition.hitVec); + if (d3 < d2 || d2 == 0.0) { + if (entity == mc.getRenderViewEntity().ridingEntity && !entity.canRiderInteract()) { + if (d2 == 0.0) { + pointedEntity = entity; + vec33 = movingobjectposition.hitVec; + } + } + else { + pointedEntity = entity; + vec33 = movingobjectposition.hitVec; + d2 = d3; + } + } + } + } + } + } + if (pointedEntity != null && (d2 < distance || mop == null)) { + mop = new MovingObjectPosition(pointedEntity, vec33); + final Vec3 offset = new Vec3(mop.hitVec.xCoord - pointedEntity.posX, mop.hitVec.yCoord - pointedEntity.posY, mop.hitVec.zCoord - pointedEntity.posZ); + return new Object[] { new Entity(mop.entityHit), offset, eyeVec.squareDistanceTo(mop.hitVec) }; + } + return null; + } + + public static boolean canPlaceBlock(ItemStack stack, Vec3 pos, String side) { + if (stack == null || stack.itemStack == null || stack.itemStack.getItem() == null || !stack.isBlock) { + return false; + } + return ((ItemBlock) stack.itemStack.getItem()).canPlaceBlockOnSide(mc.theWorld, Vec3.getBlockPos(pos), Utils.getEnum(EnumFacing.class, side), mc.thePlayer, stack.itemStack); + } + + public static boolean placeBlock(Vec3 targetPos, String side, Vec3 hitVec) { + return mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem(), Vec3.getBlockPos(targetPos), Utils.getEnum(EnumFacing.class, side), Vec3.getVec3(hitVec)); + } + + public static void enableMovementFix() { + RotationHelper.get().forceMovementFix = true; + } + + public static float[] getRotationsToBlock(Vec3 position) { + return RotationUtils.getRotations(new BlockPos(position.x, position.y, position.z)); + } + + public static void setSprinting(boolean sprinting) { + mc.thePlayer.setSprinting(sprinting); + } + + public static void swing() { + mc.thePlayer.swingItem(); + } + + public static long time() { + return System.currentTimeMillis(); + } + + public static boolean isFriend(String username) { + return Utils.isFriended(username); + } + + public static boolean isEnemy(String username) { + return Utils.isEnemy(username); + } + } + + public static class world { + public static Block getBlockAt(int x, int y, int z) { + IBlockState state = BlockUtils.getBlockState(new BlockPos(x, y, z)); + if (state == null) { + return new Block(Blocks.air, new BlockPos(x, y, z)); + } + return new Block(state, new BlockPos(x, y, z)); + } + + public static Block getBlockAt(Vec3 pos) { + IBlockState state = BlockUtils.getBlockState(new BlockPos(pos.x, pos.y, pos.z)); + if (state == null) { + return new Block(Blocks.air, new BlockPos(pos.x, pos.y, pos.z)); + } + return new Block(state, new BlockPos(pos.x, pos.y, pos.z)); + } + + public static String getDimension() { + if (mc.theWorld == null) { + return ""; + } + return mc.theWorld.provider.getDimensionName(); + } + + public static List getEntities() { + List entities = new ArrayList<>(); + if (mc.theWorld == null) { + return entities; + } + for (net.minecraft.entity.Entity entity : mc.theWorld.loadedEntityList) { + entities.add(Entity.convert(entity)); + } + return entities; + } + + public static Entity getEntityById(int entityId) { + if (mc.theWorld == null) { + return null; + } + return Entity.convert(mc.theWorld.getEntityByID(entityId)); + } + + public static List getNetworkPlayers() { + List entities = new ArrayList<>(); + for (NetworkPlayerInfo networkPlayerInfo : Utils.getTablist(false)) { + entities.add(NetworkPlayer.convert(networkPlayerInfo)); + } + return entities; + } + + public static List getPlayerEntities() { + List entities = new ArrayList<>(); + for (net.minecraft.entity.Entity entity : mc.theWorld.playerEntities) { + entities.add(Entity.convert(entity)); + } + return entities; + } + + public static List getScoreboard() { + List sidebarLines = Utils.getSidebarLines(); + if (sidebarLines.isEmpty()) { + return null; + } + return sidebarLines; + } + + public static String getTabHeader() { + if (mc == null || mc.ingameGUI == null || mc.ingameGUI.getTabList() == null) { + return ""; + } + IChatComponent header = ((IAccessorGuiPlayerTabOverlay) mc.ingameGUI.getTabList()).getHeader(); + if (header != null) { + return header.getUnformattedText(); + } + return ""; + } + + public static String getTabFooter() { + if (mc == null || mc.ingameGUI == null || mc.ingameGUI.getTabList() == null) { + return ""; + } + IChatComponent footer = ((IAccessorGuiPlayerTabOverlay) mc.ingameGUI.getTabList()).getFooter(); + if (footer != null) { + return footer.getUnformattedText(); + } + return ""; + } + + public static Map> getTeams() { + Map> teams = new HashMap<>(); + for (Team team : mc.theWorld.getScoreboard().getTeams()) { + List members = new ArrayList<>(); + for (String member : team.getMembershipCollection()) { + members.add(member); + } + teams.put(team.getRegisteredName(), members); + } + return teams; + } + + public static List getTileEntities() { + List tileEntities = new ArrayList<>(); + for (net.minecraft.tileentity.TileEntity entity : mc.theWorld.loadedTileEntityList) { + tileEntities.add(new TileEntity(entity)); + } + return tileEntities; + } + } + + public static class modules { + private String superName; + + public modules(String superName) { + this.superName = superName; + } + + private static Module getModule(String moduleName) { + return modulesMap.get(moduleName); + } + + private static Module getScript(String name) { + return modulesMap.get(name); + } + + private static Setting getSetting(Module module, String settingName) { + if (module == null) { + return null; + } + for (Setting setting : module.getSettings()) { + if (setting.getName().equals(settingName)) { + return setting; + } + } + return null; + } + + private GroupSetting getGroupForString(String group) { + if (group.isEmpty()) { + return null; + } + List settings = getScript(this.superName).getSettings(); + for (Setting setting : settings) { + if (!(setting instanceof GroupSetting)) { + continue; + } + if (setting.getName().equals(group)) { + return (GroupSetting) setting; + } + } + return null; + } + + public void enable(String moduleName) { + if (getModule(moduleName) == null) { + return; + } + getModule(moduleName).enable(); + } + + public void disable(String moduleName) { + if (getModule(moduleName) == null) { + return; + } + getModule(moduleName).disable(); + } + + public boolean isEnabled(String moduleName) { + if (getModule(moduleName) == null) { + return false; + } + return getModule(moduleName).isEnabled(); + } + + public Entity getKillAuraTarget() { + if (KillAura.target == null) { + return null; + } + return Entity.convert(KillAura.target); + } + + public Map getSettings(String name) { + Map settings = new HashMap<>(); + Module module = getModule(name); + if (module == null) { + return settings; + } + for (Setting setting : module.getSettings()) { + if (setting instanceof SliderSetting) { + settings.put(setting.getName(), ((SliderSetting) setting).getInput()); + } + else if (setting instanceof ButtonSetting) { + settings.put(setting.getName(), ((ButtonSetting) setting).isToggled()); + } + } + return settings; + } + + public Map> getCategories() { + Map> categories = new HashMap<>(); + for (CategoryComponent categoryComponent : ClickGui.categories) { + List modules = new ArrayList<>(); + for (ModuleComponent module : categoryComponent.modules) { + modules.add(module.mod.getName()); + } + categories.put(categoryComponent.category.name(), modules); + } + return categories; + } + + public Vec3 getBedAuraPosition() { + BlockPos blockPos = ModuleManager.bedAura.currentBlock; + if (ModuleManager.bedAura == null || !ModuleManager.bedAura.isEnabled() || ModuleManager.bedAura.currentBlock == null) { + return null; + } + return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + public boolean isScaffolding() { + return ModuleManager.scaffold.isEnabled(); + } + + public boolean isTowering() { + return ModuleManager.tower.canTower(); + } + + public boolean isHidden(String moduleName) { + Module module = getModule(moduleName); + if (module != null) { + return module.isHidden(); + } + return false; + } + + public float[] getBedAuraProgress() { + if (ModuleManager.bedAura != null && ModuleManager.bedAura.isEnabled()) { + return new float[]{ModuleManager.bedAura.breakProgress, ModuleManager.bedAura.vanillaProgress}; + } + return new float[]{0, 0}; + } + + public void registerGroup(String name) { + getScript(this.superName).registerSetting(new GroupSetting(name)); + } + + public void registerButton(String name, boolean defaultValue) { + getScript(this.superName).registerSetting(new ButtonSetting(name, defaultValue)); + } + + public void registerButton(String group, String name, boolean defaultValue) { + getScript(this.superName).registerSetting(new ButtonSetting(getGroupForString(group), name, defaultValue)); + } + + public void registerKey(String group, String name, int defaultKey) { + getScript(this.superName).registerSetting(new KeySetting(getGroupForString(group), name, defaultKey)); + } + + public void registerKey(String name, int defaultKey) { + getScript(this.superName).registerSetting(new KeySetting(name, defaultKey)); + } + + // main slider constructors + + public void registerSlider(String group, String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { + getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, minimum, maximum, interval)); + } + + public void registerSlider(String group, String name, String suffix, int defaultValue, String[] stringArray) { + getScript(this.superName).registerSetting(new SliderSetting(getGroupForString(group), name, suffix, defaultValue, stringArray)); + } + + // rest + + public void registerSlider(String name, double defaultValue, double minimum, double maximum, double interval) { + this.registerSlider("", name, "", defaultValue, minimum, maximum, interval); + } + + public void registerSlider(String name, int defaultValue, String[] stringArray) { + this.registerSlider("", name, "", defaultValue, stringArray); + } + + public void registerSlider(String name, String suffix, double defaultValue, double minimum, double maximum, double interval) { + this.registerSlider("", name, suffix, defaultValue, minimum, maximum, interval); + } + + public void registerSlider(String name, String suffix, int defaultValue, String[] stringArray) { + this.registerSlider("", name, suffix, defaultValue, stringArray); + } + + public void registerDescription(String description) { + getScript(this.superName).registerSetting(new DescriptionSetting(description)); + } + + public boolean getButton(String moduleName, String name) { + ButtonSetting setting = (ButtonSetting) getSetting(getModule(moduleName), name); + if (setting == null) { + return false; + } + boolean buttonState = setting.isToggled(); + return buttonState; + } + + public double getSlider(String moduleName, String name) { + SliderSetting setting = ((SliderSetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return 0; + } + double sliderValue = setting.getInput(); + return sliderValue; + } + + public boolean getKeyPressed(String moduleName, String name) { + KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return false; + } + return setting.isPressed(); + } + + public void setButton(String moduleName, String name, boolean value) { + ButtonSetting setting = (ButtonSetting) getSetting(getModule(moduleName), name); + if (setting == null) { + return; + } + setting.setEnabled(value); + } + + public void setSlider(String moduleName, String name, double value) { + SliderSetting setting = ((SliderSetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return; + } + setting.setValueRawWithEvent(value); + } + + public void setKey(String moduleName, String name, int code) { + KeySetting setting = ((KeySetting) getSetting(getModule(moduleName), name)); + if (setting == null) { + return; + } + setting.setKey(code); + } + } + + public static class gl { + public static void alpha(boolean alpha) { + if (alpha) { + GlStateManager.enableAlpha(); + } + else { + GlStateManager.disableAlpha(); + } + } + + public static void begin(int mode) { + GL11.glBegin(mode); + } + + public static void blend(boolean blend) { + if (blend) { + GlStateManager.enableBlend(); + } + else { + GlStateManager.disableBlend(); + } + } + + public static void color(float r, float g, float b, float a) { + GlStateManager.color(r, g, b, a); + } + + public static void cull(boolean cull) { + if (cull) { + GlStateManager.enableCull(); + } + else { + GlStateManager.disableCull(); + } + } + + public static void depth(boolean depth) { + if (depth) { + GlStateManager.enableDepth(); + } + else { + GlStateManager.disableDepth(); + } + } + + public static void depthMask(boolean depthMask) { + GlStateManager.depthMask(depthMask); + } + + public static void disable(int cap) { + GL11.glDisable(cap); + } + + public static void disableItemLighting() { + RenderHelper.disableStandardItemLighting(); + } + + public static void enable(int cap) { + GL11.glEnable(cap); + } + + public static void enableItemLighting(boolean gui) { + if (gui) { + RenderHelper.enableGUIStandardItemLighting(); + } + else { + RenderHelper.enableStandardItemLighting(); + } + } + + public static void resetColor() { + GlStateManager.resetColor(); + } + + public static void end() { + GL11.glEnd(); + } + + public static void lighting(boolean lighting) { + if (lighting) { + GlStateManager.enableLighting(); + } + else { + GlStateManager.disableLighting(); + } + } + + public static void lineSmooth(boolean lineSmooth) { + setGLEnable(GL11.GL_LINE_SMOOTH, lineSmooth); + } + + public static void lineWidth(float width) { + GL11.glLineWidth(width); + } + + public static void normal(float x, float y, float z) { + GL11.glNormal3f(x, y, z); + } + + public static void pop() { + GL11.glPopMatrix(); + } + + public static void push() { + GL11.glPushMatrix(); + } + + public static void rotate(float angle, float x, float y, float z) { + GL11.glRotatef(angle, x, y, z); + } + + public static void scale(float x, float y, float z) { + GL11.glScalef(x, y, z); + } + + public static void scissor(int x, int y, int width, int height) { + GL11.glScissor(x, y, width, height); + } + + public static void scissor(boolean scissor) { + setGLEnable(GL11.GL_SCISSOR_TEST, scissor); + } + + public static void texture2d(boolean texture2d) { + if (texture2d) { + GlStateManager.enableTexture2D(); + } + else { + GlStateManager.disableTexture2D(); + } + } + + public static void translate(float x, float y, float z) { + GL11.glTranslatef(x, y, z); + } + + public static void vertex2(float x, float y) { + GL11.glVertex2f(x, y); + } + + public static void vertex3(float x, float y, float z) { + GL11.glVertex3f(x, y, z); + } + + private static void setGLEnable(int cap, boolean enable) { + if (enable) { + GL11.glEnable(cap); + } + else { + GL11.glDisable(cap); + } + } + } + + public static class config { + private static String CONFIG_DIR = mc.mcDataDir + File.separator + "keystrokes" + File.separator + "script_config.txt"; + private static String SEPARATOR = ":"; + private static String SEPARATOR_FULL = SEPARATOR + " "; + + private static void ensureConfigFileExists() throws IOException { + final Path configPath = Paths.get(config.CONFIG_DIR); + if (Files.notExists(configPath)) { + Files.createDirectories(configPath.getParent()); + Files.createFile(configPath); + } + } + + public static boolean set(String key, final String value) { + if (key == null || key.isEmpty()) { + return false; + } + key = key.replace(SEPARATOR, ""); + final String entry = key + config.SEPARATOR_FULL + value; + try { + ensureConfigFileExists(); + final Path configPath = new File(config.CONFIG_DIR).toPath(); + final List lines = new ArrayList<>(Files.readAllLines(configPath)); + boolean keyExists = false; + for (int i = 0; i < lines.size(); ++i) { + final String line = lines.get(i); + if (line.startsWith(key + config.SEPARATOR_FULL)) { + lines.set(i, entry); + keyExists = true; + break; + } + } + if (!keyExists) { + lines.add(entry); + } + Files.write(configPath, lines); + return true; + } + catch (IOException ex) { + return false; + } + } + + public static String get(final String key) { + if (key == null || key.isEmpty()) { + return null; + } + try { + ensureConfigFileExists(); + final Path configPath = new File(config.CONFIG_DIR).toPath(); + final List lines = Files.readAllLines(configPath); + for (final String line : lines) { + if (line.startsWith(key + config.SEPARATOR_FULL)) { + return line.substring((key + config.SEPARATOR_FULL).length()); + } + } + } + catch (IOException ex) {} + return null; + } + } + + public static class render { + private static final IntBuffer VIEWPORT = GLAllocation.createDirectIntBuffer(16); + private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer SCREEN_COORDS = GLAllocation.createDirectFloatBuffer(3); + + public static void block(Vec3 position, int color, boolean outline, boolean shade) { + RenderUtils.renderBlock(new BlockPos(position.x, position.y, position.z), color, outline, shade); + } + + public static void block(int x, int y, int z, int color, boolean outline, boolean shade) { + RenderUtils.renderBlock(new BlockPos(x, y, z), color, outline, shade); + } + + public static void entity(Entity en, int color, float partialTicks, boolean outline, boolean shade) { + net.minecraft.entity.Entity e = en.entity; + double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * partialTicks - mc.getRenderManager().viewerPosX; + double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * partialTicks - mc.getRenderManager().viewerPosY; + double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * partialTicks - mc.getRenderManager().viewerPosZ; + AxisAlignedBB bbox = e.getEntityBoundingBox().expand(0.1, 0.1, 0.1); + AxisAlignedBB axis = new AxisAlignedBB(bbox.minX - e.posX + x, bbox.minY - e.posY + y, bbox.minZ - e.posZ + z, bbox.maxX - e.posX + x, bbox.maxY - e.posY + y, bbox.maxZ - e.posZ + z); + GL11.glPushMatrix(); + GL11.glBlendFunc(770, 771); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glLineWidth(2.0f); + float a = (color >> 24 & 0xFF) / 255.0f; + float r = (color >> 16 & 0xFF) / 255.0f; + float g = (color >> 8 & 0xFF) / 255.0f; + float b = (color & 0xFF) / 255.0f; + GL11.glColor4f(r, g, b, a); + if (outline) { + RenderGlobal.drawSelectionBoundingBox(axis); + } + if (shade) { + RenderUtils.drawBoundingBox(axis, r, g, b); + } + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void entityGui(Entity en, int x, int y, float mouseX, float mouseY, int scale) { + if (!en.isLiving) { + return; + } + GL11.glPushMatrix(); + GuiInventory.drawEntityOnScreen(x, y, scale, mouseX, mouseY, (EntityLivingBase) en.entity); + GL11.glPopMatrix(); + } + + public static void resetEquippedProgress() { + mc.getItemRenderer().resetEquippedProgress(); + } + + public static void tracer(Entity entity, float lineWidth, int color, float partialTicks) { + RenderUtils.drawTracerLine(entity.entity, color, lineWidth, partialTicks); + } + + public static void showGui() { + mc.displayGuiScreen(new EmptyGuiScreen()); + } + + private static class EmptyGuiScreen extends GuiScreen { + } + + public static void item(ItemStack item, float x, float y, float scale) { + GlStateManager.pushMatrix(); + mc.entityRenderer.setupOverlayRendering(); + if (scale != 1.0f) { + GlStateManager.scale(scale, scale, scale); + } + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.disableBlend(); + GlStateManager.translate(x / scale, y / scale, 0); + mc.getRenderItem().renderItemIntoGUI(item.itemStack, 0, 0); + GlStateManager.enableBlend(); + RenderHelper.disableStandardItemLighting(); + if (scale != 1.0f) { + GlStateManager.scale(scale, scale, scale); + } + GlStateManager.popMatrix(); + } + + public static void image(Image image, float x, float y, float width, float height) { + if (image == null || !image.isLoaded()) { + return; + } + if (image.textureId == -1) { + final DynamicTexture dynamicTexture = new DynamicTexture(image.bufferedImage); + GL11.glTexParameteri(3553, 10240, 9728); + dynamicTexture.updateDynamicTexture(); + image.textureId = dynamicTexture.getGlTextureId(); + } + GlStateManager.pushMatrix(); + GlStateManager.enableTexture2D(); + GlStateManager.bindTexture(image.textureId); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glTexParameteri(3553, 10240, 9728); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x, (y + height), 0.0).tex(0.0, 1.0).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos((x + width), (y + height), 0.0).tex(1.0, 1.0).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos((x + width), y, 0.0).tex(1.0, 0.0).color(255, 255, 255, 255).endVertex(); + worldrenderer.pos(x, y, 0.0).tex(0.0, 0.0).color(255, 255, 255, 255).endVertex(); + tessellator.draw(); + GlStateManager.popMatrix(); + } + + public static Vec3 worldToScreen(double x, double y, double z, int scaleFactor, float partialTicks) { + x -= mc.getRenderManager().viewerPosX; + y -= mc.getRenderManager().viewerPosY; + z -= mc.getRenderManager().viewerPosZ; + ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, MODELVIEW); + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, PROJECTION); + GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT); + if (GLU.gluProject((float)x, (float)y, (float)z, render.MODELVIEW, render.PROJECTION, render.VIEWPORT, render.SCREEN_COORDS)) { + Vec3 vec = new Vec3(render.SCREEN_COORDS.get(0) / scaleFactor, (Display.getHeight() - render.SCREEN_COORDS.get(1)) / scaleFactor, render.SCREEN_COORDS.get(2)); + mc.entityRenderer.setupOverlayRendering(); + return vec; + } + return null; + } + + public static void roundedRect(float startX, float startY, float endX, float endY, float radius, int color) { + RoundedUtils.drawRoundedRectRise(startX, startY, Math.abs(startX - endX), Math.abs(startY - endY), radius, color); + } + + public static void gradientRect(float startX, float startY, float endX, float endY, int leftColor, int rightColor) { + gradientRect(startX, startY, endX, endY, leftColor, leftColor, rightColor, rightColor); + } + + public static void gradientRect(float startX, float startY, float endX, float endY, int topLeftColor, int bottomLeftColor, int topRightColor, int bottomRightColor) { + RenderUtils.drawRoundedGradientRect(startX, startY, endX, endY, 0, topLeftColor, bottomLeftColor, topRightColor, bottomRightColor); + } + + public static double[] getRotations() { + return new double[] { mc.getRenderManager().playerViewY, mc.getRenderManager().playerViewX }; + } + + public static double[] getCameraRotations() { + return new double[] { Utils.getCameraYaw(), Utils.getCameraPitch() }; + } + + public static int getFontWidth(String text) { + return mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text); + } + + public static int getFontHeight() { + return mc.fontRendererObj.FONT_HEIGHT; + } + + public static Vec3 getPosition() { + net.minecraft.util.Vec3 position = Utils.getCameraPos(((IAccessorMinecraft) mc).getTimer().renderPartialTicks); + return new Vec3(position); + } + + public static void text2d(String text, float x, float y, float scale, int color, boolean shadow) { + GlStateManager.pushMatrix(); + if (scale != 1.0f) { + GlStateManager.scale(scale, scale, scale); + } + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + mc.fontRendererObj.drawString(text, x / scale, y / scale, color, shadow); + GlStateManager.disableBlend(); + if (scale != 1.0f) { + GlStateManager.scale(1.0f, 1.0f, 1.0f); + } + GlStateManager.popMatrix(); + } + + public static void text3d(String text, Vec3 position, float scale, boolean shadow, boolean depth, boolean background, int color) { + ((IAccessorEntityRenderer) mc.entityRenderer).callSetupCameraTransform(((IAccessorMinecraft) mc).getTimer().renderPartialTicks, 0); + GlStateManager.pushMatrix(); + float partialTicks = ((IAccessorMinecraft) mc).getTimer().renderPartialTicks; + double px = mc.thePlayer.prevPosX + (mc.thePlayer.posX - mc.thePlayer.prevPosX) * partialTicks; + double py = mc.thePlayer.prevPosY + (mc.thePlayer.posY - mc.thePlayer.prevPosY) * partialTicks; + double pz = mc.thePlayer.prevPosZ + (mc.thePlayer.posZ - mc.thePlayer.prevPosZ) * partialTicks; + GlStateManager.translate((float)position.x - px, (float)position.y - py, (float)position.z - pz); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f); + float f1 = 0.02666667F; + GlStateManager.scale(-f1, -f1, f1); + if (depth) { + GlStateManager.depthMask(false); + GlStateManager.disableDepth(); + } + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + if (background) { + GlStateManager.disableTexture2D(); + int width = mc.fontRendererObj.getStringWidth(text); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos(-1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(-1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(width + 1, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldrenderer.pos(width + 1, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + } + if (scale != 1) { + GlStateManager.scale(scale, scale, scale); + } + mc.fontRendererObj.drawString(text, 0, 0, color, shadow); + if (scale != 1) { + GlStateManager.scale(1, 1, 1); + } + if (depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.disableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } + + public static void rect(float startX, float startY, float endX, float endY, final int color) { + if (startX < endX) { + final float i = startX; + startX = endX; + endX = i; + } + if (startY < endY) { + final float j = startY; + startY = endY; + endY = j; + } + final float f3 = (color >> 24 & 0xFF) / 255.0f; + final float f4 = (color >> 16 & 0xFF) / 255.0f; + final float f5 = (color >> 8 & 0xFF) / 255.0f; + final float f6 = (color & 0xFF) / 255.0f; + final Tessellator tessellator = Tessellator.getInstance(); + final WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GL11.glPushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f4, f5, f6, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)startX, (double)endY, 0.0).endVertex(); + worldrenderer.pos((double)endX, (double)endY, 0.0).endVertex(); + worldrenderer.pos((double)endX, (double)startY, 0.0).endVertex(); + worldrenderer.pos((double)startX, (double)startY, 0.0).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GL11.glPopMatrix(); + } + + public static void line2D(double startX, double startY, double endX, double endY, float lineWidth, int color) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + RenderUtils.glColor(color); + GL11.glLineWidth(lineWidth); + GL11.glBegin(GL11.GL_LINES); + GL11.glVertex2d(startX, startY); + GL11.glVertex2d(endX, endY); + GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glPopMatrix(); + } + + public static void line3D(Vec3 pos1, Vec3 pos2, float lineWidth, int color) { + line3D(pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z, lineWidth, color); + } + + public static void line3D(final double startX, final double startY, final double startZ, double endX, double endY, double endZ, final float lineWidth, final int color) { + endX -= mc.getRenderManager().viewerPosX; + endY -= mc.getRenderManager().viewerPosY; + endZ -= mc.getRenderManager().viewerPosZ; + final float a = (color >> 24 & 0xFF) / 255.0f; + final float r = (color >> 16 & 0xFF) / 255.0f; + final float g = (color >> 8 & 0xFF) / 255.0f; + final float b = (color & 0xFF) / 255.0f; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(lineWidth); + GlStateManager.color(r, g, b, a); + GL11.glBegin(2); + GL11.glVertex3d(startX - mc.thePlayer.posX, startY - mc.thePlayer.posY, startZ - mc.thePlayer.posZ); + GL11.glVertex3d(endX, endY, endZ); + GL11.glEnd(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static boolean isInView(Entity en) { + return RenderUtils.isInViewFrustum(en.entity); + } + + public static class blur { + public static void prepare() { + BlurUtils.prepareBlur(); + } + + public static void apply(final int passes, final float radius) { + BlurUtils.blurEnd(passes, radius); + } + } + + public static class bloom { + public static void prepare() { + BlurUtils.prepareBloom(); + } + + public static void apply(final int passes, final float radius) { + BlurUtils.bloomEnd(passes, radius); + } + } + } + + public static class inventory { + public static int getSlot() { + return mc.thePlayer.inventory.currentItem; + } + + public static void setSlot(int slot) { + mc.thePlayer.inventory.currentItem = slot; + } + + public static void click(int slot, int button, int mode) { + mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot, button, mode, mc.thePlayer); + } + + public static List getBookContents() { + if (mc.currentScreen instanceof GuiScreenBook) { + List contents = new ArrayList<>(); + List bookContents = ((IAccessorGuiScreenBook) mc.currentScreen).getBookContents(); + if (bookContents == null) { + return contents; + } + int max = Math.min(128 / mc.fontRendererObj.FONT_HEIGHT, bookContents.size()); + for (int line = 0; line < max; ++line) { + IChatComponent lineStr = bookContents.get(line); + contents.add(lineStr.getUnformattedText()); + } + if (!contents.isEmpty()) { + return contents; + } + } + return null; + } + + public static String getChest() { + if (mc.thePlayer.openContainer instanceof ContainerChest) { + ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; + if (chest == null) { + return ""; + } + return chest.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + return ""; + } + + public static String getContainer() { + if (mc.currentScreen instanceof GuiContainerCreative) { + CreativeTabs creativetabs = CreativeTabs.creativeTabArray[((GuiContainerCreative) mc.currentScreen).getSelectedTabIndex()]; + if (creativetabs != null) { + return I18n.format(creativetabs.getTranslatedTabLabel()); + } + } + else if (mc.currentScreen != null) { + try { + return ((IInventory) ReflectionUtils.containerInventoryPlayer.get(mc.currentScreen.getClass()).get(mc.currentScreen)).getDisplayName().getUnformattedText(); + } catch (Exception e) { + } + } + return ""; + } + + public static int getSize() { + return mc.thePlayer.inventory.getSizeInventory(); + } + + public static int getChestSize() { + if (mc.thePlayer.openContainer instanceof ContainerChest) { + ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; + if (chest == null) { + return -1; + } + return chest.getLowerChestInventory().getSizeInventory(); + } + return -1; + } + + public static ItemStack getStackInSlot(int slot) { + if (mc.thePlayer.inventory.getStackInSlot(slot) == null) { + return null; + } + return new ItemStack(mc.thePlayer.inventory.getStackInSlot(slot), (byte) 0); + } + + public static ItemStack getStackInChestSlot(int slot) { + if (mc.thePlayer.openContainer instanceof ContainerChest) { + ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer; + if (chest.getLowerChestInventory().getStackInSlot(slot) == null) { + return null; + } + return new ItemStack(chest.getLowerChestInventory().getStackInSlot(slot), (byte) 0); + } + return null; + } + + public static ItemStack getStackInCraftingSlot(int slot) { + if (mc.thePlayer.openContainer instanceof ContainerWorkbench) { + InventoryCrafting craftMatrix = ((ContainerWorkbench) mc.thePlayer.openContainer).craftMatrix; + if (craftMatrix.getStackInSlot(slot) == null) { + return null; + } + return new ItemStack(craftMatrix.getStackInSlot(slot), (byte) 0); + } + return null; + } + + public static ItemStack getCraftResult() { + if (mc.thePlayer.openContainer instanceof ContainerWorkbench) { + IInventory craftResult = ((ContainerWorkbench) mc.thePlayer.openContainer).craftResult; + if (craftResult.getStackInSlot(0) == null) { + return null; + } + return new ItemStack(craftResult.getStackInSlot(0), (byte) 0); + } + return null; + } + + public static void open() { + KeyBinding inventoryKey = mc.gameSettings.keyBindInventory; + int originalKeyCode = inventoryKey.getKeyCode(); + + if (originalKeyCode == 0) { + inventoryKey.setKeyCode(13); + KeyBinding.resetKeyBindingArrayAndHash(); + } + + KeyBinding.setKeyBindState(inventoryKey.getKeyCode(), true); + KeyBinding.onTick(inventoryKey.getKeyCode()); + KeyBinding.setKeyBindState(inventoryKey.getKeyCode(), false); + + if (originalKeyCode == 0) { + inventoryKey.setKeyCode(0); + KeyBinding.resetKeyBindingArrayAndHash(); + } + } + } + + public static class keybinds { + public static int[] getMousePosition() { + return new int[] { Mouse.getX(), Mouse.getY() }; + } + + public static boolean isPressed(final String key) { + KeyBinding keyBind = ReflectionUtils.keybinds.get(key); + return keyBind != null && keyBind.isKeyDown(); + } + + public static void setPressed(final String key, final boolean pressed) { + KeyBinding keyBind = ReflectionUtils.keybinds.get(key); + if (keyBind != null) { + KeyBinding.setKeyBindState(keyBind.getKeyCode(), pressed); + if (pressed) { + KeyBinding.onTick(keyBind.getKeyCode()); + } + } + } + + public static int getKeyCode(final String key) { + final KeyBinding keyBind = ReflectionUtils.keybinds.get(key); + if (keyBind != null) { + return keyBind.getKeyCode(); + } + return -1; + } + + public static int getKeyIndex(String key) { + return Keyboard.getKeyIndex(key); + } + + public static boolean isMouseDown(int mouseButton) { + return Mouse.isButtonDown(mouseButton); + } + + public static boolean isKeyDown(int key) { + return Keyboard.isKeyDown(key); + } + + public static void rightClick() { + ((IAccessorMinecraft) mc).callRightClickMouse(); + } + + public static void leftClick() { + ((IAccessorMinecraft) mc).callClickMouse(); + } + + public static int getScroll() { + return Mouse.getDWheel(); + } + } + + public static class util { + public static final String colorSymbol = "§"; + + public static String color(String message) { + return Utils.formatColor(message); + } + + public static String strip(String string) { + return Utils.stripColor(string); + } + + public static double round(double value, int decimals) { + return Utils.round(value, decimals); + } + + public static int randomInt(int min, int max) { + return Utils.randomizeInt(min, max); + } + + public static double randomDouble(double min, double max) { + return Utils.randomizeDouble(min, max); + } + } +} diff --git a/src/main/java/keystrokesmod/script/ScriptDiagnosticListener.java b/src/main/java/keystrokesmod/script/ScriptDiagnosticListener.java index 242f14b..24fe298 100644 --- a/src/main/java/keystrokesmod/script/ScriptDiagnosticListener.java +++ b/src/main/java/keystrokesmod/script/ScriptDiagnosticListener.java @@ -1,38 +1,38 @@ -package keystrokesmod.script; - -import keystrokesmod.utility.Utils; - -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; -import java.util.Locale; - -public class ScriptDiagnosticListener implements DiagnosticListener { - - @Override - public void report(final javax.tools.Diagnostic diagnostic) { - final String message = diagnostic.getMessage(null); - if (message.contains("SpongePowered")) { - return; - } - if (diagnostic.getSource() != null) { - Utils.sendDebugMessage("§cError loading script §b" + Utils.extractFileName(((JavaSourceFromString) diagnostic.getSource()).name)); - } - final JavaFileObject javaFileObject = diagnostic.getSource(); - if (javaFileObject != null) { - int indentIndex = message.indexOf("\n"); - String error = diagnostic.getMessage(Locale.getDefault()); - Utils.sendDebugMessage(" §7err: §c" + (indentIndex == -1 ? error : error.substring(0, indentIndex))); - Utils.sendDebugMessage(" §7line: §c" + (diagnostic.getLineNumber() - ((JavaSourceFromString) diagnostic.getSource()).extraLines)); - String sourceContent = ((JavaSourceFromString) diagnostic.getSource()).getCharContent(true).toString(); - int startPos = (int) diagnostic.getStartPosition(); - int endPos = (int) diagnostic.getEndPosition(); - int srcIndentIndex = sourceContent.indexOf("\n", startPos); - if (srcIndentIndex != -1) { - Utils.sendDebugMessage(" §7src: §c" + sourceContent.substring(startPos, srcIndentIndex)); - } - else { - Utils.sendDebugMessage(" §7src: §c" + sourceContent.substring(startPos, endPos)); - } - } - } -} +package keystrokesmod.script; + +import keystrokesmod.utility.Utils; + +import javax.tools.DiagnosticListener; +import javax.tools.JavaFileObject; +import java.util.Locale; + +public class ScriptDiagnosticListener implements DiagnosticListener { + + @Override + public void report(final javax.tools.Diagnostic diagnostic) { + final String message = diagnostic.getMessage(null); + if (message.contains("SpongePowered")) { + return; + } + if (diagnostic.getSource() != null) { + Utils.sendDebugMessage("§cError loading script §b" + Utils.extractFileName(((JavaSourceFromString) diagnostic.getSource()).name)); + } + final JavaFileObject javaFileObject = diagnostic.getSource(); + if (javaFileObject != null) { + int indentIndex = message.indexOf("\n"); + String error = diagnostic.getMessage(Locale.getDefault()); + Utils.sendDebugMessage(" §7err: §c" + (indentIndex == -1 ? error : error.substring(0, indentIndex))); + Utils.sendDebugMessage(" §7line: §c" + (diagnostic.getLineNumber() - ((JavaSourceFromString) diagnostic.getSource()).extraLines)); + String sourceContent = ((JavaSourceFromString) diagnostic.getSource()).getCharContent(true).toString(); + int startPos = (int) diagnostic.getStartPosition(); + int endPos = (int) diagnostic.getEndPosition(); + int srcIndentIndex = sourceContent.indexOf("\n", startPos); + if (srcIndentIndex != -1) { + Utils.sendDebugMessage(" §7src: §c" + sourceContent.substring(startPos, srcIndentIndex)); + } + else { + Utils.sendDebugMessage(" §7src: §c" + sourceContent.substring(startPos, endPos)); + } + } + } +} diff --git a/src/main/java/keystrokesmod/script/ScriptEvents.java b/src/main/java/keystrokesmod/script/ScriptEvents.java index 7030ce2..6b35df4 100644 --- a/src/main/java/keystrokesmod/script/ScriptEvents.java +++ b/src/main/java/keystrokesmod/script/ScriptEvents.java @@ -1,189 +1,210 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.script.model.Entity; -import keystrokesmod.script.model.PlayerState; -import keystrokesmod.script.packet.clientbound.SPacket; -import keystrokesmod.script.packet.serverbound.CPacket; -import keystrokesmod.script.packet.serverbound.PacketHandler; -import keystrokesmod.utility.Utils; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.common.network.FMLNetworkEvent; - -public class ScriptEvents { - public Module module; - - public ScriptEvents(Module module) { - this.module = module; - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onChat(ClientChatReceivedEvent e) { - if (e.type == 2 || !Utils.nullCheck()) { - return; - } - if (Utils.stripColor(e.message.getUnformattedText()).isEmpty()) { - return; - } - if (Raven.scriptManager.invokeBoolean("onChat", module, e.message.getUnformattedText()) == 0) { - e.setCanceled(true); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onSendPacket(SendPacketEvent e) { - if (e.isCanceled() || e.getPacket() == null) { - return; - } - if (e.getPacket().getClass().getSimpleName().startsWith("S")) { - return; - } - CPacket packet = PacketHandler.convertServerBound(e.getPacket()); - if (packet != null && Raven.scriptManager.invokeBoolean("onPacketSent", module, packet) == 0) { - e.setCanceled(true); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onReceivePacket(ReceivePacketEvent e) { - if (e.isCanceled() || e.getPacket() == null) { - return; - } - SPacket packet = PacketHandler.convertClientBound(e.getPacket()); - if (packet != null && Raven.scriptManager.invokeBoolean("onPacketReceived", module, packet) == 0) { - e.setCanceled(true); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onAttack(AttackEvent e) { - if (e.isCanceled()) { - return; - } - Entity target = Entity.convert(e.target); - Entity attacker = Entity.convert(e.attacker); - if (Raven.scriptManager.invokeBoolean("onAttackEntity", module, target, attacker) == 0) { - e.setCanceled(true); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onClientRotations(ClientRotationEvent e) { - Float[] rotations = Raven.scriptManager.invokeFloatArray("getRotations", module); - if (rotations == null || rotations.length == 0 || rotations.length > 2) { - return; - } - if (rotations[0] != null) { - e.yaw = rotations[0]; - } - if (rotations.length == 2 && rotations[1] != null) { - e.pitch = rotations[1]; - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onKeyTyped(KeyPressEvent e) { - if (e.isCanceled()) { - return; - } - if (Raven.scriptManager.invokeBoolean("onKeyPress", module, e.typedChar, e.keyCode) == 0) { - e.setCanceled(true); - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onRenderWorldLast(RenderWorldLastEvent e) { - if (!Utils.nullCheck()) { - return; - } - Raven.scriptManager.invoke("onRenderWorld", module, e.partialTicks); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPreUpdate(PreUpdateEvent e) { - Raven.scriptManager.invoke("onPreUpdate", module); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPostUpdate(PostUpdateEvent e) { - Raven.scriptManager.invoke("onPostUpdate", module); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderTick(TickEvent.RenderTickEvent e) { - if (e.phase != TickEvent.Phase.END || !Utils.nullCheck()) { - return; - } - Raven.scriptManager.invoke("onRenderTick", module, e.renderTickTime); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onAntiCheatFlag(AntiCheatFlagEvent e) { - Raven.scriptManager.invoke("onAntiCheatFlag", module, e.flag, Entity.convert(e.entity)); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onGuiUpdate(GuiUpdateEvent e) { - if (e.guiScreen == null) { - return; - } - Raven.scriptManager.invoke("onGuiUpdate", module, e.guiScreen.getClass().getSimpleName(), e.opened); - } - - @SubscribeEvent - public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent e) { - Raven.scriptManager.invoke("onDisconnect", module); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPreMotion(PreMotionEvent e) { - PlayerState playerState = new PlayerState(e, (byte) 0); - Raven.scriptManager.invoke("onPreMotion", module, playerState); - if (e.isEquals(playerState)) { - return; - } - if (e.getYaw() != playerState.yaw) { - e.setYaw(playerState.yaw); - } - e.setPitch(playerState.pitch); - e.setPosX(playerState.x); - e.setPosY(playerState.y); - e.setPosZ(playerState.z); - e.setOnGround(playerState.onGround); - e.setSprinting(playerState.isSprinting); - e.setSneaking(playerState.isSneaking); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == null) { - return; - } - Raven.scriptManager.invoke("onWorldJoin", module, Entity.convert(e.entity)); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPostInput(PostPlayerInputEvent e) { - Raven.scriptManager.invoke("onPostPlayerInput", module); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPostMotion(PostMotionEvent e) { - Raven.scriptManager.invoke("onPostMotion", module); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onMouse(MouseEvent e) { - if (Raven.scriptManager.invokeBoolean("onMouse", module, e.button, e.buttonstate) == 0) { - e.setCanceled(true); - } - } +package keystrokesmod.script; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.script.model.Entity; +import keystrokesmod.script.model.MovementInput; +import keystrokesmod.script.model.PlayerState; +import keystrokesmod.script.model.Vec3; +import keystrokesmod.script.packet.clientbound.SPacket; +import keystrokesmod.script.packet.serverbound.CPacket; +import keystrokesmod.script.packet.serverbound.PacketHandler; +import keystrokesmod.utility.Utils; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.common.network.FMLNetworkEvent; + +public class ScriptEvents { + public Module module; + + public ScriptEvents(Module module) { + this.module = module; + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onChat(ClientChatReceivedEvent e) { + if (e.type == 2 || !Utils.nullCheck()) { + return; + } + if (Utils.stripColor(e.message.getUnformattedText()).isEmpty()) { + return; + } + if (Raven.scriptManager.invokeBoolean("onChat", module, e.message.getUnformattedText()) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onSendPacket(SendPacketEvent e) { + if (e.isCanceled() || e.getPacket() == null) { + return; + } + if (e.getPacket().getClass().getSimpleName().startsWith("S")) { + return; + } + CPacket packet = PacketHandler.convertServerBound(e.getPacket()); + if (packet != null && Raven.scriptManager.invokeBoolean("onPacketSent", module, packet) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onReceivePacket(ReceivePacketEvent e) { + if (e.isCanceled() || e.getPacket() == null) { + return; + } + SPacket packet = PacketHandler.convertClientBound(e.getPacket()); + if (packet != null && Raven.scriptManager.invokeBoolean("onPacketReceived", module, packet) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onAttack(AttackEvent e) { + if (e.isCanceled()) { + return; + } + Entity target = Entity.convert(e.target); + Entity attacker = Entity.convert(e.attacker); + if (Raven.scriptManager.invokeBoolean("onAttackEntity", module, target, attacker) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onClientRotations(ClientRotationEvent e) { + Float[] rotations = Raven.scriptManager.invokeFloatArray("getRotations", module); + if (rotations == null || rotations.length == 0 || rotations.length > 2) { + return; + } + if (rotations[0] != null) { + e.yaw = rotations[0]; + } + if (rotations.length == 2 && rotations[1] != null) { + e.pitch = rotations[1]; + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPrePlayerMovementInput(PrePlayerInputEvent e) { + MovementInput input = new MovementInput(e, (byte) 0); + Raven.scriptManager.invoke("onPrePlayerInput", module, input); + if (e.isEquals(input)) { + return; + } + e.setForward(input.forward); + e.setSneak(input.sneak); + e.setJump(input.jump); + e.setStrafe(input.strafe); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onKeyTyped(KeyPressEvent e) { + if (e.isCanceled()) { + return; + } + if (Raven.scriptManager.invokeBoolean("onKeyPress", module, e.typedChar, e.keyCode) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onRenderWorldLast(RenderWorldLastEvent e) { + if (!Utils.nullCheck()) { + return; + } + Raven.scriptManager.invoke("onRenderWorld", module, e.partialTicks); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPreUpdate(PreUpdateEvent e) { + Raven.scriptManager.invoke("onPreUpdate", module); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPostUpdate(PostUpdateEvent e) { + Raven.scriptManager.invoke("onPostUpdate", module); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderTick(TickEvent.RenderTickEvent e) { + if (e.phase != TickEvent.Phase.END || !Utils.nullCheck()) { + return; + } + Raven.scriptManager.invoke("onRenderTick", module, e.renderTickTime); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onAntiCheatFlag(AntiCheatFlagEvent e) { + Raven.scriptManager.invoke("onAntiCheatFlag", module, e.flag, Entity.convert(e.entity)); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onGuiUpdate(GuiUpdateEvent e) { + if (e.guiScreen == null) { + return; + } + Raven.scriptManager.invoke("onGuiUpdate", module, e.guiScreen.getClass().getSimpleName(), e.opened); + } + + @SubscribeEvent + public void onDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent e) { + Raven.scriptManager.invoke("onDisconnect", module); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPreMotion(PreMotionEvent e) { + PlayerState playerState = new PlayerState(e, (byte) 0); + Raven.scriptManager.invoke("onPreMotion", module, playerState); + if (e.isEquals(playerState)) { + return; + } + if (e.getYaw() != playerState.yaw) { + e.setYaw(playerState.yaw); + } + e.setPitch(playerState.pitch); + e.setPosX(playerState.x); + e.setPosY(playerState.y); + e.setPosZ(playerState.z); + e.setOnGround(playerState.onGround); + e.setSprinting(playerState.isSprinting); + e.setSneaking(playerState.isSneaking); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == null) { + return; + } + Raven.scriptManager.invoke("onWorldJoin", module, Entity.convert(e.entity)); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPostInput(PostPlayerInputEvent e) { + Raven.scriptManager.invoke("onPostPlayerInput", module); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPostMotion(PostMotionEvent e) { + Raven.scriptManager.invoke("onPostMotion", module); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onMouse(MouseEvent e) { + if (Raven.scriptManager.invokeBoolean("onMouse", module, e.button, e.buttonstate) == 0) { + e.setCanceled(true); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerMove(PlayerMoveEvent e) { + Raven.scriptManager.invoke("onPlayerMove", module, new Vec3(e.x, e.y, e.z)); + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/ScriptManager.java b/src/main/java/keystrokesmod/script/ScriptManager.java index ef986b9..24024ac 100644 --- a/src/main/java/keystrokesmod/script/ScriptManager.java +++ b/src/main/java/keystrokesmod/script/ScriptManager.java @@ -1,258 +1,258 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; -import keystrokesmod.clickgui.components.impl.CategoryComponent; -import keystrokesmod.module.Module; -import keystrokesmod.utility.NetworkUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraftforge.common.MinecraftForge; - -import javax.tools.JavaCompiler; -import javax.tools.ToolProvider; -import java.awt.*; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.MessageDigest; -import java.util.*; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Matcher; - -public class ScriptManager { - private Minecraft mc = Minecraft.getMinecraft(); - public LinkedHashMap scripts = new LinkedHashMap<>(); - public JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - public boolean deleteTempFiles = true; - public File directory; - public List imports = Arrays.asList(Color.class.getName(), Collections.class.getName(), List.class.getName(), ArrayList.class.getName(), Arrays.class.getName(), Map.class.getName(), Set.class.getName(), HashMap.class.getName(), HashSet.class.getName(), ConcurrentHashMap.class.getName(), LinkedHashMap.class.getName(), LinkedHashSet.class.getName(), Iterator.class.getName(), Comparator.class.getName(), AtomicInteger.class.getName(), AtomicLong.class.getName(), AtomicBoolean.class.getName(), Random.class.getName(), Matcher.class.getName()); - public String COMPILED_DIR = Utils.getCompilerDirectory(); - public String jarPath = ((String[])ScriptManager.class.getProtectionDomain().getCodeSource().getLocation().getPath().split("\\.jar!"))[0].substring(5) + ".jar"; - private Map loadedHashes = new HashMap<>(); - - public ScriptManager() { - directory = new File(mc.mcDataDir + File.separator + "keystrokes", "scripts"); - } - - public void onEnable(Script script) { - if (script.event == null) { - script.event = new ScriptEvents(getModule(script)); - MinecraftForge.EVENT_BUS.register(script.event); - } - script.invoke("onEnable"); - } - - public Module getModule(Script script) { - for (Map.Entry entry : this.scripts.entrySet()) { - if (entry.getKey().equals(script)) { - return entry.getValue(); - } - } - return null; - } - - public void loadScripts() { - for (Module module : this.scripts.values()) { - module.disable(); - } - - if (deleteTempFiles) { - deleteTempFiles = false; - File tempDirectory = new File(COMPILED_DIR); - if (tempDirectory.exists() && tempDirectory.isDirectory()) { - File[] tempFiles = tempDirectory.listFiles(); - if (tempFiles != null) { - for (File tempFile : tempFiles) { - if (!tempFile.delete()) { - System.err.println("Failed to delete temp file: " + tempFile.getAbsolutePath()); - } - } - } - } - } - else { - if (!this.scripts.isEmpty()) { - Iterator> iterator = scripts.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - String fileName = entry.getKey().file.getName(); - String hash = calculateHash(entry.getKey().file); - - String cachedHash = loadedHashes.get(fileName); - if (cachedHash != null && cachedHash.equals(hash) && !entry.getKey().error) { - continue; // no changes detected, skip loading - } - entry.getKey().delete(); - iterator.remove(); - loadedHashes.remove(fileName); - } - } - else { - loadedHashes.clear(); - } - } - - File scriptDirectory = directory; - if (scriptDirectory.exists() && scriptDirectory.isDirectory()) { - File[] scriptFiles = scriptDirectory.listFiles(); - if (scriptFiles != null) { - for (File scriptFile : scriptFiles) { - if (scriptFile.isFile() && scriptFile.getName().endsWith(".java")) { - String fileName = scriptFile.getName(); - String hash = calculateHash(scriptFile); - - String cachedHash = loadedHashes.get(fileName); - if (cachedHash != null && cachedHash.equals(hash)) { - continue; // No changes detected, skip parsing - } - parseFile(scriptFile); - loadedHashes.put(scriptFile.getName(), hash); - } - } - } - } - else { - if (scriptDirectory.mkdirs()) { - System.out.println("Created script directory: " + scriptDirectory.getAbsolutePath()); - } - else { - System.err.println("Failed to create script directory: " + scriptDirectory.getAbsolutePath()); - } - } - - for (Module module : this.scripts.values()) { - module.disable(); - } - - for (CategoryComponent categoryComponent : Raven.clickGui.categories) { - if (categoryComponent.category == Module.category.scripts) { - categoryComponent.reloadModules(false); - } - } - - ScriptDefaults.reloadModules(); - - File tempDirectory = new File(COMPILED_DIR); - if (tempDirectory.exists() && tempDirectory.isDirectory()) { - File[] tempFiles = tempDirectory.listFiles(); - if (tempFiles != null) { - for (File tempFile : tempFiles) { - if (!tempFile.delete()) { - System.err.println("Failed to delete temp file: " + tempFile.getAbsolutePath()); - } - } - } - } - } - - private boolean parseFile(File file) { - if (file.getName().startsWith("_") || !file.getName().endsWith(".java")) { - return false; - } - String scriptName = file.getName().replace(".java", ""); - if (scriptName.isEmpty()) { - return false; - } - StringBuilder scriptContents = new StringBuilder(); - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { - String line; - while ((line = bufferedReader.readLine()) != null) { - scriptContents.append(line).append("\n"); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - if (scriptContents.length() == 0) { - return false; - } - List topLevelLines = Utils.getTopLevelLines(scriptContents.toString()); - for (String line : topLevelLines) { - if (line.startsWith("load - \"") && line.endsWith("\"")) { - String url = line.substring("load - \"".length(), line.length() - 1); - String externalContents = NetworkUtils.getTextFromURL(url, true, true); - if (externalContents.isEmpty()) { - break; - } - int loadIndex = scriptContents.indexOf(line); - if (loadIndex != -1) { - scriptContents.replace(loadIndex, loadIndex + line.length(), externalContents); - } - } - } - - Script script = new Script(scriptName); - script.file = file; - script.setCode(scriptContents.toString()); - script.run(); - Module module = new Module(script); - Raven.scriptManager.scripts.put(script, module); - ScriptDefaults.reloadModules(); - Raven.scriptManager.invoke("onLoad", module); - return !script.error; - } - - - public void onDisable(Script script) { - if (script.event != null) { - MinecraftForge.EVENT_BUS.unregister(script.event); - script.event = null; - } - script.invoke("onDisable"); - } - - public void invoke(String methodName, Module module, Object... args) { - for (Map.Entry entry : this.scripts.entrySet()) { - if (((entry.getValue().canBeEnabled() && entry.getValue().isEnabled()) || methodName.equals("onLoad")) && entry.getValue().equals(module)) { - entry.getKey().invoke(methodName, args); - } - } - } - - public int invokeBoolean(String methodName, Module module, Object... args) { - for (Map.Entry entry : this.scripts.entrySet()) { - if (entry.getValue().canBeEnabled() && entry.getValue().isEnabled() && entry.getValue().equals(module)) { - int c = entry.getKey().getBoolean(methodName, args); - if (c != -1) { - return c; - } - } - } - return -1; - } - - - public Float[] invokeFloatArray(String method, Module module, Object... args) { - for (Map.Entry entry : this.scripts.entrySet()) { - if (entry.getValue().canBeEnabled() && entry.getValue().isEnabled() && entry.getValue().equals(module)) { - Float[] val = entry.getKey().getFloatArray(method, args); - if (val != null) { - return val; - } - } - } - return null; - } - - private String calculateHash(File file) { - try { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] fileBytes = Files.readAllBytes(Paths.get(file.getPath())); - byte[] hashBytes = digest.digest(fileBytes); - - StringBuilder hexString = new StringBuilder(); - for (byte b : hashBytes) { - hexString.append(String.format("%02x", b)); - } - return hexString.toString(); - } - catch (Exception e) { - return ""; - } - } +package keystrokesmod.script; + +import keystrokesmod.Raven; +import keystrokesmod.clickgui.components.impl.CategoryComponent; +import keystrokesmod.module.Module; +import keystrokesmod.utility.NetworkUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraftforge.common.MinecraftForge; + +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; +import java.awt.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.util.*; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.regex.Matcher; + +public class ScriptManager { + private Minecraft mc = Minecraft.getMinecraft(); + public LinkedHashMap scripts = new LinkedHashMap<>(); + public JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + public boolean deleteTempFiles = true; + public File directory; + public List imports = Arrays.asList(Color.class.getName(), Collections.class.getName(), List.class.getName(), ArrayList.class.getName(), Arrays.class.getName(), Map.class.getName(), Set.class.getName(), HashMap.class.getName(), HashSet.class.getName(), ConcurrentHashMap.class.getName(), LinkedHashMap.class.getName(), LinkedHashSet.class.getName(), Iterator.class.getName(), Comparator.class.getName(), AtomicInteger.class.getName(), AtomicLong.class.getName(), AtomicBoolean.class.getName(), Random.class.getName(), Matcher.class.getName()); + public String COMPILED_DIR = Utils.getCompilerDirectory(); + public String jarPath = ((String[])ScriptManager.class.getProtectionDomain().getCodeSource().getLocation().getPath().split("\\.jar!"))[0].substring(5) + ".jar"; + private Map loadedHashes = new HashMap<>(); + + public ScriptManager() { + directory = new File(mc.mcDataDir + File.separator + "keystrokes", "scripts"); + } + + public void onEnable(Script script) { + if (script.event == null) { + script.event = new ScriptEvents(getModule(script)); + MinecraftForge.EVENT_BUS.register(script.event); + } + script.invoke("onEnable"); + } + + public Module getModule(Script script) { + for (Map.Entry entry : this.scripts.entrySet()) { + if (entry.getKey().equals(script)) { + return entry.getValue(); + } + } + return null; + } + + public void loadScripts() { + for (Module module : this.scripts.values()) { + module.disable(); + } + + if (deleteTempFiles) { + deleteTempFiles = false; + File tempDirectory = new File(COMPILED_DIR); + if (tempDirectory.exists() && tempDirectory.isDirectory()) { + File[] tempFiles = tempDirectory.listFiles(); + if (tempFiles != null) { + for (File tempFile : tempFiles) { + if (!tempFile.delete()) { + System.err.println("Failed to delete temp file: " + tempFile.getAbsolutePath()); + } + } + } + } + } + else { + if (!this.scripts.isEmpty()) { + Iterator> iterator = scripts.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + String fileName = entry.getKey().file.getName(); + String hash = calculateHash(entry.getKey().file); + + String cachedHash = loadedHashes.get(fileName); + if (cachedHash != null && cachedHash.equals(hash) && !entry.getKey().error) { + continue; // no changes detected, skip loading + } + entry.getKey().delete(); + iterator.remove(); + loadedHashes.remove(fileName); + } + } + else { + loadedHashes.clear(); + } + } + + File scriptDirectory = directory; + if (scriptDirectory.exists() && scriptDirectory.isDirectory()) { + File[] scriptFiles = scriptDirectory.listFiles(); + if (scriptFiles != null) { + for (File scriptFile : scriptFiles) { + if (scriptFile.isFile() && scriptFile.getName().endsWith(".java")) { + String fileName = scriptFile.getName(); + String hash = calculateHash(scriptFile); + + String cachedHash = loadedHashes.get(fileName); + if (cachedHash != null && cachedHash.equals(hash)) { + continue; // No changes detected, skip parsing + } + parseFile(scriptFile); + loadedHashes.put(scriptFile.getName(), hash); + } + } + } + } + else { + if (scriptDirectory.mkdirs()) { + System.out.println("Created script directory: " + scriptDirectory.getAbsolutePath()); + } + else { + System.err.println("Failed to create script directory: " + scriptDirectory.getAbsolutePath()); + } + } + + for (Module module : this.scripts.values()) { + module.disable(); + } + + for (CategoryComponent categoryComponent : Raven.clickGui.categories) { + if (categoryComponent.category == Module.category.scripts) { + categoryComponent.reloadModules(false); + } + } + + ScriptDefaults.reloadModules(); + + File tempDirectory = new File(COMPILED_DIR); + if (tempDirectory.exists() && tempDirectory.isDirectory()) { + File[] tempFiles = tempDirectory.listFiles(); + if (tempFiles != null) { + for (File tempFile : tempFiles) { + if (!tempFile.delete()) { + System.err.println("Failed to delete temp file: " + tempFile.getAbsolutePath()); + } + } + } + } + } + + private boolean parseFile(File file) { + if (file.getName().startsWith("_") || !file.getName().endsWith(".java")) { + return false; + } + String scriptName = file.getName().replace(".java", ""); + if (scriptName.isEmpty()) { + return false; + } + StringBuilder scriptContents = new StringBuilder(); + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + scriptContents.append(line).append("\n"); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + if (scriptContents.length() == 0) { + return false; + } + List topLevelLines = Utils.getTopLevelLines(scriptContents.toString()); + for (String line : topLevelLines) { + if (line.startsWith("load - \"") && line.endsWith("\"")) { + String url = line.substring("load - \"".length(), line.length() - 1); + String externalContents = NetworkUtils.getTextFromURL(url, true, true); + if (externalContents.isEmpty()) { + break; + } + int loadIndex = scriptContents.indexOf(line); + if (loadIndex != -1) { + scriptContents.replace(loadIndex, loadIndex + line.length(), externalContents); + } + } + } + + Script script = new Script(scriptName); + script.file = file; + script.setCode(scriptContents.toString()); + script.run(); + Module module = new Module(script); + Raven.scriptManager.scripts.put(script, module); + ScriptDefaults.reloadModules(); + Raven.scriptManager.invoke("onLoad", module); + return !script.error; + } + + + public void onDisable(Script script) { + if (script.event != null) { + MinecraftForge.EVENT_BUS.unregister(script.event); + script.event = null; + } + script.invoke("onDisable"); + } + + public void invoke(String methodName, Module module, Object... args) { + for (Map.Entry entry : this.scripts.entrySet()) { + if (((entry.getValue().canBeEnabled() && entry.getValue().isEnabled()) || methodName.equals("onLoad")) && entry.getValue().equals(module)) { + entry.getKey().invoke(methodName, args); + } + } + } + + public int invokeBoolean(String methodName, Module module, Object... args) { + for (Map.Entry entry : this.scripts.entrySet()) { + if (entry.getValue().canBeEnabled() && entry.getValue().isEnabled() && entry.getValue().equals(module)) { + int c = entry.getKey().getBoolean(methodName, args); + if (c != -1) { + return c; + } + } + } + return -1; + } + + + public Float[] invokeFloatArray(String method, Module module, Object... args) { + for (Map.Entry entry : this.scripts.entrySet()) { + if (entry.getValue().canBeEnabled() && entry.getValue().isEnabled() && entry.getValue().equals(module)) { + Float[] val = entry.getKey().getFloatArray(method, args); + if (val != null) { + return val; + } + } + } + return null; + } + + private String calculateHash(File file) { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] fileBytes = Files.readAllBytes(Paths.get(file.getPath())); + byte[] hashBytes = digest.digest(fileBytes); + + StringBuilder hexString = new StringBuilder(); + for (byte b : hashBytes) { + hexString.append(String.format("%02x", b)); + } + return hexString.toString(); + } + catch (Exception e) { + return ""; + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/SecureClassLoader.java b/src/main/java/keystrokesmod/script/SecureClassLoader.java index 28db816..1a27fb6 100644 --- a/src/main/java/keystrokesmod/script/SecureClassLoader.java +++ b/src/main/java/keystrokesmod/script/SecureClassLoader.java @@ -1,35 +1,35 @@ -package keystrokesmod.script; - -import keystrokesmod.Raven; - -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.List; - -public class SecureClassLoader extends URLClassLoader { - private static final List WHITELISTED_PACKAGES = Arrays.asList("sun.reflect", "keystrokesmod", "java.lang", "java.util", "java.awt"); - - public SecureClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); - } - - @Override - protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - if (!isClassSafe(name)) { - throw new ClassNotFoundException("Unsafe class detected: " + name); - } - return super.loadClass(name, resolve); - } - - private boolean isClassSafe(String name) { - boolean hasAllowedSuffix = name.endsWith("Exception") || name.endsWith("Throwable"); - - boolean isAllowedImport = Raven.scriptManager.imports.stream().anyMatch(prefix -> name.toLowerCase().startsWith(prefix)); - boolean isScriptClass = name.startsWith("sc_") && !name.contains("."); - - boolean isWhitelistedPackage = WHITELISTED_PACKAGES.stream().anyMatch(name::startsWith); - - return hasAllowedSuffix || isAllowedImport || isScriptClass || isWhitelistedPackage; - } +package keystrokesmod.script; + +import keystrokesmod.Raven; + +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.List; + +public class SecureClassLoader extends URLClassLoader { + private static final List WHITELISTED_PACKAGES = Arrays.asList("sun.reflect", "keystrokesmod", "java.lang", "java.util", "java.awt"); + + public SecureClassLoader(URL[] urls, ClassLoader parent) { + super(urls, parent); + } + + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + if (!isClassSafe(name)) { + throw new ClassNotFoundException("Unsafe class detected: " + name); + } + return super.loadClass(name, resolve); + } + + private boolean isClassSafe(String name) { + boolean hasAllowedSuffix = name.endsWith("Exception") || name.endsWith("Throwable"); + + boolean isAllowedImport = Raven.scriptManager.imports.stream().anyMatch(prefix -> name.toLowerCase().startsWith(prefix)); + boolean isScriptClass = name.startsWith("sc_") && !name.contains("."); + + boolean isWhitelistedPackage = WHITELISTED_PACKAGES.stream().anyMatch(name::startsWith); + + return hasAllowedSuffix || isAllowedImport || isScriptClass || isWhitelistedPackage; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/model/Block.java b/src/main/java/keystrokesmod/script/model/Block.java index 9be750e..b5b8689 100644 --- a/src/main/java/keystrokesmod/script/model/Block.java +++ b/src/main/java/keystrokesmod/script/model/Block.java @@ -1,62 +1,62 @@ -package keystrokesmod.script.model; - -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; - -public class Block { - public String type; - public String name; - public boolean interactable; - public int variant; - public double height; - public double width; - public double length; - public double x; - public double y; - public double z; - - public Block(net.minecraft.block.Block block, BlockPos blockPos) { - this.type = block.getClass().getSimpleName(); - this.name = block.getRegistryName().replace("minecraft:", ""); - this.interactable = BlockUtils.isInteractable(block); - this.variant = block.getMetaFromState(BlockUtils.getBlockState(blockPos)); - this.height = block.getBlockBoundsMaxY() - block.getBlockBoundsMinY(); - this.width = block.getBlockBoundsMaxX() - block.getBlockBoundsMinX(); - this.length = block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ(); - this.x = blockPos.getX(); - this.y = blockPos.getY(); - this.z = blockPos.getZ(); - } - - public Block(IBlockState state, BlockPos blockPos) { - final net.minecraft.block.Block block = state.getBlock(); - this.type = block.getClass().getSimpleName(); - this.name = block.getRegistryName().replace("minecraft:", ""); - this.interactable = BlockUtils.isInteractable(block); - this.variant = block.getMetaFromState(state); - this.height = block.getBlockBoundsMaxY() - block.getBlockBoundsMinY(); - this.width = block.getBlockBoundsMaxX() - block.getBlockBoundsMinX(); - this.length = block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ(); - this.x = blockPos.getX(); - this.y = blockPos.getY(); - this.z = blockPos.getZ(); - } - - public Block(int x, int y, int z) { - this(BlockUtils.getBlock(x, y, z), new BlockPos(x, y, z)); - } - - protected Block(String name, Vec3 position) { - this(Utils.getBlockFromName(name), Vec3.getBlockPos(position)); - } - - public Block(String name) { - this(name, new Vec3(-1, -1, -1)); - } - - public Block(Vec3 position) { - this(BlockUtils.getBlock(position.x, position.y, position.z), new BlockPos(position.x, position.y, position.z)); - } -} +package keystrokesmod.script.model; + +import keystrokesmod.utility.BlockUtils; +import keystrokesmod.utility.Utils; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; + +public class Block { + public String type; + public String name; + public boolean interactable; + public int variant; + public double height; + public double width; + public double length; + public double x; + public double y; + public double z; + + public Block(net.minecraft.block.Block block, BlockPos blockPos) { + this.type = block.getClass().getSimpleName(); + this.name = block.getRegistryName().replace("minecraft:", ""); + this.interactable = BlockUtils.isInteractable(block); + this.variant = block.getMetaFromState(BlockUtils.getBlockState(blockPos)); + this.height = block.getBlockBoundsMaxY() - block.getBlockBoundsMinY(); + this.width = block.getBlockBoundsMaxX() - block.getBlockBoundsMinX(); + this.length = block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ(); + this.x = blockPos.getX(); + this.y = blockPos.getY(); + this.z = blockPos.getZ(); + } + + public Block(IBlockState state, BlockPos blockPos) { + final net.minecraft.block.Block block = state.getBlock(); + this.type = block.getClass().getSimpleName(); + this.name = block.getRegistryName().replace("minecraft:", ""); + this.interactable = BlockUtils.isInteractable(block); + this.variant = block.getMetaFromState(state); + this.height = block.getBlockBoundsMaxY() - block.getBlockBoundsMinY(); + this.width = block.getBlockBoundsMaxX() - block.getBlockBoundsMinX(); + this.length = block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ(); + this.x = blockPos.getX(); + this.y = blockPos.getY(); + this.z = blockPos.getZ(); + } + + public Block(int x, int y, int z) { + this(BlockUtils.getBlock(x, y, z), new BlockPos(x, y, z)); + } + + protected Block(String name, Vec3 position) { + this(Utils.getBlockFromName(name), Vec3.getBlockPos(position)); + } + + public Block(String name) { + this(name, new Vec3(-1, -1, -1)); + } + + public Block(Vec3 position) { + this(BlockUtils.getBlock(position.x, position.y, position.z), new BlockPos(position.x, position.y, position.z)); + } +} diff --git a/src/main/java/keystrokesmod/script/model/Bridge.java b/src/main/java/keystrokesmod/script/model/Bridge.java index b93a392..8caa1b6 100644 --- a/src/main/java/keystrokesmod/script/model/Bridge.java +++ b/src/main/java/keystrokesmod/script/model/Bridge.java @@ -1,35 +1,35 @@ -package keystrokesmod.script.model; - -import java.util.HashMap; -import java.util.Map; - -public class Bridge { - private static final Map map = new HashMap<>(); - - public void add(String key, Object value) { - map.put(key, value); - } - - public void add(String key) { - map.put(key, null); - } - - public void remove(String key) { - map.remove(key); - } - - public boolean has(String key) { - return map.containsKey(key); - } - - public Object get(String key) { - if (!map.containsKey(key)) { - return null; - } - return map.getOrDefault(key, null); - } - - public void clear() { - map.clear(); - } -} +package keystrokesmod.script.model; + +import java.util.HashMap; +import java.util.Map; + +public class Bridge { + private static final Map map = new HashMap<>(); + + public void add(String key, Object value) { + map.put(key, value); + } + + public void add(String key) { + map.put(key, null); + } + + public void remove(String key) { + map.remove(key); + } + + public boolean has(String key) { + return map.containsKey(key); + } + + public Object get(String key) { + if (!map.containsKey(key)) { + return null; + } + return map.getOrDefault(key, null); + } + + public void clear() { + map.clear(); + } +} diff --git a/src/main/java/keystrokesmod/script/model/Entity.java b/src/main/java/keystrokesmod/script/model/Entity.java index 0ee9b1d..e64a9be 100644 --- a/src/main/java/keystrokesmod/script/model/Entity.java +++ b/src/main/java/keystrokesmod/script/model/Entity.java @@ -1,425 +1,425 @@ -package keystrokesmod.script.model; - -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityFishHook; -import net.minecraft.item.ItemBlock; -import net.minecraft.potion.PotionEffect; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class Entity { - public net.minecraft.entity.Entity entity; - public String type; - public int entityId; - public boolean isLiving; - public boolean isPlayer; - public boolean isUser; - private static HashMap cache = new HashMap<>(); - - public Entity(net.minecraft.entity.Entity entity) { - this.entity = entity; - if (entity == null) { - return; - } - this.type = entity.getClass().getSimpleName(); - this.entityId = entity.getEntityId(); - this.isLiving = entity instanceof EntityLivingBase; - this.isPlayer = entity instanceof EntityPlayer; - if (this.isPlayer && Minecraft.getMinecraft().thePlayer != null && entity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { - this.isUser = true; - } - } - - public static Entity convert(net.minecraft.entity.Entity entity) { - if (entity == null) { - return null; - } - int id = entity.getEntityId() + System.identityHashCode(entity); - Entity cachedEntity = cache.get(id); - - if (cachedEntity == null) { - cachedEntity = new Entity(entity); - cache.put(id, cachedEntity); - } - - return cachedEntity; - } - - public static void clearCache() { - cache.clear(); - } - - public boolean allowEditing() { - if (!(entity instanceof EntityPlayer)) { - return false; - } - return (((EntityPlayer) entity).capabilities.allowEdit); - } - - public double distanceTo(Vec3 position) { - return entity.getDistance(position.x, position.y, position.z); - } - - public double distanceToSq(Vec3 position) { - return entity.getDistanceSq(position.x, position.y, position.z); - } - - public double distanceToGround() { - return Utils.distanceToGround(entity); - } - - public boolean isHoldingBlock() { - return this.isLiving && ((EntityLivingBase)this.entity).getHeldItem() != null && ((EntityLivingBase)this.entity).getHeldItem().getItem() instanceof ItemBlock; - } - - public boolean isHoldingWeapon() { - return this.isLiving && Utils.holdingWeapon((EntityLivingBase)this.entity); - } - - public float getAbsorption() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return (((EntityLivingBase) entity).getAbsorptionAmount()); - } - - public Vec3 getBlockPosition() { - return new Vec3(entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ()); - } - - public String getDisplayName() { - if (this.entity instanceof EntityItem) { - return ((EntityItem)this.entity).getEntityItem().getDisplayName(); - } - return this.entity.getDisplayName().getUnformattedText(); - } - - public Entity getRidingEntity() { - return Entity.convert(this.entity.ridingEntity); - } - - public Entity getRiddenByEntity() { - return Entity.convert(this.entity.riddenByEntity); - } - - public Vec3 getServerPosition() { - return new Vec3(entity.serverPosX, entity.serverPosY, entity.serverPosZ); - } - - public int getExperienceLevel() { - if (!(entity instanceof EntityPlayer)) { - return 0; - } - return ((EntityPlayer) entity).experienceLevel; - } - - public float getExperience() { - if (!(entity instanceof EntityPlayer)) { - return 0; - } - return ((EntityPlayer) entity).experience; - } - - public float getFallDistance() { - return entity.fallDistance; - } - - public String getUUID() { - return this.entity.getUniqueID().toString(); - } - - public String getCustomNameTag() { - return this.entity.getCustomNameTag(); - } - - public double getBPS() { - if (!this.isLiving) { - return 0.0; - } - double x = this.entity.posX - this.entity.prevPosX; - double z = this.entity.posZ - this.entity.prevPosZ; - return Math.sqrt(x * x + z * z) * 20.0; - } - - public String getFacing() { - return this.entity.getHorizontalFacing().name(); - } - - public float getHealth() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return ((EntityLivingBase) entity).getHealth(); - } - - public boolean isSleeping() { - if (this.isPlayer) { - return ((EntityPlayer) this.entity).isPlayerSleeping(); - } - return false; - } - - public float getEyeHeight() { - return entity.getEyeHeight(); - } - - public float getHeight() { - return entity.height; - } - - public float getWidth() { - return entity.width; - } - - public boolean isBurning() { - return entity.isBurning(); - } - - public ItemStack getHeldItem() { - if (entity instanceof EntityItem) { - net.minecraft.item.ItemStack item = ((EntityItem) entity).getEntityItem(); - if (item == null) { - return null; - } - return new ItemStack(item, (byte) 0); - } - else if (!(entity instanceof EntityLivingBase)) { - return null; - } - net.minecraft.item.ItemStack stack = ((EntityLivingBase) entity).getHeldItem(); - if (stack == null) { - return null; - } - return new ItemStack(stack, (byte) 0); - } - - public int getHurtTime() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return ((EntityLivingBase) entity).hurtTime; - } - - public boolean isConsuming() { - return Utils.isConsuming(this.entity); - } - - public Vec3 getLastPosition() { - return new Vec3(this.entity.lastTickPosX, this.entity.lastTickPosY, this.entity.lastTickPosZ); - } - - public float getMaxHealth() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return ((EntityLivingBase) entity).getMaxHealth(); - } - - public int getMaxHurtTime() { - if (!(entity instanceof EntityLivingBase)) { - return -1; - } - return ((EntityLivingBase) entity).maxHurtTime; - } - - public String getName() { - if (entity instanceof EntityItem) { - return ((EntityItem) entity).getEntityItem().getItem().getRegistryName().substring(10); - } - return entity.getName(); - } - - public NetworkPlayer getNetworkPlayer() { - return NetworkPlayer.convert(Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.entity.getUniqueID())); - } - - public float getPitch() { - return entity.rotationPitch; - } - - public Vec3 getPosition() { - if (entity == null) { - return null; - } - return new Vec3(entity.posX, entity.posY, entity.posZ); - } - - public List getPotionEffects() { - List potionEffects = new ArrayList<>(); - if (!(entity instanceof EntityLivingBase)) { - return potionEffects; - } - for (PotionEffect potionEffect : ((EntityLivingBase) entity).getActivePotionEffects()) { - Object[] potionData = new Object[]{potionEffect.getPotionID(), potionEffect.getEffectName(), potionEffect.getAmplifier(), potionEffect.getDuration()}; - potionEffects.add(potionData); - } - return potionEffects; - } - - public ItemStack getArmorInSlot(final int slot) { - return (this.isPlayer && slot >= 0 && slot <= 3) ? ItemStack.convert(((EntityPlayer)this.entity).inventory.armorInventory[slot]) : null; - } - - public double getSpeed() { - return Utils.getHorizontalSpeed(entity); - } - - public int getSwingProgress() { - return this.isLiving ? ((EntityLivingBase)this.entity).swingProgressInt : -1; - } - - public float getPrevSwingProgress() { - return this.isLiving ? ((EntityLivingBase)this.entity).prevSwingProgress : -1f; - } - - public int getTicksExisted() { - return entity.ticksExisted; - } - - public float getYaw() { - return entity.rotationYaw; - } - - public int getFireResistance() { - return this.entity.fireResistance; - } - - public float getPrevYaw() { - return entity.prevRotationYaw; - } - - public float getPrevPitch() { - return entity.prevRotationPitch; - } - - public boolean isCreative() { - if (!(entity instanceof EntityPlayer)) { - return false; - } - return (((EntityPlayer) entity).capabilities.isCreativeMode); - } - - public boolean isCollided() { - if (!(entity instanceof EntityPlayer)) { - return Minecraft.getMinecraft().theWorld.checkBlockCollision(this.entity.getEntityBoundingBox().expand(0.05, 0.0, 0.05)); - } - return entity.isCollided; - } - - public boolean isCollidedHorizontally() { - return entity.isCollidedHorizontally; - } - - public boolean isCollidedVertically() { - return entity.isCollidedVertically; - } - - public boolean isDead() { - return this.entity.isDead || (this.isLiving && ((EntityLivingBase)this.entity).deathTime > 0); - } - - public int getHunger() { - if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { - return 0; - } - return ((EntityPlayer) this.entity).getFoodStats().getFoodLevel(); - } - - public float getSaturation() { - if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { - return 0.0f; - } - return ((EntityPlayer) this.entity).getFoodStats().getSaturationLevel(); - } - - public float getAir() { - return this.entity.getAir(); - } - - public boolean isInvisible() { - return entity.isInvisible(); - } - - public boolean isInWater() { - return entity.isInWater(); - } - - public boolean isInLava() { - return entity.isInLava(); - } - - public Entity getFisher() { - if (this.entity instanceof EntityFishHook) { - return convert(((EntityFishHook) this.entity).angler); - } - return null; - } - - public boolean isInLiquid() { - return !this.entity.isOffsetPositionInLiquid(0, 0, 0); - } - - public boolean isOnLadder() { - if (this.isLiving) { - if (((EntityLivingBase) this.entity).isOnLadder()) { - return true; - } - } - return false; - } - - public boolean isOnEdge() { - return Utils.onEdge(this.entity); - } - - public boolean isSprinting() { - return entity.isSprinting(); - } - - public boolean isSneaking() { - return entity.isSneaking(); - } - - public boolean isUsingItem() { - if (!(entity instanceof EntityPlayer)) { - return false; - } - return (((EntityPlayer) entity).isUsingItem()); - } - - public boolean onGround() { - return entity.onGround; - } - - public void setMotion(double x, double y, double z) { - entity.motionX = x; - entity.motionY = y; - entity.motionZ = z; - } - - public Vec3 getMotion() { - return new Vec3(entity.motionX, entity.motionY, entity.motionZ); - } - - public void setPitch(float pitch) { - entity.rotationPitch = pitch; - } - - public void setYaw(float yaw) { - entity.rotationYaw = yaw; - } - - public void setPosition(Vec3 position) { - entity.setPosition(position.x, position.y, position.z); - } - - public void setPosition(double x, double y, double z) { - entity.setPosition(x, y, z); - } -} +package keystrokesmod.script.model; + +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.item.ItemBlock; +import net.minecraft.potion.PotionEffect; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class Entity { + public net.minecraft.entity.Entity entity; + public String type; + public int entityId; + public boolean isLiving; + public boolean isPlayer; + public boolean isUser; + private static HashMap cache = new HashMap<>(); + + public Entity(net.minecraft.entity.Entity entity) { + this.entity = entity; + if (entity == null) { + return; + } + this.type = entity.getClass().getSimpleName(); + this.entityId = entity.getEntityId(); + this.isLiving = entity instanceof EntityLivingBase; + this.isPlayer = entity instanceof EntityPlayer; + if (this.isPlayer && Minecraft.getMinecraft().thePlayer != null && entity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { + this.isUser = true; + } + } + + public static Entity convert(net.minecraft.entity.Entity entity) { + if (entity == null) { + return null; + } + int id = entity.getEntityId() + System.identityHashCode(entity); + Entity cachedEntity = cache.get(id); + + if (cachedEntity == null) { + cachedEntity = new Entity(entity); + cache.put(id, cachedEntity); + } + + return cachedEntity; + } + + public static void clearCache() { + cache.clear(); + } + + public boolean allowEditing() { + if (!(entity instanceof EntityPlayer)) { + return false; + } + return (((EntityPlayer) entity).capabilities.allowEdit); + } + + public double distanceTo(Vec3 position) { + return entity.getDistance(position.x, position.y, position.z); + } + + public double distanceToSq(Vec3 position) { + return entity.getDistanceSq(position.x, position.y, position.z); + } + + public double distanceToGround() { + return Utils.distanceToGround(entity); + } + + public boolean isHoldingBlock() { + return this.isLiving && ((EntityLivingBase)this.entity).getHeldItem() != null && ((EntityLivingBase)this.entity).getHeldItem().getItem() instanceof ItemBlock; + } + + public boolean isHoldingWeapon() { + return this.isLiving && Utils.holdingWeapon((EntityLivingBase)this.entity); + } + + public float getAbsorption() { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return (((EntityLivingBase) entity).getAbsorptionAmount()); + } + + public Vec3 getBlockPosition() { + return new Vec3(entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ()); + } + + public String getDisplayName() { + if (this.entity instanceof EntityItem) { + return ((EntityItem)this.entity).getEntityItem().getDisplayName(); + } + return this.entity.getDisplayName().getUnformattedText(); + } + + public Entity getRidingEntity() { + return Entity.convert(this.entity.ridingEntity); + } + + public Entity getRiddenByEntity() { + return Entity.convert(this.entity.riddenByEntity); + } + + public Vec3 getServerPosition() { + return new Vec3(entity.serverPosX, entity.serverPosY, entity.serverPosZ); + } + + public int getExperienceLevel() { + if (!(entity instanceof EntityPlayer)) { + return 0; + } + return ((EntityPlayer) entity).experienceLevel; + } + + public float getExperience() { + if (!(entity instanceof EntityPlayer)) { + return 0; + } + return ((EntityPlayer) entity).experience; + } + + public float getFallDistance() { + return entity.fallDistance; + } + + public String getUUID() { + return this.entity.getUniqueID().toString(); + } + + public String getCustomNameTag() { + return this.entity.getCustomNameTag(); + } + + public double getBPS() { + if (!this.isLiving) { + return 0.0; + } + double x = this.entity.posX - this.entity.prevPosX; + double z = this.entity.posZ - this.entity.prevPosZ; + return Math.sqrt(x * x + z * z) * 20.0; + } + + public String getFacing() { + return this.entity.getHorizontalFacing().name(); + } + + public float getHealth() { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return ((EntityLivingBase) entity).getHealth(); + } + + public boolean isSleeping() { + if (this.isPlayer) { + return ((EntityPlayer) this.entity).isPlayerSleeping(); + } + return false; + } + + public float getEyeHeight() { + return entity.getEyeHeight(); + } + + public float getHeight() { + return entity.height; + } + + public float getWidth() { + return entity.width; + } + + public boolean isBurning() { + return entity.isBurning(); + } + + public ItemStack getHeldItem() { + if (entity instanceof EntityItem) { + net.minecraft.item.ItemStack item = ((EntityItem) entity).getEntityItem(); + if (item == null) { + return null; + } + return new ItemStack(item, (byte) 0); + } + else if (!(entity instanceof EntityLivingBase)) { + return null; + } + net.minecraft.item.ItemStack stack = ((EntityLivingBase) entity).getHeldItem(); + if (stack == null) { + return null; + } + return new ItemStack(stack, (byte) 0); + } + + public int getHurtTime() { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return ((EntityLivingBase) entity).hurtTime; + } + + public boolean isConsuming() { + return Utils.isConsuming(this.entity); + } + + public Vec3 getLastPosition() { + return new Vec3(this.entity.lastTickPosX, this.entity.lastTickPosY, this.entity.lastTickPosZ); + } + + public float getMaxHealth() { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return ((EntityLivingBase) entity).getMaxHealth(); + } + + public int getMaxHurtTime() { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return ((EntityLivingBase) entity).maxHurtTime; + } + + public String getName() { + if (entity instanceof EntityItem) { + return ((EntityItem) entity).getEntityItem().getItem().getRegistryName().substring(10); + } + return entity.getName(); + } + + public NetworkPlayer getNetworkPlayer() { + return NetworkPlayer.convert(Minecraft.getMinecraft().getNetHandler().getPlayerInfo(this.entity.getUniqueID())); + } + + public float getPitch() { + return entity.rotationPitch; + } + + public Vec3 getPosition() { + if (entity == null) { + return null; + } + return new Vec3(entity.posX, entity.posY, entity.posZ); + } + + public List getPotionEffects() { + List potionEffects = new ArrayList<>(); + if (!(entity instanceof EntityLivingBase)) { + return potionEffects; + } + for (PotionEffect potionEffect : ((EntityLivingBase) entity).getActivePotionEffects()) { + Object[] potionData = new Object[]{potionEffect.getPotionID(), potionEffect.getEffectName(), potionEffect.getAmplifier(), potionEffect.getDuration()}; + potionEffects.add(potionData); + } + return potionEffects; + } + + public ItemStack getArmorInSlot(final int slot) { + return (this.isPlayer && slot >= 0 && slot <= 3) ? ItemStack.convert(((EntityPlayer)this.entity).inventory.armorInventory[slot]) : null; + } + + public double getSpeed() { + return Utils.getHorizontalSpeed(entity); + } + + public int getSwingProgress() { + return this.isLiving ? ((EntityLivingBase)this.entity).swingProgressInt : -1; + } + + public float getPrevSwingProgress() { + return this.isLiving ? ((EntityLivingBase)this.entity).prevSwingProgress : -1f; + } + + public int getTicksExisted() { + return entity.ticksExisted; + } + + public float getYaw() { + return entity.rotationYaw; + } + + public int getFireResistance() { + return this.entity.fireResistance; + } + + public float getPrevYaw() { + return entity.prevRotationYaw; + } + + public float getPrevPitch() { + return entity.prevRotationPitch; + } + + public boolean isCreative() { + if (!(entity instanceof EntityPlayer)) { + return false; + } + return (((EntityPlayer) entity).capabilities.isCreativeMode); + } + + public boolean isCollided() { + if (!(entity instanceof EntityPlayer)) { + return Minecraft.getMinecraft().theWorld.checkBlockCollision(this.entity.getEntityBoundingBox().expand(0.05, 0.0, 0.05)); + } + return entity.isCollided; + } + + public boolean isCollidedHorizontally() { + return entity.isCollidedHorizontally; + } + + public boolean isCollidedVertically() { + return entity.isCollidedVertically; + } + + public boolean isDead() { + return this.entity.isDead || (this.isLiving && ((EntityLivingBase)this.entity).deathTime > 0); + } + + public int getHunger() { + if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { + return 0; + } + return ((EntityPlayer) this.entity).getFoodStats().getFoodLevel(); + } + + public float getSaturation() { + if (!this.isPlayer || ((EntityPlayer) this.entity).getFoodStats() == null) { + return 0.0f; + } + return ((EntityPlayer) this.entity).getFoodStats().getSaturationLevel(); + } + + public float getAir() { + return this.entity.getAir(); + } + + public boolean isInvisible() { + return entity.isInvisible(); + } + + public boolean isInWater() { + return entity.isInWater(); + } + + public boolean isInLava() { + return entity.isInLava(); + } + + public Entity getFisher() { + if (this.entity instanceof EntityFishHook) { + return convert(((EntityFishHook) this.entity).angler); + } + return null; + } + + public boolean isInLiquid() { + return !this.entity.isOffsetPositionInLiquid(0, 0, 0); + } + + public boolean isOnLadder() { + if (this.isLiving) { + if (((EntityLivingBase) this.entity).isOnLadder()) { + return true; + } + } + return false; + } + + public boolean isOnEdge() { + return Utils.onEdge(this.entity); + } + + public boolean isSprinting() { + return entity.isSprinting(); + } + + public boolean isSneaking() { + return entity.isSneaking(); + } + + public boolean isUsingItem() { + if (!(entity instanceof EntityPlayer)) { + return false; + } + return (((EntityPlayer) entity).isUsingItem()); + } + + public boolean onGround() { + return entity.onGround; + } + + public void setMotion(double x, double y, double z) { + entity.motionX = x; + entity.motionY = y; + entity.motionZ = z; + } + + public Vec3 getMotion() { + return new Vec3(entity.motionX, entity.motionY, entity.motionZ); + } + + public void setPitch(float pitch) { + entity.rotationPitch = pitch; + } + + public void setYaw(float yaw) { + entity.rotationYaw = yaw; + } + + public void setPosition(Vec3 position) { + entity.setPosition(position.x, position.y, position.z); + } + + public void setPosition(double x, double y, double z) { + entity.setPosition(x, y, z); + } +} diff --git a/src/main/java/keystrokesmod/script/model/Image.java b/src/main/java/keystrokesmod/script/model/Image.java index e30ecd3..fcb1813 100644 --- a/src/main/java/keystrokesmod/script/model/Image.java +++ b/src/main/java/keystrokesmod/script/model/Image.java @@ -1,62 +1,62 @@ -package keystrokesmod.script.model; - -import keystrokesmod.script.ScriptDefaults; -import keystrokesmod.utility.NetworkUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; - -import java.awt.image.BufferedImage; -import java.util.HashMap; - -public class Image { - private static HashMap imageCache = new HashMap<>(); - public String url; - public BufferedImage bufferedImage; - public int height; - public int width; - public int textureId; - public boolean cached; - - public Image(String url, boolean cached) { - this.textureId = -1; - this.url = url; - this.cached = cached; - final BufferedImage cachedImage = cached ? imageCache.get(url) : null; - if (cachedImage == null) { - ScriptDefaults.client.async(() -> { - BufferedImage newImage = NetworkUtils.getImageFromURL(url); - if (newImage != null) { - this.bufferedImage = newImage; - this.height = newImage.getHeight(); - this.width = newImage.getWidth(); - if (cached) { - imageCache.put(url, newImage); - } - } - }); - } - else { - this.bufferedImage = cachedImage; - this.height = cachedImage.getHeight(); - this.width = cachedImage.getWidth(); - } - } - - public float[] getDimensions() { - final int scaleFactor = new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor(); - return new float[] { this.width / scaleFactor, this.height / scaleFactor }; - } - - public boolean isLoaded() { - return this.bufferedImage != null; - } - - public static void clearCache() { - imageCache.clear(); - } - - @Override - public String toString() { - return "Image(" + this.height + "," + this.width + "," + this.url + ")"; - } -} +package keystrokesmod.script.model; + +import keystrokesmod.script.ScriptDefaults; +import keystrokesmod.utility.NetworkUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; + +import java.awt.image.BufferedImage; +import java.util.HashMap; + +public class Image { + private static HashMap imageCache = new HashMap<>(); + public String url; + public BufferedImage bufferedImage; + public int height; + public int width; + public int textureId; + public boolean cached; + + public Image(String url, boolean cached) { + this.textureId = -1; + this.url = url; + this.cached = cached; + final BufferedImage cachedImage = cached ? imageCache.get(url) : null; + if (cachedImage == null) { + ScriptDefaults.client.async(() -> { + BufferedImage newImage = NetworkUtils.getImageFromURL(url); + if (newImage != null) { + this.bufferedImage = newImage; + this.height = newImage.getHeight(); + this.width = newImage.getWidth(); + if (cached) { + imageCache.put(url, newImage); + } + } + }); + } + else { + this.bufferedImage = cachedImage; + this.height = cachedImage.getHeight(); + this.width = cachedImage.getWidth(); + } + } + + public float[] getDimensions() { + final int scaleFactor = new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor(); + return new float[] { this.width / scaleFactor, this.height / scaleFactor }; + } + + public boolean isLoaded() { + return this.bufferedImage != null; + } + + public static void clearCache() { + imageCache.clear(); + } + + @Override + public String toString() { + return "Image(" + this.height + "," + this.width + "," + this.url + ")"; + } +} diff --git a/src/main/java/keystrokesmod/script/model/ItemStack.java b/src/main/java/keystrokesmod/script/model/ItemStack.java index 4b233f0..513e9b6 100644 --- a/src/main/java/keystrokesmod/script/model/ItemStack.java +++ b/src/main/java/keystrokesmod/script/model/ItemStack.java @@ -1,98 +1,98 @@ -package keystrokesmod.script.model; - -import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class ItemStack { - public String type; - public String name; - public String displayName; - public int stackSize; - public int maxStackSize; - public int durability; - public int maxDurability; - public boolean isBlock; - public net.minecraft.item.ItemStack itemStack; - public int meta; - - public ItemStack(net.minecraft.item.ItemStack itemStack, byte f1) { - if (itemStack == null) { - return; - } - this.itemStack = itemStack; - this.isBlock = itemStack.getItem() instanceof ItemBlock; - this.type = isBlock ? ((ItemBlock) itemStack.getItem()).getBlock().getClass().getSimpleName() : itemStack.getItem().getClass().getSimpleName(); - this.name = itemStack.getItem().getRegistryName().substring(10); // substring 10 to remove "minecraft:" - this.displayName = itemStack.getDisplayName(); - this.stackSize = itemStack.stackSize; - this.maxStackSize = itemStack.getMaxStackSize(); - this.durability = itemStack.getMaxDamage() - itemStack.getItemDamage(); - this.maxDurability = itemStack.getMaxDamage(); - this.meta = itemStack.getMetadata(); - } - - public ItemStack(String name) { - this(withMeta(name), (byte) 0); - } - - private static net.minecraft.item.ItemStack withMeta(String name) { - String[] parts = name.split(":"); - String itemName = parts[0]; - int meta = 0; - - if (parts.length > 1) { - meta = parseMeta(parts[1]); - } - - net.minecraft.item.Item item = Item.itemRegistry.getObject(new ResourceLocation("minecraft:" + itemName)); - return new net.minecraft.item.ItemStack(item, 1, meta); - } - - private static int parseMeta(String metaStr) { - try { - return Integer.parseInt(metaStr); - } - catch (NumberFormatException e) { - return 0; - } - } - - public List getTooltip() { - return this.itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, true); - } - - public List getEnchantments() { - Map enchants = EnchantmentHelper.getEnchantments(this.itemStack); - if (enchants.isEmpty()) { - return null; - } - List enchantments = new ArrayList<>(); - for (Map.Entry entry : enchants.entrySet()) { - Enchantment enchant = Enchantment.getEnchantmentById((int)entry.getKey()); - String name = StatCollector.translateToFallback(enchant.getName()).toLowerCase().replace(" ", "_"); - enchantments.add(new Object[] { name, entry.getValue() }); - } - return enchantments; - } - - public static ItemStack convert(net.minecraft.item.ItemStack itemStack) { - if (itemStack == null) { - return null; - } - return new ItemStack(itemStack, (byte) 0); - } - - @Override - public String toString() { - return "ItemStack(" + this.type + "," + this.name + ")"; - } -} +package keystrokesmod.script.model; + +import net.minecraft.client.Minecraft; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ItemStack { + public String type; + public String name; + public String displayName; + public int stackSize; + public int maxStackSize; + public int durability; + public int maxDurability; + public boolean isBlock; + public net.minecraft.item.ItemStack itemStack; + public int meta; + + public ItemStack(net.minecraft.item.ItemStack itemStack, byte f1) { + if (itemStack == null) { + return; + } + this.itemStack = itemStack; + this.isBlock = itemStack.getItem() instanceof ItemBlock; + this.type = isBlock ? ((ItemBlock) itemStack.getItem()).getBlock().getClass().getSimpleName() : itemStack.getItem().getClass().getSimpleName(); + this.name = itemStack.getItem().getRegistryName().substring(10); // substring 10 to remove "minecraft:" + this.displayName = itemStack.getDisplayName(); + this.stackSize = itemStack.stackSize; + this.maxStackSize = itemStack.getMaxStackSize(); + this.durability = itemStack.getMaxDamage() - itemStack.getItemDamage(); + this.maxDurability = itemStack.getMaxDamage(); + this.meta = itemStack.getMetadata(); + } + + public ItemStack(String name) { + this(withMeta(name), (byte) 0); + } + + private static net.minecraft.item.ItemStack withMeta(String name) { + String[] parts = name.split(":"); + String itemName = parts[0]; + int meta = 0; + + if (parts.length > 1) { + meta = parseMeta(parts[1]); + } + + net.minecraft.item.Item item = Item.itemRegistry.getObject(new ResourceLocation("minecraft:" + itemName)); + return new net.minecraft.item.ItemStack(item, 1, meta); + } + + private static int parseMeta(String metaStr) { + try { + return Integer.parseInt(metaStr); + } + catch (NumberFormatException e) { + return 0; + } + } + + public List getTooltip() { + return this.itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, true); + } + + public List getEnchantments() { + Map enchants = EnchantmentHelper.getEnchantments(this.itemStack); + if (enchants.isEmpty()) { + return null; + } + List enchantments = new ArrayList<>(); + for (Map.Entry entry : enchants.entrySet()) { + Enchantment enchant = Enchantment.getEnchantmentById((int)entry.getKey()); + String name = StatCollector.translateToFallback(enchant.getName()).toLowerCase().replace(" ", "_"); + enchantments.add(new Object[] { name, entry.getValue() }); + } + return enchantments; + } + + public static ItemStack convert(net.minecraft.item.ItemStack itemStack) { + if (itemStack == null) { + return null; + } + return new ItemStack(itemStack, (byte) 0); + } + + @Override + public String toString() { + return "ItemStack(" + this.type + "," + this.name + ")"; + } +} diff --git a/src/main/java/keystrokesmod/script/model/Json.java b/src/main/java/keystrokesmod/script/model/Json.java index 98be337..a6dc97b 100644 --- a/src/main/java/keystrokesmod/script/model/Json.java +++ b/src/main/java/keystrokesmod/script/model/Json.java @@ -1,189 +1,189 @@ -package keystrokesmod.script.model; - -import com.google.gson.*; -import java.util.*; - -public class Json { - public enum Type { OBJECT, ARRAY, STRING, NUMBER, BOOLEAN, NULL } - - private final JsonElement element; - private final Type type; - - private Json(JsonElement element) { - this.element = element; - if (element.isJsonObject()) { - this.type = Type.OBJECT; - } - else if (element.isJsonArray()) { - this.type = Type.ARRAY; - } - else if (element.isJsonPrimitive()) { - JsonPrimitive prim = element.getAsJsonPrimitive(); - if (prim.isBoolean()) { - this.type = Type.BOOLEAN; - } - else if (prim.isNumber()) { - this.type = Type.NUMBER; - } - else { - this.type = Type.STRING; - } - } - else if (element.isJsonNull()) { - this.type = Type.NULL; - } - else { - this.type = Type.NULL; - } - } - - public static Json parse(String jsonString) { - return new Json(new JsonParser().parse(jsonString)); - } - - public static Json object() { - return new Json(new JsonObject()); - } - - public static Json array() { - return new Json(new JsonArray()); - } - - public static Json string(String value) { - return new Json(new JsonPrimitive(value)); - } - - public static Json number(Number value) { - return new Json(new JsonPrimitive(value)); - } - - public static Json booleanValue(boolean value) { - return new Json(new JsonPrimitive(value)); - } - - public static Json nullValue() { - return new Json(JsonNull.INSTANCE); - } - - public Type type() { - return type; - } - - private void ensureObject() { - if (type != Type.OBJECT) { - throw new IllegalStateException("Not a JSON object: " + type); - } - } - - public Json add(String key, Json value) { - ensureObject(); - this.element.getAsJsonObject().add(key, value.element); - return this; - } - - public Json add(String key, String val) { - return add(key, Json.string(val)); - } - - public Json add(String key, Number val) { - return add(key, Json.number(val)); - } - - public Json add(String key, boolean val) { - return add(key, Json.booleanValue(val)); - } - - public Json get(String key) { - ensureObject(); - JsonElement child = this.element.getAsJsonObject().get(key); - return child == null ? Json.nullValue() : new Json(child); - } - - public boolean has(String key) { - ensureObject(); - return this.element.getAsJsonObject().has(key); - } - - private void ensureArray() { - if (type != Type.ARRAY) { - throw new IllegalStateException("Not a JSON array: " + type); - } - } - - public Json add(Json value) { - ensureArray(); - this.element.getAsJsonArray().add(value.element); - return this; - } - - public Json add(String val) { - return add(Json.string(val)); - } - - public Json add(Number val) { - return add(Json.number(val)); - } - - public Json add(boolean val) { - return add(Json.booleanValue(val)); - } - - public List asArray() { - ensureArray(); - List list = new ArrayList<>(); - for (JsonElement el : this.element.getAsJsonArray()) { - list.add(new Json(el)); - } - return list; - } - - private void ensurePrimitive() { - if (type != Type.STRING && type != Type.NUMBER && type != Type.BOOLEAN) { - throw new IllegalStateException("Not a primitive: " + type); - } - } - - public String asString() { - ensurePrimitive(); - return element.getAsString(); - } - - public int asInt() { - ensurePrimitive(); - return element.getAsInt(); - } - - public double asDouble() { - ensurePrimitive(); - return element.getAsDouble(); - } - - public long asLong() { - ensurePrimitive(); - return element.getAsLong(); - } - - public float asFloat() { - ensurePrimitive(); - return element.getAsFloat(); - } - - public boolean asBoolean() { - ensurePrimitive(); - return element.getAsBoolean(); - } - - public LinkedHashSet keys() { - ensureObject(); - LinkedHashSet out = new LinkedHashSet<>(); - for (Map.Entry e : element.getAsJsonObject().entrySet()) { - out.add(e.getKey()); - } - return out; - } - - @Override - public String toString() { - return element.toString(); - } +package keystrokesmod.script.model; + +import com.google.gson.*; +import java.util.*; + +public class Json { + public enum Type { OBJECT, ARRAY, STRING, NUMBER, BOOLEAN, NULL } + + private final JsonElement element; + private final Type type; + + private Json(JsonElement element) { + this.element = element; + if (element.isJsonObject()) { + this.type = Type.OBJECT; + } + else if (element.isJsonArray()) { + this.type = Type.ARRAY; + } + else if (element.isJsonPrimitive()) { + JsonPrimitive prim = element.getAsJsonPrimitive(); + if (prim.isBoolean()) { + this.type = Type.BOOLEAN; + } + else if (prim.isNumber()) { + this.type = Type.NUMBER; + } + else { + this.type = Type.STRING; + } + } + else if (element.isJsonNull()) { + this.type = Type.NULL; + } + else { + this.type = Type.NULL; + } + } + + public static Json parse(String jsonString) { + return new Json(new JsonParser().parse(jsonString)); + } + + public static Json object() { + return new Json(new JsonObject()); + } + + public static Json array() { + return new Json(new JsonArray()); + } + + public static Json string(String value) { + return new Json(new JsonPrimitive(value)); + } + + public static Json number(Number value) { + return new Json(new JsonPrimitive(value)); + } + + public static Json booleanValue(boolean value) { + return new Json(new JsonPrimitive(value)); + } + + public static Json nullValue() { + return new Json(JsonNull.INSTANCE); + } + + public Type type() { + return type; + } + + private void ensureObject() { + if (type != Type.OBJECT) { + throw new IllegalStateException("Not a JSON object: " + type); + } + } + + public Json add(String key, Json value) { + ensureObject(); + this.element.getAsJsonObject().add(key, value.element); + return this; + } + + public Json add(String key, String val) { + return add(key, Json.string(val)); + } + + public Json add(String key, Number val) { + return add(key, Json.number(val)); + } + + public Json add(String key, boolean val) { + return add(key, Json.booleanValue(val)); + } + + public Json get(String key) { + ensureObject(); + JsonElement child = this.element.getAsJsonObject().get(key); + return child == null ? Json.nullValue() : new Json(child); + } + + public boolean has(String key) { + ensureObject(); + return this.element.getAsJsonObject().has(key); + } + + private void ensureArray() { + if (type != Type.ARRAY) { + throw new IllegalStateException("Not a JSON array: " + type); + } + } + + public Json add(Json value) { + ensureArray(); + this.element.getAsJsonArray().add(value.element); + return this; + } + + public Json add(String val) { + return add(Json.string(val)); + } + + public Json add(Number val) { + return add(Json.number(val)); + } + + public Json add(boolean val) { + return add(Json.booleanValue(val)); + } + + public List asArray() { + ensureArray(); + List list = new ArrayList<>(); + for (JsonElement el : this.element.getAsJsonArray()) { + list.add(new Json(el)); + } + return list; + } + + private void ensurePrimitive() { + if (type != Type.STRING && type != Type.NUMBER && type != Type.BOOLEAN) { + throw new IllegalStateException("Not a primitive: " + type); + } + } + + public String asString() { + ensurePrimitive(); + return element.getAsString(); + } + + public int asInt() { + ensurePrimitive(); + return element.getAsInt(); + } + + public double asDouble() { + ensurePrimitive(); + return element.getAsDouble(); + } + + public long asLong() { + ensurePrimitive(); + return element.getAsLong(); + } + + public float asFloat() { + ensurePrimitive(); + return element.getAsFloat(); + } + + public boolean asBoolean() { + ensurePrimitive(); + return element.getAsBoolean(); + } + + public LinkedHashSet keys() { + ensureObject(); + LinkedHashSet out = new LinkedHashSet<>(); + for (Map.Entry e : element.getAsJsonObject().entrySet()) { + out.add(e.getKey()); + } + return out; + } + + @Override + public String toString() { + return element.toString(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/model/Message.java b/src/main/java/keystrokesmod/script/model/Message.java index 31e9075..2595504 100644 --- a/src/main/java/keystrokesmod/script/model/Message.java +++ b/src/main/java/keystrokesmod/script/model/Message.java @@ -1,55 +1,55 @@ -package keystrokesmod.script.model; - -import keystrokesmod.utility.Utils; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.IChatComponent; - -import java.util.ArrayList; -import java.util.List; - -public class Message { - public ChatComponentText component; - - public Message(String message) { - this.component = new ChatComponentText(message); - } - - public void appendStyle(String style, String action, String styleMessage, String message) { - ChatStyle chatStyle = new ChatStyle(); - if (style.equals("HOVER")) { - chatStyle.setChatHoverEvent(new HoverEvent(Utils.getEnum(HoverEvent.Action.class, action), new ChatComponentText(styleMessage))); - } - else if (style.equals("CLICK")) { - chatStyle.setChatClickEvent(new ClickEvent(Utils.getEnum(ClickEvent.Action.class, action), styleMessage)); - } - component.appendSibling(new ChatComponentText(message).setChatStyle(chatStyle)); - } - - public void append(String append) { - component.appendSibling(new ChatComponentText(append)); - } - - public List getSiblings() { - List siblings = new ArrayList<>(); - for (IChatComponent sibling : this.component.getSiblings()) { - siblings.add(new Message(sibling.getUnformattedTextForChat())); - } - return siblings; - } - - public String getStyle() { - return this.component.getChatStyle().toString(); - } - - public String getText() { - return this.component.getUnformattedTextForChat(); - } - - @Override - public String toString() { - return "TextComponent{text='" + this.component.getUnformattedTextForChat() + '\'' + ", siblings=" + this.component.getSiblings() + ", style=" + this.component.getChatStyle() + '}'; - } +package keystrokesmod.script.model; + +import keystrokesmod.utility.Utils; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; + +import java.util.ArrayList; +import java.util.List; + +public class Message { + public ChatComponentText component; + + public Message(String message) { + this.component = new ChatComponentText(message); + } + + public void appendStyle(String style, String action, String styleMessage, String message) { + ChatStyle chatStyle = new ChatStyle(); + if (style.equals("HOVER")) { + chatStyle.setChatHoverEvent(new HoverEvent(Utils.getEnum(HoverEvent.Action.class, action), new ChatComponentText(styleMessage))); + } + else if (style.equals("CLICK")) { + chatStyle.setChatClickEvent(new ClickEvent(Utils.getEnum(ClickEvent.Action.class, action), styleMessage)); + } + component.appendSibling(new ChatComponentText(message).setChatStyle(chatStyle)); + } + + public void append(String append) { + component.appendSibling(new ChatComponentText(append)); + } + + public List getSiblings() { + List siblings = new ArrayList<>(); + for (IChatComponent sibling : this.component.getSiblings()) { + siblings.add(new Message(sibling.getUnformattedTextForChat())); + } + return siblings; + } + + public String getStyle() { + return this.component.getChatStyle().toString(); + } + + public String getText() { + return this.component.getUnformattedTextForChat(); + } + + @Override + public String toString() { + return "TextComponent{text='" + this.component.getUnformattedTextForChat() + '\'' + ", siblings=" + this.component.getSiblings() + ", style=" + this.component.getChatStyle() + '}'; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/model/MovementInput.java b/src/main/java/keystrokesmod/script/model/MovementInput.java new file mode 100644 index 0000000..027f56f --- /dev/null +++ b/src/main/java/keystrokesmod/script/model/MovementInput.java @@ -0,0 +1,43 @@ +package keystrokesmod.script.model; + +import keystrokesmod.event.PrePlayerInputEvent; + +public class MovementInput { + public float forward; + public float strafe; + public boolean jump; + public boolean sneak; + + public MovementInput(PrePlayerInputEvent event, byte f1) { + this.forward = event.getForward(); + this.strafe = event.getStrafe(); + this.jump = event.isJump(); + this.sneak = event.isSneak(); + } + + public MovementInput(float forward, float strafe, boolean jump, boolean sneak) { + this.forward = forward; + this.strafe = strafe; + this.jump = jump; + this.sneak = sneak; + } + + public MovementInput(Object[] state) { + this.forward = (float) state[0]; + this.strafe = (float) state[1]; + this.jump = (boolean) state[2]; + this.sneak = (boolean) state[3]; + } + + public Object[] asArray() { + return new Object[] { this.forward, this.strafe, this.jump, this.sneak }; + } + + public boolean equals(MovementInput input) { + if (input == null) { + return false; + } + return this.forward == input.forward && this.strafe == input.strafe && this.jump == input.jump && this.sneak == input.sneak; + } + +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/model/NetworkPlayer.java b/src/main/java/keystrokesmod/script/model/NetworkPlayer.java index 403a225..0c5ab9e 100644 --- a/src/main/java/keystrokesmod/script/model/NetworkPlayer.java +++ b/src/main/java/keystrokesmod/script/model/NetworkPlayer.java @@ -1,75 +1,75 @@ -package keystrokesmod.script.model; - -import com.google.common.collect.Iterables; -import com.mojang.authlib.properties.Property; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; -import java.util.HashMap; - -public class NetworkPlayer { - private NetworkPlayerInfo playerInfo; - private static HashMap cache = new HashMap<>(); - - public NetworkPlayer(NetworkPlayerInfo playerInfo) { - this.playerInfo = playerInfo; - } - - public String getCape() { - return playerInfo.getLocationCape().getResourcePath(); - } - - public String getDisplayName() { - return (this.playerInfo.getGameProfile() == Minecraft.getMinecraft().thePlayer.getGameProfile()) ? Minecraft.getMinecraft().thePlayer.getDisplayName().getUnformattedText() : ScorePlayerTeam.formatPlayerName(this.playerInfo.getPlayerTeam(), this.getName()); - } - - public String getName() { - if (playerInfo == null) { - return ""; - } - return playerInfo.getGameProfile().getName(); - } - - public int getPing() { - if (playerInfo == null) { - return 0; - } - return playerInfo.getResponseTime(); - } - - public String getSkinData() { - final Property texture = (Property) Iterables.getFirst(playerInfo.getGameProfile().getProperties().get("textures"), (Object)null); - if (texture == null) { - return null; - } - return new String(Base64.getDecoder().decode(texture.getValue().getBytes(StandardCharsets.UTF_8))); - } - - public String getUUID() { - if (playerInfo == null) { - return ""; - } - return playerInfo.getGameProfile().getId().toString(); - } - - public static NetworkPlayer convert(NetworkPlayerInfo networkPlayerInfo) { - if (networkPlayerInfo == null) { - return null; - } - String id = networkPlayerInfo.getGameProfile().getId().toString(); - NetworkPlayer cachedEntity = cache.get(id); - - if (cachedEntity == null) { - cachedEntity = new NetworkPlayer(networkPlayerInfo); - cache.put(id, cachedEntity); - } - return cachedEntity; - } - - public static void clearCache() { - cache.clear(); - } -} +package keystrokesmod.script.model; + +import com.google.common.collect.Iterables; +import com.mojang.authlib.properties.Property; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; + +public class NetworkPlayer { + private NetworkPlayerInfo playerInfo; + private static HashMap cache = new HashMap<>(); + + public NetworkPlayer(NetworkPlayerInfo playerInfo) { + this.playerInfo = playerInfo; + } + + public String getCape() { + return playerInfo.getLocationCape().getResourcePath(); + } + + public String getDisplayName() { + return (this.playerInfo.getGameProfile() == Minecraft.getMinecraft().thePlayer.getGameProfile()) ? Minecraft.getMinecraft().thePlayer.getDisplayName().getUnformattedText() : ScorePlayerTeam.formatPlayerName(this.playerInfo.getPlayerTeam(), this.getName()); + } + + public String getName() { + if (playerInfo == null) { + return ""; + } + return playerInfo.getGameProfile().getName(); + } + + public int getPing() { + if (playerInfo == null) { + return 0; + } + return playerInfo.getResponseTime(); + } + + public String getSkinData() { + final Property texture = (Property) Iterables.getFirst(playerInfo.getGameProfile().getProperties().get("textures"), (Object)null); + if (texture == null) { + return null; + } + return new String(Base64.getDecoder().decode(texture.getValue().getBytes(StandardCharsets.UTF_8))); + } + + public String getUUID() { + if (playerInfo == null) { + return ""; + } + return playerInfo.getGameProfile().getId().toString(); + } + + public static NetworkPlayer convert(NetworkPlayerInfo networkPlayerInfo) { + if (networkPlayerInfo == null) { + return null; + } + String id = networkPlayerInfo.getGameProfile().getId().toString(); + NetworkPlayer cachedEntity = cache.get(id); + + if (cachedEntity == null) { + cachedEntity = new NetworkPlayer(networkPlayerInfo); + cache.put(id, cachedEntity); + } + return cachedEntity; + } + + public static void clearCache() { + cache.clear(); + } +} diff --git a/src/main/java/keystrokesmod/script/model/PlayerState.java b/src/main/java/keystrokesmod/script/model/PlayerState.java index ef29c82..c3868b1 100644 --- a/src/main/java/keystrokesmod/script/model/PlayerState.java +++ b/src/main/java/keystrokesmod/script/model/PlayerState.java @@ -1,47 +1,47 @@ -package keystrokesmod.script.model; - -import keystrokesmod.event.PreMotionEvent; - -public class PlayerState { - public double x; - public double y; - public double z; - public float yaw; - public float pitch; - public boolean onGround; - public boolean isSprinting; - public boolean isSneaking; - - public PlayerState(PreMotionEvent e, byte f1) { - this.x = e.getPosX(); - this.y = e.getPosY(); - this.z = e.getPosZ(); - this.yaw = e.getYaw(); - this.pitch = e.getPitch(); - this.onGround = e.isOnGround(); - this.isSprinting = e.isSprinting(); - this.isSneaking = e.isSneaking(); - } - - public PlayerState(Object[] state) { - this.x = (double) state[0]; - this.y = (double) state[1]; - this.z = (double) state[2]; - this.yaw = (float) state[3]; - this.pitch = (float) state[4]; - this.onGround = (boolean) state[5]; - this.isSprinting = (boolean) state[6]; - this.isSneaking = (boolean) state[7]; - } - - public Object[] asArray() { - return new Object[] { this.x, this.y, this.z, this.yaw, this.pitch, this.onGround, this.isSprinting, this.isSneaking }; - } - - public boolean equals(PlayerState playerState) { - if (playerState == null) { - return false; - } - return this.x == playerState.x && this.y == playerState.y && this.z == playerState.z && this.yaw == playerState.yaw && this.pitch == playerState.pitch && this.onGround == playerState.onGround && this.isSprinting == playerState.isSprinting && this.isSneaking == playerState.isSneaking; - } -} +package keystrokesmod.script.model; + +import keystrokesmod.event.PreMotionEvent; + +public class PlayerState { + public double x; + public double y; + public double z; + public float yaw; + public float pitch; + public boolean onGround; + public boolean isSprinting; + public boolean isSneaking; + + public PlayerState(PreMotionEvent e, byte f1) { + this.x = e.getPosX(); + this.y = e.getPosY(); + this.z = e.getPosZ(); + this.yaw = e.getYaw(); + this.pitch = e.getPitch(); + this.onGround = e.isOnGround(); + this.isSprinting = e.isSprinting(); + this.isSneaking = e.isSneaking(); + } + + public PlayerState(Object[] state) { + this.x = (double) state[0]; + this.y = (double) state[1]; + this.z = (double) state[2]; + this.yaw = (float) state[3]; + this.pitch = (float) state[4]; + this.onGround = (boolean) state[5]; + this.isSprinting = (boolean) state[6]; + this.isSneaking = (boolean) state[7]; + } + + public Object[] asArray() { + return new Object[] { this.x, this.y, this.z, this.yaw, this.pitch, this.onGround, this.isSprinting, this.isSneaking }; + } + + public boolean equals(PlayerState playerState) { + if (playerState == null) { + return false; + } + return this.x == playerState.x && this.y == playerState.y && this.z == playerState.z && this.yaw == playerState.yaw && this.pitch == playerState.pitch && this.onGround == playerState.onGround && this.isSprinting == playerState.isSprinting && this.isSneaking == playerState.isSneaking; + } +} diff --git a/src/main/java/keystrokesmod/script/model/Request.java b/src/main/java/keystrokesmod/script/model/Request.java index 0acac77..f8f0e13 100644 --- a/src/main/java/keystrokesmod/script/model/Request.java +++ b/src/main/java/keystrokesmod/script/model/Request.java @@ -1,169 +1,169 @@ -package keystrokesmod.script.model; - -import keystrokesmod.script.Manager; -import keystrokesmod.utility.NetworkUtils; -import keystrokesmod.utility.Utils; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - -public class Request { - public String method; - public String url; - public List headers = new ArrayList<>(); - public String userAgent; - public int connectionTimeout; - public int readTimeout; - public String content = ""; - - public Request(String method, String URL) { - if (!method.equals("POST") && !method.equals("GET")) { - this.method = "GET"; - } - else { - this.method = method; - } - this.url = URL; - this.userAgent = ""; - this.readTimeout = 5000; - this.connectionTimeout = 5000; - - } - - public void addHeader(final String header, final String value) { - if (this.headers == null) { - this.headers = new ArrayList<>(); - } - this.headers.add(new String[] { header, value }); - } - - public void setUserAgent(String userAgent) { - this.userAgent = userAgent; - } - - public void setConnectTimeout(int timeout) { - this.connectionTimeout = timeout; - } - - public void setReadTimeout(int timeout) { - this.readTimeout = timeout; - } - - public void setContent(String content) { - this.content = content; - } - - public Response fetch() { - if (!Manager.enableHttpRequests.isToggled()) { - Utils.sendMessage("&cFailed to send http request, http requests are not enabled."); - return new Response(404, ""); - } - if (!this.url.isEmpty()) { - HttpURLConnection con = null; - try { - final URL url = new URL(this.url); - con = (HttpURLConnection)url.openConnection(); - con.setRequestMethod(this.method); - con.setConnectTimeout(this.connectionTimeout); - con.setReadTimeout(this.readTimeout); - con.setRequestProperty("User-Agent", this.userAgent.isEmpty() ? NetworkUtils.CHROME_USER_AGENT : this.userAgent); - if (this.headers != null && !this.headers.isEmpty()) { - for (final String[] header : this.headers) { - con.setRequestProperty(header[0], header[1]); - } - } - if (this.method.equals("POST") && !this.content.isEmpty()) { - con.setDoOutput(true); - final byte[] out = this.content.getBytes(StandardCharsets.UTF_8); - con.setFixedLengthStreamingMode(out.length); - con.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); - con.connect(); - final OutputStream os = con.getOutputStream(); - try { - os.write(out); - if (os != null) { - os.close(); - } - } - catch (Throwable t) { - if (os != null) { - try { - os.close(); - } - catch (Throwable t2) { - t.addSuppressed(t2); - } - } - throw t; - } - } - String contents = ""; - try { - final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); - try { - final StringBuilder sb = new StringBuilder(); - String input; - while ((input = br.readLine()) != null) { - sb.append(input); - } - contents = sb.toString(); - br.close(); - } - catch (Throwable t3) { - try { - br.close(); - } - catch (Throwable t4) { - t3.addSuppressed(t4); - } - throw t3; - } - } - catch (IOException er1) { - InputStream errorStream = con.getErrorStream(); - if (errorStream != null) { - try { - final BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream)); - try { - final StringBuilder sb2 = new StringBuilder(); - String input2; - while ((input2 = errorReader.readLine()) != null) { - sb2.append(input2); - } - contents = sb2.toString(); - errorReader.close(); - } - catch (Throwable t5) { - try { - errorReader.close(); - } - catch (Throwable t6) { - t5.addSuppressed(t6); - } - throw t5; - } - } - catch (IOException ex) {} - } - } - return new Response(con.getResponseCode(), contents); - } - catch (IOException ex2) {} - finally { - if (con != null) { - con.disconnect(); - } - } - } - return null; - } - - @Override - public String toString() { - return "Request(" + this.method + "," + this.url + ")"; - } -} +package keystrokesmod.script.model; + +import keystrokesmod.script.Manager; +import keystrokesmod.utility.NetworkUtils; +import keystrokesmod.utility.Utils; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +public class Request { + public String method; + public String url; + public List headers = new ArrayList<>(); + public String userAgent; + public int connectionTimeout; + public int readTimeout; + public String content = ""; + + public Request(String method, String URL) { + if (!method.equals("POST") && !method.equals("GET")) { + this.method = "GET"; + } + else { + this.method = method; + } + this.url = URL; + this.userAgent = ""; + this.readTimeout = 5000; + this.connectionTimeout = 5000; + + } + + public void addHeader(final String header, final String value) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(new String[] { header, value }); + } + + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + public void setConnectTimeout(int timeout) { + this.connectionTimeout = timeout; + } + + public void setReadTimeout(int timeout) { + this.readTimeout = timeout; + } + + public void setContent(String content) { + this.content = content; + } + + public Response fetch() { + if (!Manager.enableHttpRequests.isToggled()) { + Utils.sendMessage("&cFailed to send http request, http requests are not enabled."); + return new Response(404, ""); + } + if (!this.url.isEmpty()) { + HttpURLConnection con = null; + try { + final URL url = new URL(this.url); + con = (HttpURLConnection)url.openConnection(); + con.setRequestMethod(this.method); + con.setConnectTimeout(this.connectionTimeout); + con.setReadTimeout(this.readTimeout); + con.setRequestProperty("User-Agent", this.userAgent.isEmpty() ? NetworkUtils.CHROME_USER_AGENT : this.userAgent); + if (this.headers != null && !this.headers.isEmpty()) { + for (final String[] header : this.headers) { + con.setRequestProperty(header[0], header[1]); + } + } + if (this.method.equals("POST") && !this.content.isEmpty()) { + con.setDoOutput(true); + final byte[] out = this.content.getBytes(StandardCharsets.UTF_8); + con.setFixedLengthStreamingMode(out.length); + con.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + con.connect(); + final OutputStream os = con.getOutputStream(); + try { + os.write(out); + if (os != null) { + os.close(); + } + } + catch (Throwable t) { + if (os != null) { + try { + os.close(); + } + catch (Throwable t2) { + t.addSuppressed(t2); + } + } + throw t; + } + } + String contents = ""; + try { + final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); + try { + final StringBuilder sb = new StringBuilder(); + String input; + while ((input = br.readLine()) != null) { + sb.append(input); + } + contents = sb.toString(); + br.close(); + } + catch (Throwable t3) { + try { + br.close(); + } + catch (Throwable t4) { + t3.addSuppressed(t4); + } + throw t3; + } + } + catch (IOException er1) { + InputStream errorStream = con.getErrorStream(); + if (errorStream != null) { + try { + final BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream)); + try { + final StringBuilder sb2 = new StringBuilder(); + String input2; + while ((input2 = errorReader.readLine()) != null) { + sb2.append(input2); + } + contents = sb2.toString(); + errorReader.close(); + } + catch (Throwable t5) { + try { + errorReader.close(); + } + catch (Throwable t6) { + t5.addSuppressed(t6); + } + throw t5; + } + } + catch (IOException ex) {} + } + } + return new Response(con.getResponseCode(), contents); + } + catch (IOException ex2) {} + finally { + if (con != null) { + con.disconnect(); + } + } + } + return null; + } + + @Override + public String toString() { + return "Request(" + this.method + "," + this.url + ")"; + } +} diff --git a/src/main/java/keystrokesmod/script/model/Response.java b/src/main/java/keystrokesmod/script/model/Response.java index 3976aa3..7741498 100644 --- a/src/main/java/keystrokesmod/script/model/Response.java +++ b/src/main/java/keystrokesmod/script/model/Response.java @@ -1,28 +1,28 @@ -package keystrokesmod.script.model; - -public class Response { - private int responseCode; - private String contents; - - public Response(int responseCode, String contents) { - this.responseCode = responseCode; - this.contents = contents; - } - - public int code() { - return this.responseCode; - } - - public String string() { - return this.contents; - } - - public Json json() { - return (this.contents == null) ? null : Json.parse(this.contents); - } - - @Override - public String toString() { - return "Response(" + this.responseCode + ")"; - } -} +package keystrokesmod.script.model; + +public class Response { + private int responseCode; + private String contents; + + public Response(int responseCode, String contents) { + this.responseCode = responseCode; + this.contents = contents; + } + + public int code() { + return this.responseCode; + } + + public String string() { + return this.contents; + } + + public Json json() { + return (this.contents == null) ? null : Json.parse(this.contents); + } + + @Override + public String toString() { + return "Response(" + this.responseCode + ")"; + } +} diff --git a/src/main/java/keystrokesmod/script/model/SimulatedPlayer.java b/src/main/java/keystrokesmod/script/model/SimulatedPlayer.java new file mode 100644 index 0000000..2ba9925 --- /dev/null +++ b/src/main/java/keystrokesmod/script/model/SimulatedPlayer.java @@ -0,0 +1,1236 @@ +package keystrokesmod.script.model; + +import com.google.common.base.Predicate; +import com.google.common.collect.Lists; +import keystrokesmod.mixin.impl.accessor.IAccessorEntity; +import keystrokesmod.mixin.impl.accessor.IAccessorEntityLivingBase; +import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.EnchantmentProtection; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.ServersideAttributeMap; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.*; +import net.minecraft.util.MovementInput; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.border.WorldBorder; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.List; + +public class SimulatedPlayer { + private static final Minecraft mc = Minecraft.getMinecraft(); + + private final EntityPlayerSP player; + public AxisAlignedBB box; + public final MovementInput movementInput; + private int jumpTicks; + public double motionZ; + public double motionY; + public double motionX; + private boolean inWater; + public boolean onGround; + private boolean isAirBorne; + public float rotationYaw; + private double posX; + private double posY; + private double posZ; + private final PlayerCapabilities capabilities; + private final Entity ridingEntity; + private float jumpMovementFactor; + private final World worldObj; + public boolean isCollidedHorizontally; + private boolean isCollidedVertically; + private final WorldBorder worldBorder; + private final IChunkProvider chunkProvider; + private boolean isOutsideBorder; + private final Entity riddenByEntity; + private BaseAttributeMap attributeMap; + private final boolean isSpectator; + public float fallDistance; + private final float stepHeight; + private boolean isCollided; + private int fire; + private float distanceWalkedModified; + private float distanceWalkedOnStepModified; + private int nextStepDistance; + public final float height; + private final float width; + private final int fireResistance; + private boolean isInWeb; + private boolean noClip; + private boolean isSprinting; + private final FoodStats foodStats; + + public SimulatedPlayer(EntityPlayerSP player, AxisAlignedBB box, net.minecraft.util.MovementInput movementInput, int jumpTicks, double motionZ, double motionY, double motionX, boolean inWater, boolean onGround, boolean isAirBorne, float rotationYaw, double posX, double posY, double posZ, PlayerCapabilities capabilities, Entity ridingEntity, float jumpMovementFactor, World worldObj, boolean isCollidedHorizontally, boolean isCollidedVertically, WorldBorder worldBorder, IChunkProvider chunkProvider, boolean isOutsideBorder, Entity riddenByEntity, BaseAttributeMap attributeMap, boolean isSpectator, float fallDistance, float stepHeight, boolean isCollided, int fire, float distanceWalkedModified, float distanceWalkedOnStepModified, int nextStepDistance, float height, float width, int fireResistance, boolean isInWeb, boolean noClip, boolean isSprinting, FoodStats foodStats) { + this.player = player; + this.box = box; + this.movementInput = movementInput; + this.jumpTicks = jumpTicks; + this.motionZ = motionZ; + this.motionY = motionY; + this.motionX = motionX; + this.inWater = inWater; + this.onGround = onGround; + this.isAirBorne = isAirBorne; + this.rotationYaw = rotationYaw; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.capabilities = capabilities; + this.ridingEntity = ridingEntity; + this.jumpMovementFactor = jumpMovementFactor; + this.worldObj = worldObj; + this.isCollidedHorizontally = isCollidedHorizontally; + this.isCollidedVertically = isCollidedVertically; + this.worldBorder = worldBorder; + this.chunkProvider = chunkProvider; + this.isOutsideBorder = isOutsideBorder; + this.riddenByEntity = riddenByEntity; + this.attributeMap = attributeMap; + this.isSpectator = isSpectator; + this.fallDistance = fallDistance; + this.stepHeight = stepHeight; + this.isCollided = isCollided; + this.fire = fire; + this.distanceWalkedModified = distanceWalkedModified; + this.distanceWalkedOnStepModified = distanceWalkedOnStepModified; + this.nextStepDistance = nextStepDistance; + this.height = height; + this.width = width; + this.fireResistance = fireResistance; + this.isInWeb = isInWeb; + this.noClip = noClip; + this.isSprinting = isSprinting; + this.foodStats = foodStats; + } + + public Vec3 getPos() { + return new Vec3(posX, posY, posZ); + } + + private float moveForward = 0f; + private float moveStrafing = 0f; + private boolean isJumping = false; + + public boolean safeWalk = false; + + private static final float SPEED_IN_AIR = 0.02F; + + public static SimulatedPlayer fromClientPlayer(net.minecraft.util.MovementInput input) { + EntityPlayerSP player = mc.thePlayer; + + PlayerCapabilities capabilities = createCapabilitiesCopy(player); + FoodStats foodStats = createFoodStatsCopy(player); + + net.minecraft.util.MovementInput movementInput = new net.minecraft.util.MovementInput(); + movementInput.jump = input.jump; + movementInput.moveForward = input.moveForward; + movementInput.moveStrafe = input.moveStrafe; + movementInput.sneak = input.sneak; + + return new SimulatedPlayer(player, + player.getEntityBoundingBox(), + movementInput, + ((IAccessorEntityLivingBase) player).getJumpTicks(), + player.motionZ, + player.motionY, + player.motionX, + player.isInWater(), + player.onGround, + player.isAirBorne, + player.rotationYaw, + player.posX, + player.posY, + player.posZ, + capabilities, + player.ridingEntity, + player.jumpMovementFactor, + player.worldObj, + player.isCollidedHorizontally, + player.isCollidedVertically, + player.worldObj.getWorldBorder(), + player.worldObj.getChunkProvider(), + player.isOutsideBorder(), + player.riddenByEntity, + player.getAttributeMap(), + player.isSpectator(), + player.fallDistance, + player.stepHeight, + player.isCollided, + ((IAccessorEntity) player).getFire(), + player.distanceWalkedModified, + player.distanceWalkedOnStepModified, + ((IAccessorEntity) player).getNextStepDistance(), + player.height, + player.width, + player.fireResistance, + ((IAccessorEntity) player).getIsInWeb(), + player.noClip, + player.isSprinting(), + foodStats + ); + } + + private static FoodStats createFoodStatsCopy(EntityPlayerSP player) { + NBTTagCompound foodStatsNBT = new NBTTagCompound(); + FoodStats foodStats = new FoodStats(); + + player.getFoodStats().writeNBT(foodStatsNBT); + foodStats.readNBT(foodStatsNBT); + return foodStats; + } + + private static PlayerCapabilities createCapabilitiesCopy(EntityPlayerSP player) { + NBTTagCompound capabilitiesNBT = new NBTTagCompound(); + PlayerCapabilities capabilities = new PlayerCapabilities(); + + player.capabilities.writeCapabilitiesToNBT(capabilitiesNBT); + capabilities.readCapabilitiesFromNBT(capabilitiesNBT); + + return capabilities; + } + + private boolean onEntityUpdate() { + handleWaterMovement(); + if (worldObj.isRemote) { + fire = 0; + } else if (fire > 0) { + --fire; + } + + if (isInLava()) { + setOnFireFromLava(); + fallDistance *= 0.5f; + } + + return !(posY < -64.0); + } + + public void tick() { + if (!onEntityUpdate() || player.isRiding()) { + return; + } + + playerUpdate(false); + clientPlayerLivingUpdate(); + playerUpdate(true); + } + + private void clientPlayerLivingUpdate() { + pushOutOfBlocks(posX - width * 0.35, getEntityBoundingBox().minY + 0.5, posZ + width * 0.35); + pushOutOfBlocks(posX - width * 0.35, getEntityBoundingBox().minY + 0.5, posZ - width * 0.35); + pushOutOfBlocks(posX + width * 0.35, getEntityBoundingBox().minY + 0.5, posZ - width * 0.35); + pushOutOfBlocks(posX + width * 0.35, getEntityBoundingBox().minY + 0.5, posZ + width * 0.35); + + boolean flag3 = this.foodStats.getFoodLevel() > 6 || capabilities.allowFlying; + float f = 0.8f; + + boolean shouldSprint = player.isSprinting(); + + if (onGround && movementInput.moveForward >= f && !isSprinting() && flag3 && !player.isUsingItem() && !isPotionActive(Potion.blindness) && shouldSprint) { + setSprinting(true); + } + + if (!isSprinting() && movementInput.moveForward >= f && flag3 && !player.isUsingItem() && !isPotionActive(Potion.blindness) && shouldSprint) { + setSprinting(true); + } + + if (movementInput.sneak) { + setSprinting(false); + } + + if (isSprinting() && (movementInput.moveForward < 0.8f || isCollidedHorizontally || !flag3)) { + setSprinting(false); + } + + if (capabilities.allowFlying) { + if (mc.playerController.isSpectatorMode()) { + if (!capabilities.isFlying) { + capabilities.isFlying = true; + } + } + } + + if (capabilities.isFlying) { + if (movementInput.sneak) { + motionY -= (capabilities.getFlySpeed() * 3.0f); + } + if (movementInput.jump) { + motionY += (capabilities.getFlySpeed() * 3.0f); + } + } + + livingEntityUpdate(); + } + + private void playerUpdate(boolean post) { + if (!post) { + noClip = this.isSpectator; + + if (this.isSpectator) { + onGround = false; + } + } else { + clampPositionFromEntityPlayer(); + } + } + + private void livingEntityUpdate() { + if (this.jumpTicks > 0) { + --this.jumpTicks; + } + + if (Math.abs(this.motionX) < 0.005) { + this.motionX = 0.0; + } + + if (Math.abs(this.motionY) < 0.005) { + this.motionY = 0.0; + } + + if (Math.abs(this.motionZ) < 0.005) { + this.motionZ = 0.0; + } + + if (this.isMovementBlocked()) { + this.isJumping = false; + this.moveStrafing = 0.0f; + this.moveForward = 0.0f; + } else if (this.isServerWorld()) { + this.updateLivingEntityInput(); + } + + if (this.isJumping) { + if (this.isInWater() || this.isInLava()) { + this.updateAITick(); + } else if (this.onGround && this.jumpTicks == 0) { + this.jump(); + } + } else { + this.jumpTicks = 0; + } + + this.moveStrafing *= 0.98f; + this.moveForward *= 0.98f; + this.playerSideMoveEntityWithHeading(this.moveStrafing, this.moveForward); + + jumpMovementFactor = SPEED_IN_AIR; + if (isSprinting()) { + jumpMovementFactor = (float) (jumpMovementFactor + SPEED_IN_AIR * 0.3); + } + + if (this.onGround && this.capabilities.isFlying && !isSpectator) { + this.capabilities.isFlying = false; + } + } + + private void clampPositionFromEntityPlayer() { + double d3 = MathHelper.clamp_double(posX, -2.9999999E7, 2.9999999E7); + double d4 = MathHelper.clamp_double(posZ, -2.9999999E7, 2.9999999E7); + if (d3 != posX || d4 != posZ) { + setPosition(d3, posY, d4); + } + } + + private void setPosition(double x, double y, double z) { + posX = x; + posY = y; + posZ = z; + float f = width / 2.0f; + float f1 = height; + setEntityBoundingBox(new AxisAlignedBB(x - f, y, z - f, x + f, y + f1, z + f)); + } + + private void setSprinting(boolean state) { + isSprinting = state; + } + + private boolean pushOutOfBlocks(double x, double y, double z) { + if (noClip) { + return false; + } else { + BlockPos blockPos = new BlockPos(x, y, z); + double d0 = x - blockPos.getX(); + double d1 = z - blockPos.getZ(); + int entHeight = (int) Math.ceil(height); + boolean inTranslucentBlock = !this.isHeadspaceFree(blockPos, entHeight); + if (inTranslucentBlock) { + int i = -1; + double d2 = 9999.0; + if (this.isHeadspaceFree(blockPos.west(), entHeight) && d0 < d2) { + d2 = d0; + i = 0; + } + if (this.isHeadspaceFree(blockPos.east(), entHeight) && 1.0 - d0 < d2) { + d2 = 1.0 - d0; + i = 1; + } + if (this.isHeadspaceFree(blockPos.north(), entHeight) && d1 < d2) { + d2 = d1; + i = 4; + } + if (this.isHeadspaceFree(blockPos.south(), entHeight) && 1.0 - d1 < d2) { + i = 5; + } + + float f = 0.1f; + if (i == 0) { + motionX = -f; + } + if (i == 1) { + motionX = f; + } + if (i == 4) { + motionZ = -f; + } + if (i == 5) { + motionZ = f; + } + } + return false; + } + } + + private boolean isHeadspaceFree(BlockPos pos, int height) { + for (int y = 0; y < height; y++) { + if (!this.isOpenBlockSpace(pos.add(0, y, 0))) { + return false; + } + } + return true; + } + + private boolean isOpenBlockSpace(BlockPos pos) { + return getBlockState(pos).getBlock().isNormalCube(); + } + + private void playerSideMoveEntityWithHeading(float moveStrafing, float moveForward) { + if (capabilities.isFlying && ridingEntity == null) { + double d3 = motionY; + float f = jumpMovementFactor; + jumpMovementFactor = capabilities.getFlySpeed() * (isSprinting() ? 2 : 1); + livingEntitySideMoveEntityWithHeading(moveStrafing, moveForward); + motionY = d3 * 0.6; + jumpMovementFactor = f; + } else { + livingEntitySideMoveEntityWithHeading(moveStrafing, moveForward); + } + } + + private void livingEntitySideMoveEntityWithHeading(float strafing, float forwards) { + double d0; + float f3; + if (isServerWorld()) { + float f5; + float f6; + if (!isInWater() || this.capabilities.isFlying) { + if (isInLava() && !this.capabilities.isFlying) { + d0 = posY; + moveFlying(strafing, forwards, 0.02f); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.5; + motionY *= 0.5; + motionZ *= 0.5; + motionY -= 0.02; + if (isCollidedHorizontally && isOffsetPositionInLiquid(motionX, motionY + 0.6000000238418579 - posY + d0, motionZ)) { + motionY = 0.30000001192092896; + } + } else { + float f4 = 0.91f; + if (onGround) { + f4 = worldObj.getBlockState(new BlockPos(MathHelper.floor_double(posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(posZ))).getBlock().slipperiness * 0.91f; + } + + float f = 0.16277136f / (f4 * f4 * f4); + f5 = onGround ? getAIMoveSpeed() * f : jumpMovementFactor; + + moveFlying(strafing, forwards, f5); + f4 = 0.91f; + if (onGround) { + f4 = worldObj.getBlockState(new BlockPos(MathHelper.floor_double(posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(posZ))).getBlock().slipperiness * 0.91f; + } + + if (isOnLadder()) { + f6 = 0.15f; + motionX = MathHelper.clamp_double(motionX, -f6, f6); + motionZ = MathHelper.clamp_double(motionZ, -f6, f6); + fallDistance = 0.0f; + if (motionY < -0.15) { + motionY = -0.15; + } + + boolean flag = isSneaking(); + if (flag && motionY < 0.0) { + motionY = 0.0; + } + } + + moveEntity(motionX, motionY, motionZ); + if (isCollidedHorizontally && isOnLadder()) { + motionY = 0.2; + } + + if (worldObj.isRemote && (!worldObj.isBlockLoaded(new BlockPos(posX, 0, posZ)) || !worldObj.getChunkFromBlockCoords(new BlockPos(posX, 0, posZ)).isLoaded())) { + motionY = posY > 0.0 ? -0.1 : 0.0; + } else { + motionY -= 0.08; + } + + motionY *= 0.9800000190734863; + motionX *= f4; + motionZ *= f4; + } + } else { + d0 = posY; + f5 = 0.8f; + f6 = 0.02f; + f3 = EnchantmentHelper.getDepthStriderModifier(player); + if (f3 > 3.0f) { + f3 = 3.0f; + } + + if (!onGround) { + f3 *= 0.5f; + } + + if (f3 > 0.0f) { + f5 += (0.54600006f - f5) * f3 / 3.0f; + f6 += (getAIMoveSpeed() - f6) * f3 / 3.0f; + } + + moveFlying(strafing, forwards, f6); + moveEntity(motionX, motionY, motionZ); + motionX *= f5; + motionY *= 0.800000011920929; + motionZ *= f5; + motionY -= 0.02; + if (isCollidedHorizontally && isOffsetPositionInLiquid(motionX, motionY + 0.6000000238418579 - posY + d0, motionZ)) { + motionY = 0.30000001192092896; + } + } + } + } + + public void moveEntity(double xMotion, double yMotion, double zMotion) { + double velocityX = xMotion; + double velocityY = yMotion; + double velocityZ = zMotion; + if (noClip) { + this.setEntityBoundingBox(this.getEntityBoundingBox().offset(velocityX, velocityY, velocityZ)); + resetPositionToBB(); + } else { + double d0 = posX; + double d1 = posY; + double d2 = posZ; + if (isInWeb) { + isInWeb = false; + velocityX *= 0.25; + velocityY *= 0.05000000074505806; + velocityZ *= 0.25; + motionX = 0.0; + motionY = 0.0; + motionZ = 0.0; + } + double d3 = velocityX; + double d4 = velocityY; + double d5 = velocityZ; + + boolean flag = onGround && (isSneaking() || safeWalk); + + if (flag) { + d3 = checkForCollision(this, velocityX, velocityZ).getLeft(); + d5 = checkForCollision(this, velocityX, velocityZ).getRight(); + } + + List list1 = worldObj.getCollidingBoundingBoxes(player, + getEntityBoundingBox().addCoord(velocityX, velocityY, velocityZ)); + AxisAlignedBB axisalignedbb = getEntityBoundingBox(); + + for (AxisAlignedBB axisalignedbb1 : list1) { + velocityY = axisalignedbb1.calculateYOffset(getEntityBoundingBox(), velocityY); + } + + setEntityBoundingBox(getEntityBoundingBox().offset(0.0, velocityY, 0.0)); + boolean flag1 = onGround || d4 != velocityY && d4 < 0; + + for (AxisAlignedBB axisalignedbb2 : list1) { + velocityX = axisalignedbb2.calculateXOffset(getEntityBoundingBox(), velocityX); + } + + setEntityBoundingBox(getEntityBoundingBox().offset(velocityX, 0.0, 0.0)); + + for (AxisAlignedBB axisalignedbb13 : list1) { + velocityZ = axisalignedbb13.calculateZOffset(getEntityBoundingBox(), velocityZ); + } + + setEntityBoundingBox(getEntityBoundingBox().offset(0.0, 0.0, velocityZ)); + if (stepHeight > 0.0f && flag1 && (d3 != velocityX || d5 != velocityZ)) { + double d11 = velocityX; + double d7 = velocityY; + double d8 = velocityZ; + AxisAlignedBB axisalignedbb3 = getEntityBoundingBox(); + setEntityBoundingBox(axisalignedbb); + velocityY = stepHeight; + List list = worldObj.getCollidingBoundingBoxes(player, + getEntityBoundingBox().addCoord(d3, velocityY, d5)); + AxisAlignedBB axisalignedbb4 = getEntityBoundingBox(); + AxisAlignedBB axisalignedbb5 = axisalignedbb4.addCoord(d3, 0.0, d5); + double d9 = velocityY; + + for (AxisAlignedBB axisalignedbb6 : list) { + d9 = axisalignedbb6.calculateYOffset(axisalignedbb5, d9); + } + + axisalignedbb4 = axisalignedbb4.offset(0.0, d9, 0.0); + double d15 = d3; + + for (AxisAlignedBB axisalignedbb7 : list) { + d15 = axisalignedbb7.calculateXOffset(axisalignedbb4, d15); + } + + axisalignedbb4 = axisalignedbb4.offset(d15, 0.0, 0.0); + double d16 = d5; + + for (AxisAlignedBB axisalignedbb8 : list) { + d16 = axisalignedbb8.calculateZOffset(axisalignedbb4, d16); + } + + axisalignedbb4 = axisalignedbb4.offset(0.0, 0.0, d16); + AxisAlignedBB axisalignedbb14 = getEntityBoundingBox(); + double d17 = velocityY; + + for (AxisAlignedBB axisalignedbb9 : list) { + d17 = axisalignedbb9.calculateYOffset(axisalignedbb14, d17); + } + + axisalignedbb14 = axisalignedbb14.offset(0.0, d17, 0.0); + double d18 = d3; + + for (AxisAlignedBB axisalignedbb10 : list) { + d18 = axisalignedbb10.calculateXOffset(axisalignedbb14, d18); + } + + axisalignedbb14 = axisalignedbb14.offset(d18, 0.0, 0.0); + double d19 = d5; + + for (AxisAlignedBB axisalignedbb11 : list) { + d19 = axisalignedbb11.calculateZOffset(axisalignedbb14, d19); + } + + axisalignedbb14 = axisalignedbb14.offset(0.0, 0.0, d19); + double d20 = d15 * d15 + d16 * d16; + double d10 = d18 * d18 + d19 * d19; + + if (d20 > d10) { + velocityX = d15; + velocityZ = d16; + velocityY = -d9; + setEntityBoundingBox(axisalignedbb4); + } else { + velocityX = d18; + velocityZ = d19; + velocityY = -d17; + setEntityBoundingBox(axisalignedbb14); + } + + for (AxisAlignedBB axisalignedbb12 : list) { + velocityY = axisalignedbb12.calculateYOffset(getEntityBoundingBox(), velocityY); + } + + setEntityBoundingBox(getEntityBoundingBox().offset(0.0, velocityY, 0.0)); + + if (d11 * d11 + d8 * d8 >= velocityX * velocityX + velocityZ * velocityZ) { + velocityX = d11; + velocityY = d7; + velocityZ = d8; + setEntityBoundingBox(axisalignedbb3); + } + } + resetPositionToBB(); + isCollidedHorizontally = d3 != velocityX || d5 != velocityZ; + isCollidedVertically = d4 != velocityY; + onGround = isCollidedVertically && d4 < 0.0; + isCollided = isCollidedHorizontally || isCollidedVertically; + int i = MathHelper.floor_double(posX); + int j = MathHelper.floor_double(posY - 0.20000000298023224); + int k = MathHelper.floor_double(posZ); + BlockPos blockPos = new BlockPos(i, j, k); + net.minecraft.block.Block block1 = worldObj.getBlockState(blockPos).getBlock(); + if (block1.getMaterial() == Material.air) { + net.minecraft.block.Block block = worldObj.getBlockState(blockPos.down()).getBlock(); + if (block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockFenceGate) { + block1 = block; + } + } + updateFallState(velocityY, onGround); + if (d3 != velocityX) { + motionX = 0.0; + } + if (d5 != velocityZ) { + motionZ = 0.0; + } + if (d4 != velocityY) { + onLanded(block1); + } + if (canTriggerWalking() && !flag && ridingEntity == null) { + double d12 = posX - d0; + double d13 = posY - d1; + double d14 = posZ - d2; + if (block1 != Blocks.ladder) { + d13 = 0.0; + } + if (block1 != null && onGround) { + onEntityCollidedWithBlock(block1); + } + distanceWalkedModified = (float) (distanceWalkedModified + MathHelper.sqrt_double(d12 * d12 + d14 * d14) * 0.6); + distanceWalkedOnStepModified = (float) (distanceWalkedOnStepModified + MathHelper.sqrt_double(d12 * d12 + d13 * d13 + d14 * d14) * 0.6); + if (distanceWalkedOnStepModified > nextStepDistance && block1.getMaterial() != Material.air) { + nextStepDistance = (int) distanceWalkedOnStepModified + 1; + } + } + + try { + doBlockCollisions(); + } catch (Throwable var52) { + var52.printStackTrace(); + } + + boolean flag2 = isWet(); + + if (worldObj.isFlammableWithin(this.getEntityBoundingBox().contract(0.001, 0.001, 0.001))) { + //this.dealFireDamage(1); + if (!flag2) { + ++fire; + if (fire == 0) { + setFire(8); + } + } + } else if (fire <= 0) { + fire = -fireResistance; + } + + if (flag2 && fire > 0) { + fire = -fireResistance; + } + } + } + + public AxisAlignedBB getEntityBoundingBox() { + return box; + } + + public void setEntityBoundingBox(AxisAlignedBB box) { + this.box = box; + } + + public void setOnFireFromLava() { + setFire(15); + } + + public void setFire(int seconds) { + int i = seconds * 20; + i = EnchantmentProtection.getFireTimeForEntity(player, i); + if (fire < i) { + fire = i; + } + } + + public boolean isWet() { + return inWater || isRainingAt(new BlockPos(posX, posY, posZ)) + || isRainingAt(new BlockPos(posX, posY + height, posZ)); + } + + public void doBlockCollisions() { + BlockPos blockpos = new BlockPos(getEntityBoundingBox().minX + 0.001, + getEntityBoundingBox().minY + 0.001, + getEntityBoundingBox().minZ + 0.001); + BlockPos blockpos1 = new BlockPos(getEntityBoundingBox().maxX - 0.001, + getEntityBoundingBox().maxY - 0.001, + getEntityBoundingBox().maxZ - 0.001); + if (isAreaLoaded(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockpos1.getX(), blockpos1.getY(), blockpos1.getZ(), true)) { + for (int i = blockpos.getX(); i <= blockpos1.getX(); i++) { + for (int j = blockpos.getY(); j <= blockpos1.getY(); j++) { + for (int k = blockpos.getZ(); k <= blockpos1.getZ(); k++) { + BlockPos pos = new BlockPos(i, j, k); + IBlockState state = worldObj.getBlockState(pos); + try { + net.minecraft.block.Block block = state.getBlock(); + if (block instanceof BlockWeb) { + isInWeb = true; + } else if (block instanceof BlockSoulSand) { + motionX *= 0.4; + motionZ *= 0.4; + } + } catch (Throwable var11) { + var11.printStackTrace(); + } + } + } + } + } + } + + public void updateFallState(double motionY, boolean onGround) { + if (!isInWater()) { + handleWaterMovement(); + } + + if (onGround) { + if (fallDistance > 0.0f) { + fallDistance = 0.0f; + } + } else if (motionY < 0.0) { + fallDistance = (float) (fallDistance - motionY); + } + } + + public boolean handleWaterMovement() { + if (handleMaterialAcceleration(getEntityBoundingBox().expand(0.0, -0.4000000059604645, 0.0) + .contract(0.001, 0.001, 0.001), Material.water)) { + fallDistance = 0.0f; + inWater = true; + fire = 0; + } else { + inWater = false; + } + + return inWater; + } + + public boolean handleMaterialAcceleration(AxisAlignedBB boundingBox, Material material) { + int i = MathHelper.floor_double(boundingBox.minX); + int j = MathHelper.floor_double(boundingBox.maxX + 1.0); + int k = MathHelper.floor_double(boundingBox.minY); + int l = MathHelper.floor_double(boundingBox.maxY + 1.0); + int i1 = MathHelper.floor_double(boundingBox.minZ); + int j1 = MathHelper.floor_double(boundingBox.maxZ + 1.0); + if (!isAreaLoaded(i, k, i1, j, l, j1, true)) { + return false; + } else { + boolean flag = false; + net.minecraft.util.Vec3 vec3 = new net.minecraft.util.Vec3(0.0, 0.0, 0.0); + BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); + for (int k1 = i; k1 < j; k1++) { + for (int l1 = k; l1 < l; l1++) { + for (int i2 = i1; i2 < j1; i2++) { + blockPos.set(k1, l1, i2); + IBlockState state = getBlockState(blockPos); + if (state == null) continue; + net.minecraft.block.Block block = state.getBlock(); + if (block == null) continue; + if (block.getMaterial() == material) { + double d0 = ((l1 + 1) - BlockLiquid.getLiquidHeightPercent(state.getValue(BlockLiquid.LEVEL))); + if (l >= d0) { + flag = true; + vec3 = block.modifyAcceleration(worldObj, blockPos, player, vec3); + } + } + } + } + } + if (vec3.lengthVector() > 0.0 && isPushedByWater()) { + vec3 = vec3.normalize(); + double d1 = 0.014; + motionX += vec3.xCoord * d1; + motionY += vec3.yCoord * d1; + motionZ += vec3.zCoord * d1; + } + return flag; + } + } + + public boolean isAreaLoaded(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean idfk) { + if (maxY >= 0 && minY < 256) { + minX >>= 4; + minZ >>= 4; + maxX >>= 4; + maxZ >>= 4; + for (int i = minX; i <= maxX; i++) { + for (int j = minZ; j <= maxZ; j++) { + if (!isChunkLoaded(i, j, idfk)) { + return false; + } + } + } + return true; + } else { + return false; + } + } + + public void onEntityCollidedWithBlock(Block block) { + if (block instanceof BlockSlime) { + if (Math.abs(motionY) < 0.1 && !isSneaking()) { + double motion = 0.4 + Math.abs(motionY) * 0.2; + motionX *= motion; + motionZ *= motion; + } + } + } + + public boolean canTriggerWalking() { + return !capabilities.isFlying; + } + + public boolean isOnLadder() { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.getEntityBoundingBox().minY); + int k = MathHelper.floor_double(this.posZ); + net.minecraft.block.Block block = this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock(); + return (block == Blocks.ladder || block == Blocks.vine) && (!isSpectator); + } + + public void moveFlying(float strafe, float forward, float friction) { + float newStrafe = strafe; + float newForward = forward; + float f = newStrafe * newStrafe + newForward * newForward; + if (f >= 1.0E-4f) { + f = MathHelper.sqrt_float(f); + if (f < 1.0f) { + f = 1.0f; + } + f = friction / f; + newStrafe *= f; + newForward *= f; + float f1 = MathHelper.sin(rotationYaw * 3.1415927f / 180.0f); + float f2 = MathHelper.cos(rotationYaw * 3.1415927f / 180.0f); + motionX += (newStrafe * f2 - newForward * f1); + motionZ += (newForward * f2 + newStrafe * f1); + } + } + + public void jump() { + motionY = getJumpUpwardsMotion(); + if (isPotionActive(Potion.jump)) { + motionY += ((getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1f); + } + + if (isSprinting()) { + float f = rotationYaw * 0.017453292f; + motionX -= (MathHelper.sin(f) * 0.2f); + motionZ += (MathHelper.cos(f) * 0.2f); + } + + isAirBorne = true; + } + + public boolean isSprinting() { + return isSprinting; + } + + public boolean isPotionActive(Potion potion) { + return player.getActivePotionEffect(potion) != null; + } + + public PotionEffect getActivePotionEffect(Potion potion) { + return player.getActivePotionEffect(potion); + } + + public float getJumpUpwardsMotion() { + return 0.42f; + } + + public boolean isInWater() { + return inWater; + } + + public void updateLivingEntityInput() { + moveForward = movementInput.moveForward; + moveStrafing = movementInput.moveStrafe; + isJumping = movementInput.jump; + } + + public boolean isServerWorld() { + return true; + } + + public boolean isMovementBlocked() { + return player.getHealth() <= 0f || player.isPlayerSleeping(); + } + + public boolean isInLava() { + return worldObj.isMaterialInBB(getEntityBoundingBox().expand(-0.10000000149011612, -0.4000000059604645, -0.10000000149011612), Material.lava); + } + + public void updateAITick() { + motionY += 0.03999999910593033; + } + + public boolean isOffsetPositionInLiquid(double x, double y, double z) { + AxisAlignedBB box = getEntityBoundingBox().offset(x, y, z); + return isLiquidPresentInAABB(box); + } + + public boolean isLiquidPresentInAABB(AxisAlignedBB box) { + return worldObj.getCollidingBoundingBoxes(player, box).isEmpty() && !worldObj.isAnyLiquid(box); + } + + public List getCollidingBoundingBoxes(AxisAlignedBB box) { + List list = Lists.newArrayList(); + int i = MathHelper.floor_double(box.minX); + int j = MathHelper.floor_double(box.maxX + 1.0); + int k = MathHelper.floor_double(box.minY); + int l = MathHelper.floor_double(box.maxY + 1.0); + int i1 = MathHelper.floor_double(box.minZ); + int j1 = MathHelper.floor_double(box.maxZ + 1.0); + WorldBorder worldBorder = getWorldBorder(); + boolean flag = isOutsideBorder; + boolean flag1 = isInsideBorder(worldBorder, flag); + IBlockState iblockstate = Blocks.stone.getDefaultState(); + BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); + for (int k1 = i; k1 < j; k1++) { + for (int l1 = i1; l1 < j1; l1++) { + if (isBlockLoaded(blockPos.set(k1, 64, l1))) { + for (int i2 = k - 1; i2 < l; i2++) { + blockPos.set(k1, i2, l1); + if (flag && flag1) { + isOutsideBorder = false; + } else if (!flag && !flag1) { + isOutsideBorder = true; + } + IBlockState state = iblockstate; + if (worldBorder.contains(blockPos) || !flag1) { + state = getBlockState(blockPos); + } + state.getBlock().addCollisionBoxesToList(worldObj, blockPos, state, box, list, player); + } + } + } + } + double d0 = 0.25; + List entities = getEntitiesWithinAABBExcludingEntity(player, box.expand(d0, d0, d0)); + for (Entity entity : entities) { + if (riddenByEntity != entity && ridingEntity != entity) { + AxisAlignedBB boundingBox = entity.getCollisionBoundingBox(); + if (boundingBox != null && boundingBox.intersectsWith(box)) { + list.add(boundingBox); + } + boundingBox = getCollisionBox(player, entity); + if (boundingBox != null && boundingBox.intersectsWith(box)) { + list.add(boundingBox); + } + } + } + return list; + } + + public IBlockState getBlockState(BlockPos blockPos) { + return worldObj.getBlockState(blockPos); + } + + private Chunk getChunkFromBlockCoords(BlockPos blockPos) { + return getChunkFromChunkCoords(blockPos.getX() >> 4, blockPos.getZ() >> 4); + } + + private Chunk getChunkFromChunkCoords(int x, int z) { + return chunkProvider.provideChunk(x, z); + } + + private boolean isValid(BlockPos pos) { + return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000 && pos.getY() >= 0 && pos.getY() < 256; + } + + private WorldBorder getWorldBorder() { + return worldBorder; + } + + private boolean isInsideBorder(WorldBorder border, boolean insideBorder) { + double d0 = border.minX(); + double d1 = border.minZ(); + double d2 = border.maxX(); + double d3 = border.maxZ(); + if (insideBorder) { + ++d0; + ++d1; + --d2; + --d3; + } else { + --d0; + --d1; + ++d2; + ++d3; + } + return posX > d0 && posX < d2 && posZ > d1 && posZ < d3; + } + + private boolean isBlockLoaded(BlockPos pos) { + return isBlockLoaded(pos, true); + } + + private boolean isBlockLoaded(BlockPos pos, boolean check2) { + return isValid(pos) && isChunkLoaded(pos.getX() >> 4, pos.getZ() >> 4, check2); + } + + private boolean isChunkLoaded(int x, int z, boolean flag) { + return chunkProvider.chunkExists(x, z) && (flag || !chunkProvider.provideChunk(x, z).isEmpty()); + } + + private List getEntitiesWithinAABBExcludingEntity(Entity entity, AxisAlignedBB box) { + return getEntitiesInAABBexcluding(entity, box, EntitySelectors.NOT_SPECTATING); + } + + private List getEntitiesInAABBexcluding(Entity entity, AxisAlignedBB bb, Predicate predicate) { + List list = Lists.newArrayList(); + int i = MathHelper.floor_double((bb.minX - 2.0) / 16.0); + int j = MathHelper.floor_double((bb.maxX + 2.0) / 16.0); + int k = MathHelper.floor_double((bb.minZ - 2.0) / 16.0); + int l = MathHelper.floor_double((bb.maxZ + 2.0) / 16.0); + for (int i1 = i; i1 <= j; i1++) { + for (int j1 = k; j1 <= l; j1++) { + if (isChunkLoaded(i1, j1, true)) { + getChunkFromChunkCoords(i1, j1).getEntitiesWithinAABBForEntity(entity, bb, list, predicate); + } + } + } + return list; + } + + private AxisAlignedBB getCollisionBox(Entity player, Entity entity) { + if (entity instanceof EntityBoat) { + return entity.getEntityBoundingBox(); + } else if (entity instanceof EntityMinecart) { + return player.getCollisionBox(entity); + } else { + return null; + } + } + + private float getAIMoveSpeed() { + return (float) getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + } + + private IAttributeInstance getEntityAttribute(IAttribute iAttribute) { + return getAttributeMap().getAttributeInstance(iAttribute); + } + + private BaseAttributeMap getAttributeMap() { + if (attributeMap == null) { + attributeMap = new ServersideAttributeMap(); + } + return attributeMap; + } + + private void resetPositionToBB() { + posX = (getEntityBoundingBox().minX + getEntityBoundingBox().maxX) / 2.0; + posY = getEntityBoundingBox().minY; + posZ = (getEntityBoundingBox().minZ + getEntityBoundingBox().maxZ) / 2.0; + } + + private void onLanded(net.minecraft.block.Block block) { + if (block instanceof BlockSlime) { + if (isSneaking()) { + motionY = 0.0; + } + else if (motionY < 0.0) { + motionY = -motionY; + } + } + else { + motionY = 0.0; + } + } + + public boolean isSneaking() { + return movementInput.sneak && !player.isPlayerSleeping(); + } + + private boolean isRainingAt(BlockPos pos) { + if (worldObj.getRainStrength(1.0F) <= 0.2) { + return false; + } else if (!canSeeSky(pos)) { + return false; + } else if (worldObj.getPrecipitationHeight(pos).getY() > pos.getY()) { + return false; + } else { + BiomeGenBase base = worldObj.getBiomeGenForCoords(pos); + if (base.getEnableSnow()) return false; + else if (worldObj.canSnowAt(pos, false)) return false; + else return base.canRain(); + } + } + + private boolean canSeeSky(BlockPos pos) { + return getChunkFromBlockCoords(pos).canSeeSky(pos); + } + + private boolean isPushedByWater() { + return !capabilities.isFlying; + } + + public Pair checkForCollision(SimulatedPlayer simPlayer, double velocityX, double velocityZ) { + EntityPlayerSP player = mc.thePlayer; + World worldObj = player.worldObj; + + double d6; + + double d3 = velocityX; + double d5 = velocityZ; + + for (d6 = 0.05; velocityX != 0 && worldObj.getCollidingBoundingBoxes(player, simPlayer.box.offset(velocityX, -1, 0)).isEmpty(); d3 = velocityX) { + if (velocityX < d6 && velocityX >= -d6) { + velocityX = 0; + } else if (velocityX > 0) { + velocityX -= d6; + } else { + velocityX += d6; + } + } + + //noinspection ConstantConditions + for (; velocityZ != 0 && worldObj.getCollidingBoundingBoxes(player, simPlayer.box.offset(0, -1, velocityZ)).isEmpty(); d5 = velocityZ) { + if (velocityZ < d6 && velocityZ >= -d6) { + velocityZ = 0; + } else if (velocityZ > 0) { + velocityZ -= d6; + } else { + velocityZ += d6; + } + } + + //noinspection ConstantConditions + for (; velocityX != 0 && velocityZ != 0 && worldObj.getCollidingBoundingBoxes(player, simPlayer.box.offset(velocityX, -1, velocityZ)).isEmpty(); d5 = velocityZ) { + if (velocityX < d6 && velocityX >= -d6) { + velocityX = 0; + } else if (velocityX > 0) { + velocityX -= d6; + } else { + velocityX += d6; + } + + d3 = velocityX; + + if (velocityZ < d6 && velocityZ >= -d6) { + velocityZ = 0; + } else if (velocityZ > 0) { + velocityZ -= d6; + } else { + velocityZ += d6; + } + } + + return Pair.of(d3, d5); + } + public float getEyeHeight() + { + return this.height * 0.85F; + } +} diff --git a/src/main/java/keystrokesmod/script/model/Simulation.java b/src/main/java/keystrokesmod/script/model/Simulation.java new file mode 100644 index 0000000..66ed5a8 --- /dev/null +++ b/src/main/java/keystrokesmod/script/model/Simulation.java @@ -0,0 +1,86 @@ +package keystrokesmod.script.model; + +import net.minecraft.client.Minecraft; +import net.minecraft.util.MovementInput; + +public class Simulation { + private final SimulatedPlayer raw; + + private Simulation(SimulatedPlayer raw) { + this.raw = raw; + } + + /** + * Create a new simulation seeded from the current client player state. + * Automatically copies the real player's MovementInput. + */ + public static Simulation create() { + Minecraft mc = Minecraft.getMinecraft(); + MovementInput input = mc.thePlayer.movementInput; + SimulatedPlayer sim = SimulatedPlayer.fromClientPlayer(input); + return new Simulation(sim); + } + + /** + * Set forward input (-1..1). + */ + public void setForward(float forward) { + raw.movementInput.moveForward = forward; + } + + /** + * Set strafe input (-1..1). + */ + public void setStrafe(float strafe) { + raw.movementInput.moveStrafe = strafe; + } + + /** + * Set jump flag. + */ + public void setJump(boolean jump) { + raw.movementInput.jump = jump; + } + + /** + * Set sneak flag. + */ + public void setSneak(boolean sneak) { + raw.movementInput.sneak = sneak; + } + + /** + * Set yaw (horizontal rotation) for the simulation. + */ + public void setYaw(float yaw) { + raw.rotationYaw = yaw; + } + + /** + * Advance the simulator one game tick. + */ + public void tick() { + raw.tick(); + } + + /** + * @return predicted position after tick. + */ + public Vec3 getPosition() { + return raw.getPos(); + } + + /** + * @return raw motion vector (dx, dy, dz) from last tick. + */ + public Vec3 getMotion() { + return new Vec3(raw.motionX, raw.motionY, raw.motionZ); + } + + /** + * @return true if on ground at end of simulation. + */ + public boolean onGround() { + return raw.onGround; + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/model/TileEntity.java b/src/main/java/keystrokesmod/script/model/TileEntity.java index 3124659..3850f14 100644 --- a/src/main/java/keystrokesmod/script/model/TileEntity.java +++ b/src/main/java/keystrokesmod/script/model/TileEntity.java @@ -1,38 +1,38 @@ -package keystrokesmod.script.model; - -import net.minecraft.tileentity.TileEntitySkull; - -public class TileEntity { - private net.minecraft.tileentity.TileEntity tileEntity; - private Vec3 position; - - public String type; - public String name; - - public TileEntity(net.minecraft.tileentity.TileEntity tileEntity) { - this.tileEntity = tileEntity; - this.position = new Vec3(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ()); - this.type = tileEntity.getBlockType().getClass().getSimpleName(); - this.name = tileEntity.getBlockType().getRegistryName().replace("minecraft:", ""); - } - - public Vec3 getPosition() { - return position; - } - - public Object[] getSkullData() { - if (this.tileEntity instanceof TileEntitySkull) { - final TileEntitySkull skull = (TileEntitySkull)this.tileEntity; - final Object[] skullData = { skull.getSkullType(), skull.getSkullRotation(), null, null, null }; - if (skull.getPlayerProfile() == null) { - skullData[2] = (skullData[3] = null); - } - else { - skullData[2] = skull.getPlayerProfile().getName(); - skullData[3] = skull.getPlayerProfile().getId(); - } - return skullData; - } - return null; - } -} +package keystrokesmod.script.model; + +import net.minecraft.tileentity.TileEntitySkull; + +public class TileEntity { + private net.minecraft.tileentity.TileEntity tileEntity; + private Vec3 position; + + public String type; + public String name; + + public TileEntity(net.minecraft.tileentity.TileEntity tileEntity) { + this.tileEntity = tileEntity; + this.position = new Vec3(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ()); + this.type = tileEntity.getBlockType().getClass().getSimpleName(); + this.name = tileEntity.getBlockType().getRegistryName().replace("minecraft:", ""); + } + + public Vec3 getPosition() { + return position; + } + + public Object[] getSkullData() { + if (this.tileEntity instanceof TileEntitySkull) { + final TileEntitySkull skull = (TileEntitySkull)this.tileEntity; + final Object[] skullData = { skull.getSkullType(), skull.getSkullRotation(), null, null, null }; + if (skull.getPlayerProfile() == null) { + skullData[2] = (skullData[3] = null); + } + else { + skullData[2] = skull.getPlayerProfile().getName(); + skullData[3] = skull.getPlayerProfile().getId(); + } + return skullData; + } + return null; + } +} diff --git a/src/main/java/keystrokesmod/script/model/Vec3.java b/src/main/java/keystrokesmod/script/model/Vec3.java index 0d16be9..3137c44 100644 --- a/src/main/java/keystrokesmod/script/model/Vec3.java +++ b/src/main/java/keystrokesmod/script/model/Vec3.java @@ -1,98 +1,98 @@ -package keystrokesmod.script.model; - -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; - -public class Vec3 { - public double x, y, z; - - public Vec3(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Vec3(net.minecraft.util.Vec3 minecraftVec3) { - this.x = minecraftVec3.xCoord; - this.y = minecraftVec3.yCoord; - this.z = minecraftVec3.zCoord; - } - - public Vec3(BlockPos blockPos) { - this.x = blockPos.getX(); - this.y = blockPos.getY(); - this.z = blockPos.getZ(); - } - - public boolean equals(Vec3 vector2) { - if (this == vector2) { - return true; - } - else if (this.x == vector2.x && this.y == vector2.y && this.z == vector2.z) { - return true; - } - return false; - } - - public Vec3 offset(Vec3 position) { - return new Vec3(this.x + position.x, this.y + position.y, this.z + position.z); - } - - public Vec3 offset(double x, double y, double z) { - return new Vec3(this.x + x, this.y + y, this.z + z); - } - - public Vec3 ceil() { - return new Vec3(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); - } - - public Vec3 floor() { - return new Vec3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); - } - - public Vec3 inverse() { - return new Vec3(-this.x, -this.y, -this.z); - } - - public Vec3 translate(Vec3 position) { - return this.offset(position.x, position.y, position.z); - } - - public Vec3 translate(double x, double y, double z) { - return this.offset(x, y, z); - } - - public static Vec3 convert(BlockPos blockPos) { - if (blockPos == null) { - return null; - } - return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - } - - public double distanceTo(Vec3 vec3) { - double deltaX = this.x - vec3.x; - double deltaY = this.y - vec3.y; - double deltaZ = this.z - vec3.z; - return MathHelper.sqrt_double(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); - } - - public double distanceToSq(Vec3 vec3) { - double deltaX = this.x - vec3.x; - double deltaY = this.y - vec3.y; - double deltaZ = this.z - vec3.z; - return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ; - } - - public static BlockPos getBlockPos(Vec3 blockPos) { - return new BlockPos(blockPos.x, blockPos.y, blockPos.z); - } - - public static net.minecraft.util.Vec3 getVec3(Vec3 vec3) { - return new net.minecraft.util.Vec3(vec3.x, vec3.y, vec3.z); - } - - @Override - public String toString() { - return "Vec3(" + this.x + "," + this.y + "," + this.z + ")"; - } -} +package keystrokesmod.script.model; + +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; + +public class Vec3 { + public double x, y, z; + + public Vec3(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Vec3(net.minecraft.util.Vec3 minecraftVec3) { + this.x = minecraftVec3.xCoord; + this.y = minecraftVec3.yCoord; + this.z = minecraftVec3.zCoord; + } + + public Vec3(BlockPos blockPos) { + this.x = blockPos.getX(); + this.y = blockPos.getY(); + this.z = blockPos.getZ(); + } + + public boolean equals(Vec3 vector2) { + if (this == vector2) { + return true; + } + else if (this.x == vector2.x && this.y == vector2.y && this.z == vector2.z) { + return true; + } + return false; + } + + public Vec3 offset(Vec3 position) { + return new Vec3(this.x + position.x, this.y + position.y, this.z + position.z); + } + + public Vec3 offset(double x, double y, double z) { + return new Vec3(this.x + x, this.y + y, this.z + z); + } + + public Vec3 ceil() { + return new Vec3(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); + } + + public Vec3 floor() { + return new Vec3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); + } + + public Vec3 inverse() { + return new Vec3(-this.x, -this.y, -this.z); + } + + public Vec3 translate(Vec3 position) { + return this.offset(position.x, position.y, position.z); + } + + public Vec3 translate(double x, double y, double z) { + return this.offset(x, y, z); + } + + public static Vec3 convert(BlockPos blockPos) { + if (blockPos == null) { + return null; + } + return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + public double distanceTo(Vec3 vec3) { + double deltaX = this.x - vec3.x; + double deltaY = this.y - vec3.y; + double deltaZ = this.z - vec3.z; + return MathHelper.sqrt_double(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + } + + public double distanceToSq(Vec3 vec3) { + double deltaX = this.x - vec3.x; + double deltaY = this.y - vec3.y; + double deltaZ = this.z - vec3.z; + return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ; + } + + public static BlockPos getBlockPos(Vec3 blockPos) { + return new BlockPos(blockPos.x, blockPos.y, blockPos.z); + } + + public static net.minecraft.util.Vec3 getVec3(Vec3 vec3) { + return new net.minecraft.util.Vec3(vec3.x, vec3.y, vec3.z); + } + + @Override + public String toString() { + return "Vec3(" + this.x + "," + this.y + "," + this.z + ")"; + } +} diff --git a/src/main/java/keystrokesmod/script/model/WebSocket.java b/src/main/java/keystrokesmod/script/model/WebSocket.java index a219a9a..41d70a5 100644 --- a/src/main/java/keystrokesmod/script/model/WebSocket.java +++ b/src/main/java/keystrokesmod/script/model/WebSocket.java @@ -1,129 +1,129 @@ -package keystrokesmod.script.model; - -import keystrokesmod.script.Manager; -import keystrokesmod.utility.Utils; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; - -import java.net.URI; -import java.util.Map; - -public class WebSocket { - private final WebSocketClient client; - - public WebSocket(String serverURI) { - this.client = createWebSocketClient(serverURI); - } - - public WebSocket(String serverUri, Map httpHeaders) { - this.client = createWebSocketClient(serverUri, httpHeaders); - } - - private WebSocketClient createWebSocketClient(String serverUri) { - return new WebSocketClient(toURI(serverUri)) { - @Override - public void onOpen(ServerHandshake handshakedata) { - WebSocket.this.onOpen(handshakedata.getHttpStatus(), handshakedata.getHttpStatusMessage()); - } - @Override - public void onMessage(String message) { - WebSocket.this.onMessage(message); - } - @Override - public void onClose(int code, String reason, boolean remote) { - WebSocket.this.onClose(code, reason, remote); - } - @Override - public void onError(Exception ex) { - WebSocket.this.onError(ex); - } - }; - } - - private WebSocketClient createWebSocketClient(String serverUri, Map httpHeaders) { - return new WebSocketClient(toURI(serverUri), httpHeaders) { - @Override - public void onOpen(ServerHandshake handshakedata) { - WebSocket.this.onOpen(handshakedata.getHttpStatus(), handshakedata.getHttpStatusMessage()); - } - @Override - public void onMessage(String message) { - WebSocket.this.onMessage(message); - } - @Override - public void onClose(int code, String reason, boolean remote) { - WebSocket.this.onClose(code, reason, remote); - } - @Override - public void onError(Exception ex) { - WebSocket.this.onError(ex); - } - }; - } - - private static URI toURI(String uri) { - try { - return new URI(uri); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void onOpen(short status, String message) { - - } - - public void onMessage(String message) { - - } - - public void onClose(int code, String reason, boolean remote) { - - } - - public void onError(Exception ex) { - - } - - public boolean connect(boolean block) { - if (!Manager.enableWebSockets.isToggled()) { - Utils.sendMessage("&cFailed to connect to websockets, websockets are not enabled."); - return false; - } - if (block) { - try { - return client.connectBlocking(); - } - catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - else { - client.connect(); - } - return true; - } - - public void send(String message) { - client.send(message); - } - - public void close(boolean block) { - if (block) { - try { - client.closeBlocking(); - } - catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - else { - client.close(); - } - } - - public boolean isOpen() { - return this.client == null ? false : this.client.isOpen(); - } +package keystrokesmod.script.model; + +import keystrokesmod.script.Manager; +import keystrokesmod.utility.Utils; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.handshake.ServerHandshake; + +import java.net.URI; +import java.util.Map; + +public class WebSocket { + private final WebSocketClient client; + + public WebSocket(String serverURI) { + this.client = createWebSocketClient(serverURI); + } + + public WebSocket(String serverUri, Map httpHeaders) { + this.client = createWebSocketClient(serverUri, httpHeaders); + } + + private WebSocketClient createWebSocketClient(String serverUri) { + return new WebSocketClient(toURI(serverUri)) { + @Override + public void onOpen(ServerHandshake handshakedata) { + WebSocket.this.onOpen(handshakedata.getHttpStatus(), handshakedata.getHttpStatusMessage()); + } + @Override + public void onMessage(String message) { + WebSocket.this.onMessage(message); + } + @Override + public void onClose(int code, String reason, boolean remote) { + WebSocket.this.onClose(code, reason, remote); + } + @Override + public void onError(Exception ex) { + WebSocket.this.onError(ex); + } + }; + } + + private WebSocketClient createWebSocketClient(String serverUri, Map httpHeaders) { + return new WebSocketClient(toURI(serverUri), httpHeaders) { + @Override + public void onOpen(ServerHandshake handshakedata) { + WebSocket.this.onOpen(handshakedata.getHttpStatus(), handshakedata.getHttpStatusMessage()); + } + @Override + public void onMessage(String message) { + WebSocket.this.onMessage(message); + } + @Override + public void onClose(int code, String reason, boolean remote) { + WebSocket.this.onClose(code, reason, remote); + } + @Override + public void onError(Exception ex) { + WebSocket.this.onError(ex); + } + }; + } + + private static URI toURI(String uri) { + try { + return new URI(uri); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void onOpen(short status, String message) { + + } + + public void onMessage(String message) { + + } + + public void onClose(int code, String reason, boolean remote) { + + } + + public void onError(Exception ex) { + + } + + public boolean connect(boolean block) { + if (!Manager.enableWebSockets.isToggled()) { + Utils.sendMessage("&cFailed to connect to websockets, websockets are not enabled."); + return false; + } + if (block) { + try { + return client.connectBlocking(); + } + catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + else { + client.connect(); + } + return true; + } + + public void send(String message) { + client.send(message); + } + + public void close(boolean block) { + if (block) { + try { + client.closeBlocking(); + } + catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + else { + client.close(); + } + } + + public boolean isOpen() { + return this.client == null ? false : this.client.isOpen(); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/packet/PacketMappings.java b/src/main/java/keystrokesmod/script/packet/PacketMappings.java index 1378c75..ec273f3 100644 --- a/src/main/java/keystrokesmod/script/packet/PacketMappings.java +++ b/src/main/java/keystrokesmod/script/packet/PacketMappings.java @@ -1,59 +1,59 @@ -package keystrokesmod.script.packet; - -import java.util.LinkedHashMap; -import java.util.Map; - -import keystrokesmod.script.packet.serverbound.*; -import keystrokesmod.script.packet.clientbound.*; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.*; - -public class PacketMappings { - public static final Map>, Class> minecraftToScriptC = new LinkedHashMap<>(); - - public static final Map>, Class> minecraftToScriptS = new LinkedHashMap<>(); - - static { - // serverbound - minecraftToScriptC.put(C0APacketAnimation.class, C0A.class); - minecraftToScriptC.put(C0BPacketEntityAction.class, C0B.class); - minecraftToScriptC.put(C01PacketChatMessage.class, C01.class); - minecraftToScriptC.put(C02PacketUseEntity.class, C02.class); - minecraftToScriptC.put(C0FPacketConfirmTransaction.class, C0F.class); - minecraftToScriptC.put(C0EPacketClickWindow.class, C0E.class); - minecraftToScriptC.put(C03PacketPlayer.class, C03.class); - minecraftToScriptC.put(C03PacketPlayer.C04PacketPlayerPosition.class, C03.class); - minecraftToScriptC.put(C03PacketPlayer.C05PacketPlayerLook.class, C03.class); - minecraftToScriptC.put(C03PacketPlayer.C06PacketPlayerPosLook.class, C03.class); - minecraftToScriptC.put(C07PacketPlayerDigging.class, C07.class); - minecraftToScriptC.put(C08PacketPlayerBlockPlacement.class, C08.class); - minecraftToScriptC.put(C09PacketHeldItemChange.class, C09.class); - minecraftToScriptC.put(C10PacketCreativeInventoryAction.class, C10.class); - minecraftToScriptC.put(C13PacketPlayerAbilities.class, C13.class); - minecraftToScriptC.put(C16PacketClientStatus.class, C16.class); - minecraftToScriptC.put(C0DPacketCloseWindow.class, C0D.class); - - // clientbound - minecraftToScriptS.put(S12PacketEntityVelocity.class, S12.class); - minecraftToScriptS.put(S27PacketExplosion.class, S27.class); - minecraftToScriptS.put(S3EPacketTeams.class, S3E.class); - minecraftToScriptS.put(S08PacketPlayerPosLook.class, S08.class); - minecraftToScriptS.put(S2APacketParticles.class, S2A.class); - minecraftToScriptS.put(S25PacketBlockBreakAnim.class, S25.class); - minecraftToScriptS.put(S06PacketUpdateHealth.class, S06.class); - minecraftToScriptS.put(S23PacketBlockChange.class, S23.class); - minecraftToScriptS.put(S29PacketSoundEffect.class, S29.class); - minecraftToScriptS.put(S2FPacketSetSlot.class, S2F.class); - minecraftToScriptS.put(S48PacketResourcePackSend.class, S48.class); - minecraftToScriptS.put(S3APacketTabComplete.class, S3A.class); - minecraftToScriptS.put(S02PacketChat.class, S02.class); - minecraftToScriptS.put(S45PacketTitle.class, S45.class); - minecraftToScriptS.put(S0BPacketAnimation.class, S0B.class); - minecraftToScriptS.put(S14PacketEntity.class, S14.class); - minecraftToScriptS.put(S14PacketEntity.S15PacketEntityRelMove.class, S14.class); - minecraftToScriptS.put(S14PacketEntity.S16PacketEntityLook.class, S14.class); - minecraftToScriptS.put(S14PacketEntity.S17PacketEntityLookMove.class, S14.class); - minecraftToScriptS.put(S04PacketEntityEquipment.class, S04.class); - } +package keystrokesmod.script.packet; + +import java.util.LinkedHashMap; +import java.util.Map; + +import keystrokesmod.script.packet.serverbound.*; +import keystrokesmod.script.packet.clientbound.*; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.*; + +public class PacketMappings { + public static final Map>, Class> minecraftToScriptC = new LinkedHashMap<>(); + + public static final Map>, Class> minecraftToScriptS = new LinkedHashMap<>(); + + static { + // serverbound + minecraftToScriptC.put(C0APacketAnimation.class, C0A.class); + minecraftToScriptC.put(C0BPacketEntityAction.class, C0B.class); + minecraftToScriptC.put(C01PacketChatMessage.class, C01.class); + minecraftToScriptC.put(C02PacketUseEntity.class, C02.class); + minecraftToScriptC.put(C0FPacketConfirmTransaction.class, C0F.class); + minecraftToScriptC.put(C0EPacketClickWindow.class, C0E.class); + minecraftToScriptC.put(C03PacketPlayer.class, C03.class); + minecraftToScriptC.put(C03PacketPlayer.C04PacketPlayerPosition.class, C03.class); + minecraftToScriptC.put(C03PacketPlayer.C05PacketPlayerLook.class, C03.class); + minecraftToScriptC.put(C03PacketPlayer.C06PacketPlayerPosLook.class, C03.class); + minecraftToScriptC.put(C07PacketPlayerDigging.class, C07.class); + minecraftToScriptC.put(C08PacketPlayerBlockPlacement.class, C08.class); + minecraftToScriptC.put(C09PacketHeldItemChange.class, C09.class); + minecraftToScriptC.put(C10PacketCreativeInventoryAction.class, C10.class); + minecraftToScriptC.put(C13PacketPlayerAbilities.class, C13.class); + minecraftToScriptC.put(C16PacketClientStatus.class, C16.class); + minecraftToScriptC.put(C0DPacketCloseWindow.class, C0D.class); + + // clientbound + minecraftToScriptS.put(S12PacketEntityVelocity.class, S12.class); + minecraftToScriptS.put(S27PacketExplosion.class, S27.class); + minecraftToScriptS.put(S3EPacketTeams.class, S3E.class); + minecraftToScriptS.put(S08PacketPlayerPosLook.class, S08.class); + minecraftToScriptS.put(S2APacketParticles.class, S2A.class); + minecraftToScriptS.put(S25PacketBlockBreakAnim.class, S25.class); + minecraftToScriptS.put(S06PacketUpdateHealth.class, S06.class); + minecraftToScriptS.put(S23PacketBlockChange.class, S23.class); + minecraftToScriptS.put(S29PacketSoundEffect.class, S29.class); + minecraftToScriptS.put(S2FPacketSetSlot.class, S2F.class); + minecraftToScriptS.put(S48PacketResourcePackSend.class, S48.class); + minecraftToScriptS.put(S3APacketTabComplete.class, S3A.class); + minecraftToScriptS.put(S02PacketChat.class, S02.class); + minecraftToScriptS.put(S45PacketTitle.class, S45.class); + minecraftToScriptS.put(S0BPacketAnimation.class, S0B.class); + minecraftToScriptS.put(S14PacketEntity.class, S14.class); + minecraftToScriptS.put(S14PacketEntity.S15PacketEntityRelMove.class, S14.class); + minecraftToScriptS.put(S14PacketEntity.S16PacketEntityLook.class, S14.class); + minecraftToScriptS.put(S14PacketEntity.S17PacketEntityLookMove.class, S14.class); + minecraftToScriptS.put(S04PacketEntityEquipment.class, S04.class); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S02.java b/src/main/java/keystrokesmod/script/packet/clientbound/S02.java index 1290234..cc0a0d9 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S02.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S02.java @@ -1,21 +1,21 @@ -package keystrokesmod.script.packet.clientbound; - -import net.minecraft.network.play.server.S02PacketChat; -import net.minecraft.util.ChatComponentText; - -public class S02 extends SPacket { - public byte type; - public String message; - - public S02(S02PacketChat packet) { - super(packet); - this.type = packet.getType(); - this.message = packet.getChatComponent().getUnformattedText(); - } - - public S02(byte type, String message) { - super(new S02PacketChat(new ChatComponentText(message), type)); - this.type = type; - this.message = message; - } -} +package keystrokesmod.script.packet.clientbound; + +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.util.ChatComponentText; + +public class S02 extends SPacket { + public byte type; + public String message; + + public S02(S02PacketChat packet) { + super(packet); + this.type = packet.getType(); + this.message = packet.getChatComponent().getUnformattedText(); + } + + public S02(byte type, String message) { + super(new S02PacketChat(new ChatComponentText(message), type)); + this.type = type; + this.message = message; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S04.java b/src/main/java/keystrokesmod/script/packet/clientbound/S04.java index 832a4b9..8bd186d 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S04.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S04.java @@ -1,24 +1,24 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.ItemStack; -import net.minecraft.network.play.server.S04PacketEntityEquipment; - -public class S04 extends SPacket { - public int entityId; - public int slot; - public ItemStack item; - - public S04(S04PacketEntityEquipment e) { - super(e); - this.entityId = e.getEntityID(); - this.slot = e.getEquipmentSlot(); - this.item = ItemStack.convert(e.getItemStack()); - } - - public S04(int entityId, int slot, keystrokesmod.script.model.ItemStack item) { - super(new S04PacketEntityEquipment(entityId, slot, item.itemStack)); - this.entityId = entityId; - this.slot = slot; - this.item = item; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.ItemStack; +import net.minecraft.network.play.server.S04PacketEntityEquipment; + +public class S04 extends SPacket { + public int entityId; + public int slot; + public ItemStack item; + + public S04(S04PacketEntityEquipment e) { + super(e); + this.entityId = e.getEntityID(); + this.slot = e.getEquipmentSlot(); + this.item = ItemStack.convert(e.getItemStack()); + } + + public S04(int entityId, int slot, keystrokesmod.script.model.ItemStack item) { + super(new S04PacketEntityEquipment(entityId, slot, item.itemStack)); + this.entityId = entityId; + this.slot = slot; + this.item = item; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S06.java b/src/main/java/keystrokesmod/script/packet/clientbound/S06.java index 908eae3..96627e9 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S06.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S06.java @@ -1,23 +1,23 @@ -package keystrokesmod.script.packet.clientbound; - -import net.minecraft.network.play.server.S06PacketUpdateHealth; - -public class S06 extends SPacket { - public float health; - public float saturation; - public int food; - - public S06(S06PacketUpdateHealth packet) { - super(packet); - this.health = packet.getHealth(); - this.saturation = packet.getSaturationLevel(); - this.food = packet.getFoodLevel(); - } - - public S06(float health, float saturation, int food) { - super(new S06PacketUpdateHealth(health, food, saturation)); - this.health = health; - this.saturation = saturation; - this.food = food; - } -} +package keystrokesmod.script.packet.clientbound; + +import net.minecraft.network.play.server.S06PacketUpdateHealth; + +public class S06 extends SPacket { + public float health; + public float saturation; + public int food; + + public S06(S06PacketUpdateHealth packet) { + super(packet); + this.health = packet.getHealth(); + this.saturation = packet.getSaturationLevel(); + this.food = packet.getFoodLevel(); + } + + public S06(float health, float saturation, int food) { + super(new S06PacketUpdateHealth(health, food, saturation)); + this.health = health; + this.saturation = saturation; + this.food = food; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S08.java b/src/main/java/keystrokesmod/script/packet/clientbound/S08.java index f8c1c59..d7e0459 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S08.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S08.java @@ -1,49 +1,49 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Vec3; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; - -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Set; - -public class S08 extends SPacket { - public Vec3 position; - public float yaw; - public float pitch; - public Set enumFlags; - - public S08(S08PacketPlayerPosLook packet) { - super(packet); - this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); - this.yaw = packet.getYaw(); - this.pitch = packet.getPitch(); - - Set flags = packet.func_179834_f(); - Set flagsStr = new HashSet<>(flags.size()); - for (S08PacketPlayerPosLook.EnumFlags flag : flags) { - flagsStr.add(flag.name()); - } - this.enumFlags = flagsStr; - } - - public S08(Vec3 position, float yaw, float pitch, Set enumFlags) { - super(create(position, yaw, pitch, enumFlags)); - this.position = position; - this.yaw = yaw; - this.pitch = pitch; - this.enumFlags = enumFlags; - } - - private static S08PacketPlayerPosLook create(Vec3 position, float yaw, float pitch, Set enumFlags) { - Set enumSet = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class); - for (String flag : enumFlags) { - S08PacketPlayerPosLook.EnumFlags enumFlag = Utils.getEnum(S08PacketPlayerPosLook.EnumFlags.class, flag); - if (enumFlag != null) { - enumSet.add(enumFlag); - } - } - return new S08PacketPlayerPosLook(position.x, position.y, position.z, yaw, pitch, enumSet); - } +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Vec3; +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; + +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + +public class S08 extends SPacket { + public Vec3 position; + public float yaw; + public float pitch; + public Set enumFlags; + + public S08(S08PacketPlayerPosLook packet) { + super(packet); + this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); + this.yaw = packet.getYaw(); + this.pitch = packet.getPitch(); + + Set flags = packet.func_179834_f(); + Set flagsStr = new HashSet<>(flags.size()); + for (S08PacketPlayerPosLook.EnumFlags flag : flags) { + flagsStr.add(flag.name()); + } + this.enumFlags = flagsStr; + } + + public S08(Vec3 position, float yaw, float pitch, Set enumFlags) { + super(create(position, yaw, pitch, enumFlags)); + this.position = position; + this.yaw = yaw; + this.pitch = pitch; + this.enumFlags = enumFlags; + } + + private static S08PacketPlayerPosLook create(Vec3 position, float yaw, float pitch, Set enumFlags) { + Set enumSet = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class); + for (String flag : enumFlags) { + S08PacketPlayerPosLook.EnumFlags enumFlag = Utils.getEnum(S08PacketPlayerPosLook.EnumFlags.class, flag); + if (enumFlag != null) { + enumSet.add(enumFlag); + } + } + return new S08PacketPlayerPosLook(position.x, position.y, position.z, yaw, pitch, enumSet); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S0B.java b/src/main/java/keystrokesmod/script/packet/clientbound/S0B.java index e4839bb..4277bac 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S0B.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S0B.java @@ -1,32 +1,32 @@ -package keystrokesmod.script.packet.clientbound; - -import com.mojang.authlib.GameProfile; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.entity.Entity; -import net.minecraft.network.play.server.S0BPacketAnimation; - -import java.util.UUID; - -public class S0B extends SPacket { - public int entityId; - public int type; - - public S0B(S0BPacketAnimation packet) { - super(packet); - this.entityId = packet.getEntityID(); - this.type = packet.getAnimationType(); - } - - public S0B(int entityId, int type) { - super(new S0BPacketAnimation(createEntityWithCustomID(entityId), type)); - this.entityId = entityId; - this.type = type; - } - - private static Entity createEntityWithCustomID(int id) { - EntityOtherPlayerMP entity = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, new GameProfile(UUID.fromString("ae7a42d0-31b1-4926-ba4c-f28d6efad4a9"), "")); - entity.setEntityId(id); - return entity; - } -} +package keystrokesmod.script.packet.clientbound; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.entity.Entity; +import net.minecraft.network.play.server.S0BPacketAnimation; + +import java.util.UUID; + +public class S0B extends SPacket { + public int entityId; + public int type; + + public S0B(S0BPacketAnimation packet) { + super(packet); + this.entityId = packet.getEntityID(); + this.type = packet.getAnimationType(); + } + + public S0B(int entityId, int type) { + super(new S0BPacketAnimation(createEntityWithCustomID(entityId), type)); + this.entityId = entityId; + this.type = type; + } + + private static Entity createEntityWithCustomID(int id) { + EntityOtherPlayerMP entity = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, new GameProfile(UUID.fromString("ae7a42d0-31b1-4926-ba4c-f28d6efad4a9"), "")); + entity.setEntityId(id); + return entity; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S12.java b/src/main/java/keystrokesmod/script/packet/clientbound/S12.java index 7f22c99..cc86577 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S12.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S12.java @@ -1,21 +1,21 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.server.S12PacketEntityVelocity; - -public class S12 extends SPacket { - public int entityId; - public Vec3 motion; - - public S12(S12PacketEntityVelocity packet) { - super(packet); - this.entityId = packet.getEntityID(); - this.motion = new Vec3(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ()); - } - - public S12(int entityId, Vec3 motion) { - super(new S12PacketEntityVelocity(entityId, motion.x, motion.y, motion.z)); - this.entityId = entityId; - this.motion = motion; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.server.S12PacketEntityVelocity; + +public class S12 extends SPacket { + public int entityId; + public Vec3 motion; + + public S12(S12PacketEntityVelocity packet) { + super(packet); + this.entityId = packet.getEntityID(); + this.motion = new Vec3(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ()); + } + + public S12(int entityId, Vec3 motion) { + super(new S12PacketEntityVelocity(entityId, motion.x, motion.y, motion.z)); + this.entityId = entityId; + this.motion = motion; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S14.java b/src/main/java/keystrokesmod/script/packet/clientbound/S14.java index f8ddc23..454c74b 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S14.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S14.java @@ -1,54 +1,54 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.mixin.impl.accessor.IAccessorS14PacketEntity; -import net.minecraft.network.play.server.S14PacketEntity; - -public class S14 extends SPacket { - public int entityId; - public byte posX; - public byte posY; - public byte posZ; - public byte yaw; - public byte pitch; - public boolean onGround; - public boolean rotating; - - public S14(S14PacketEntity e) { - super(e); - this.entityId = ((IAccessorS14PacketEntity) e).getEntityId(); - this.posX = e.func_149062_c(); - this.posY = e.func_149061_d(); - this.posZ = e.func_149064_e(); - this.yaw = e.func_149066_f(); - this.pitch = e.func_149063_g(); - this.rotating = e.func_149060_h(); - } - - public S14(int entityId, byte posX, byte posY, byte posZ, byte yaw, byte pitch, boolean onGround) { - super(new S14PacketEntity.S17PacketEntityLookMove(entityId, posX, posY, posZ, yaw, pitch, onGround)); - this.entityId = entityId; - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - this.yaw = yaw; - this.pitch = pitch; - this.onGround = onGround; - } - - public S14(int entityId, byte posX, byte posY, byte posZ, boolean onGround) { - super(new S14PacketEntity.S15PacketEntityRelMove(entityId, posX, posY, posZ, onGround)); - this.entityId = entityId; - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - this.onGround = onGround; - } - - public S14(int entityId, byte yaw, byte pitch, boolean onGround) { - super(new S14PacketEntity.S16PacketEntityLook(entityId, yaw, pitch, onGround)); - this.entityId = entityId; - this.yaw = yaw; - this.pitch = pitch; - this.onGround = onGround; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.mixin.impl.accessor.IAccessorS14PacketEntity; +import net.minecraft.network.play.server.S14PacketEntity; + +public class S14 extends SPacket { + public int entityId; + public byte posX; + public byte posY; + public byte posZ; + public byte yaw; + public byte pitch; + public boolean onGround; + public boolean rotating; + + public S14(S14PacketEntity e) { + super(e); + this.entityId = ((IAccessorS14PacketEntity) e).getEntityId(); + this.posX = e.func_149062_c(); + this.posY = e.func_149061_d(); + this.posZ = e.func_149064_e(); + this.yaw = e.func_149066_f(); + this.pitch = e.func_149063_g(); + this.rotating = e.func_149060_h(); + } + + public S14(int entityId, byte posX, byte posY, byte posZ, byte yaw, byte pitch, boolean onGround) { + super(new S14PacketEntity.S17PacketEntityLookMove(entityId, posX, posY, posZ, yaw, pitch, onGround)); + this.entityId = entityId; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.yaw = yaw; + this.pitch = pitch; + this.onGround = onGround; + } + + public S14(int entityId, byte posX, byte posY, byte posZ, boolean onGround) { + super(new S14PacketEntity.S15PacketEntityRelMove(entityId, posX, posY, posZ, onGround)); + this.entityId = entityId; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.onGround = onGround; + } + + public S14(int entityId, byte yaw, byte pitch, boolean onGround) { + super(new S14PacketEntity.S16PacketEntityLook(entityId, yaw, pitch, onGround)); + this.entityId = entityId; + this.yaw = yaw; + this.pitch = pitch; + this.onGround = onGround; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S23.java b/src/main/java/keystrokesmod/script/packet/clientbound/S23.java index e13939f..f49a4d0 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S23.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S23.java @@ -1,24 +1,24 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Block; -import keystrokesmod.script.model.Vec3; -import net.minecraft.client.Minecraft; -import net.minecraft.network.play.server.S23PacketBlockChange; -import net.minecraft.util.BlockPos; - -public class S23 extends SPacket { - public Vec3 position; - public Block block; - - public S23(S23PacketBlockChange packet, byte f) { - super(packet); - this.position = Vec3.convert(packet.getBlockPosition()); - this.block = new Block(packet.getBlockState(), new BlockPos(position.x, position.y, position.z)); - } - - public S23(Vec3 position) { - super(new S23PacketBlockChange(Minecraft.getMinecraft().theWorld, Vec3.getBlockPos(position))); - this.position = position; - this.block = new Block(position); - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Block; +import keystrokesmod.script.model.Vec3; +import net.minecraft.client.Minecraft; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.util.BlockPos; + +public class S23 extends SPacket { + public Vec3 position; + public Block block; + + public S23(S23PacketBlockChange packet, byte f) { + super(packet); + this.position = Vec3.convert(packet.getBlockPosition()); + this.block = new Block(packet.getBlockState(), new BlockPos(position.x, position.y, position.z)); + } + + public S23(Vec3 position) { + super(new S23PacketBlockChange(Minecraft.getMinecraft().theWorld, Vec3.getBlockPos(position))); + this.position = position; + this.block = new Block(position); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S25.java b/src/main/java/keystrokesmod/script/packet/clientbound/S25.java index 4611565..03e39e6 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S25.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S25.java @@ -1,33 +1,33 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Block; -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.server.S25PacketBlockBreakAnim; -import net.minecraft.util.BlockPos; - -public class S25 extends SPacket { - public int entityId; - public Block block; - public int progress; - - public S25(S25PacketBlockBreakAnim packet) { - super(packet); - this.entityId = packet.getBreakerId(); - this.block = new Block(Vec3.convert(packet.getPosition())); - this.progress = packet.getProgress(); - } - - public S25(int entityId, Block block, int progress) { - super(new S25PacketBlockBreakAnim(entityId, new BlockPos(block.x, block.y, block.z), progress)); - this.entityId = entityId; - this.block = block; - this.progress = progress; - } - - public S25(int entityId, Vec3 position, int progress) { - super(new S25PacketBlockBreakAnim(entityId, Vec3.getBlockPos(position), progress)); - this.entityId = entityId; - this.block = new Block(position); - this.progress = progress; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Block; +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.server.S25PacketBlockBreakAnim; +import net.minecraft.util.BlockPos; + +public class S25 extends SPacket { + public int entityId; + public Block block; + public int progress; + + public S25(S25PacketBlockBreakAnim packet) { + super(packet); + this.entityId = packet.getBreakerId(); + this.block = new Block(Vec3.convert(packet.getPosition())); + this.progress = packet.getProgress(); + } + + public S25(int entityId, Block block, int progress) { + super(new S25PacketBlockBreakAnim(entityId, new BlockPos(block.x, block.y, block.z), progress)); + this.entityId = entityId; + this.block = block; + this.progress = progress; + } + + public S25(int entityId, Vec3 position, int progress) { + super(new S25PacketBlockBreakAnim(entityId, Vec3.getBlockPos(position), progress)); + this.entityId = entityId; + this.block = new Block(position); + this.progress = progress; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S27.java b/src/main/java/keystrokesmod/script/packet/clientbound/S27.java index ddec966..75191ed 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S27.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S27.java @@ -1,44 +1,44 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraft.util.BlockPos; - -import java.util.ArrayList; -import java.util.List; - -public class S27 extends SPacket { - public float strength; - public Vec3 position; - public Vec3 motion; - public List affectedBlockPositions; - - public S27(S27PacketExplosion packet) { - super(packet); - this.strength = packet.getStrength(); - this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); - this.motion = new Vec3(packet.func_149149_c(), packet.func_149144_d(), packet.func_149147_e()); - - List affectedBlockPositions = new ArrayList<>(); - for (BlockPos blockPos : packet.getAffectedBlockPositions()) { - affectedBlockPositions.add(Vec3.convert(blockPos)); - } - this.affectedBlockPositions = affectedBlockPositions; - } - - public S27(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { - super(create(strength, position, motion, affectedBlockPositions)); - this.strength = strength; - this.position = position; - this.motion = motion; - this.affectedBlockPositions = affectedBlockPositions; - } - - private static S27PacketExplosion create(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { - List list = new ArrayList<>(); - for (Vec3 vec3 : affectedBlockPositions) { - list.add(Vec3.getBlockPos(vec3)); - } - return new S27PacketExplosion(position.x, position.y, position.z, strength, list, Vec3.getVec3(motion)); - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.BlockPos; + +import java.util.ArrayList; +import java.util.List; + +public class S27 extends SPacket { + public float strength; + public Vec3 position; + public Vec3 motion; + public List affectedBlockPositions; + + public S27(S27PacketExplosion packet) { + super(packet); + this.strength = packet.getStrength(); + this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); + this.motion = new Vec3(packet.func_149149_c(), packet.func_149144_d(), packet.func_149147_e()); + + List affectedBlockPositions = new ArrayList<>(); + for (BlockPos blockPos : packet.getAffectedBlockPositions()) { + affectedBlockPositions.add(Vec3.convert(blockPos)); + } + this.affectedBlockPositions = affectedBlockPositions; + } + + public S27(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { + super(create(strength, position, motion, affectedBlockPositions)); + this.strength = strength; + this.position = position; + this.motion = motion; + this.affectedBlockPositions = affectedBlockPositions; + } + + private static S27PacketExplosion create(float strength, Vec3 position, Vec3 motion, List affectedBlockPositions) { + List list = new ArrayList<>(); + for (Vec3 vec3 : affectedBlockPositions) { + list.add(Vec3.getBlockPos(vec3)); + } + return new S27PacketExplosion(position.x, position.y, position.z, strength, list, Vec3.getVec3(motion)); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S29.java b/src/main/java/keystrokesmod/script/packet/clientbound/S29.java index cfddc58..c2dbc95 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S29.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S29.java @@ -1,27 +1,27 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.server.S29PacketSoundEffect; - -public class S29 extends SPacket { - public String sound; - public Vec3 position; - public float volume; - public float pitch; - - public S29(S29PacketSoundEffect packet) { - super(packet); - this.sound = packet.getSoundName(); - this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); - this.volume = packet.getVolume(); - this.pitch = packet.getPitch(); - } - - public S29(String sound, Vec3 position, float volume, float pitch) { - super(new S29PacketSoundEffect(sound, position.x, position.y, position.z, volume, pitch)); - this.sound = sound; - this.position = position; - this.volume = volume; - this.pitch = pitch; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.server.S29PacketSoundEffect; + +public class S29 extends SPacket { + public String sound; + public Vec3 position; + public float volume; + public float pitch; + + public S29(S29PacketSoundEffect packet) { + super(packet); + this.sound = packet.getSoundName(); + this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ()); + this.volume = packet.getVolume(); + this.pitch = packet.getPitch(); + } + + public S29(String sound, Vec3 position, float volume, float pitch) { + super(new S29PacketSoundEffect(sound, position.x, position.y, position.z, volume, pitch)); + this.sound = sound; + this.position = position; + this.volume = volume; + this.pitch = pitch; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S2A.java b/src/main/java/keystrokesmod/script/packet/clientbound/S2A.java index 68eec90..5151170 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S2A.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S2A.java @@ -1,38 +1,38 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.Vec3; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.server.S2APacketParticles; -import net.minecraft.util.EnumParticleTypes; - -public class S2A extends SPacket { - public String type; - public Vec3 position; - public Vec3 offset; - public float speed; - public int count; - public boolean longDistance; - public int[] args; - - public S2A(S2APacketParticles packet) { - super(packet); - this.type = packet.getParticleType().name(); - this.longDistance = packet.isLongDistance(); - this.position = new Vec3(packet.getXCoordinate(), packet.getYCoordinate(), packet.getZCoordinate()); - this.offset = new Vec3(packet.getXOffset(), packet.getYOffset(), packet.getZOffset()); - this.speed = packet.getParticleSpeed(); - this.count = packet.getParticleCount(); - this.args = packet.getParticleArgs(); - } - - public S2A(String type, boolean longDistance, Vec3 position, Vec3 offset, float speed, int count, int[] args) { - super(new S2APacketParticles(Utils.getEnum(EnumParticleTypes.class, type), longDistance, (float) position.x, (float) position.y, (float) position.z, (float) offset.x, (float) offset.y, (float) offset.z, speed, count, args)); - this.type = type; - this.longDistance = longDistance; - this.position = position; - this.offset = offset; - this.speed = speed; - this.count = count; - this.args = args; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.Vec3; +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.util.EnumParticleTypes; + +public class S2A extends SPacket { + public String type; + public Vec3 position; + public Vec3 offset; + public float speed; + public int count; + public boolean longDistance; + public int[] args; + + public S2A(S2APacketParticles packet) { + super(packet); + this.type = packet.getParticleType().name(); + this.longDistance = packet.isLongDistance(); + this.position = new Vec3(packet.getXCoordinate(), packet.getYCoordinate(), packet.getZCoordinate()); + this.offset = new Vec3(packet.getXOffset(), packet.getYOffset(), packet.getZOffset()); + this.speed = packet.getParticleSpeed(); + this.count = packet.getParticleCount(); + this.args = packet.getParticleArgs(); + } + + public S2A(String type, boolean longDistance, Vec3 position, Vec3 offset, float speed, int count, int[] args) { + super(new S2APacketParticles(Utils.getEnum(EnumParticleTypes.class, type), longDistance, (float) position.x, (float) position.y, (float) position.z, (float) offset.x, (float) offset.y, (float) offset.z, speed, count, args)); + this.type = type; + this.longDistance = longDistance; + this.position = position; + this.offset = offset; + this.speed = speed; + this.count = count; + this.args = args; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S2F.java b/src/main/java/keystrokesmod/script/packet/clientbound/S2F.java index 1153e02..c2ad394 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S2F.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S2F.java @@ -1,24 +1,24 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.script.model.ItemStack; -import net.minecraft.network.play.server.S2FPacketSetSlot; - -public class S2F extends SPacket { - public int windowId; - public int slot; - public ItemStack itemStack; - - public S2F(S2FPacketSetSlot packet) { - super(packet); - this.windowId = packet.func_149175_c(); - this.slot = packet.func_149173_d(); - this.itemStack = ItemStack.convert(packet.func_149174_e()); - } - - public S2F(int windowId, int slot, ItemStack itemStack) { - super(new S2FPacketSetSlot(windowId, slot, itemStack.itemStack)); - this.windowId = windowId; - this.slot = slot; - this.itemStack = itemStack; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.script.model.ItemStack; +import net.minecraft.network.play.server.S2FPacketSetSlot; + +public class S2F extends SPacket { + public int windowId; + public int slot; + public ItemStack itemStack; + + public S2F(S2FPacketSetSlot packet) { + super(packet); + this.windowId = packet.func_149175_c(); + this.slot = packet.func_149173_d(); + this.itemStack = ItemStack.convert(packet.func_149174_e()); + } + + public S2F(int windowId, int slot, ItemStack itemStack) { + super(new S2FPacketSetSlot(windowId, slot, itemStack.itemStack)); + this.windowId = windowId; + this.slot = slot; + this.itemStack = itemStack; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S3A.java b/src/main/java/keystrokesmod/script/packet/clientbound/S3A.java index eb2dc0c..13f42b9 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S3A.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S3A.java @@ -1,17 +1,17 @@ -package keystrokesmod.script.packet.clientbound; - -import net.minecraft.network.play.server.S3APacketTabComplete; - -public class S3A extends SPacket { - public String[] matches; - - public S3A(S3APacketTabComplete packet, byte f) { - super(packet); - this.matches = packet.func_149630_c(); - } - - public S3A(String[] matches) { - super(new S3APacketTabComplete(matches)); - this.matches = matches; - } -} +package keystrokesmod.script.packet.clientbound; + +import net.minecraft.network.play.server.S3APacketTabComplete; + +public class S3A extends SPacket { + public String[] matches; + + public S3A(S3APacketTabComplete packet, byte f) { + super(packet); + this.matches = packet.func_149630_c(); + } + + public S3A(String[] matches) { + super(new S3APacketTabComplete(matches)); + this.matches = matches; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S3E.java b/src/main/java/keystrokesmod/script/packet/clientbound/S3E.java index 8500f01..ad78a00 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S3E.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S3E.java @@ -1,44 +1,44 @@ -package keystrokesmod.script.packet.clientbound; - -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S3EPacketTeams; - -import java.util.Collection; - -public class S3E extends SPacket { - public String name; - public String displayName; - public String prefix; - public String suffix; - public String nametagVisibility; - public Collection playerList; - public int action; - public int friendlyFlags; - public int color; - - public S3E(S3EPacketTeams packet) { - super(packet); - this.name = packet.getName(); - this.displayName = packet.getDisplayName(); - this.prefix = packet.getPrefix(); - this.suffix = packet.getSuffix(); - this.nametagVisibility = packet.getNameTagVisibility(); - this.playerList = packet.getPlayers(); - this.action = packet.getAction(); - this.friendlyFlags = packet.getFriendlyFlags(); - this.color = packet.getColor(); - } - - public S3E(Packet packet, String name, String displayName, String prefix, String suffix, String nametagVisibility, Collection playerList, int action, int friendlyFlags, int color) { - super(packet); - this.name = name; - this.displayName = displayName; - this.prefix = prefix; - this.suffix = suffix; - this.nametagVisibility = nametagVisibility; - this.playerList = playerList; - this.action = action; - this.friendlyFlags = friendlyFlags; - this.color = color; - } -} +package keystrokesmod.script.packet.clientbound; + +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S3EPacketTeams; + +import java.util.Collection; + +public class S3E extends SPacket { + public String name; + public String displayName; + public String prefix; + public String suffix; + public String nametagVisibility; + public Collection playerList; + public int action; + public int friendlyFlags; + public int color; + + public S3E(S3EPacketTeams packet) { + super(packet); + this.name = packet.getName(); + this.displayName = packet.getDisplayName(); + this.prefix = packet.getPrefix(); + this.suffix = packet.getSuffix(); + this.nametagVisibility = packet.getNameTagVisibility(); + this.playerList = packet.getPlayers(); + this.action = packet.getAction(); + this.friendlyFlags = packet.getFriendlyFlags(); + this.color = packet.getColor(); + } + + public S3E(Packet packet, String name, String displayName, String prefix, String suffix, String nametagVisibility, Collection playerList, int action, int friendlyFlags, int color) { + super(packet); + this.name = name; + this.displayName = displayName; + this.prefix = prefix; + this.suffix = suffix; + this.nametagVisibility = nametagVisibility; + this.playerList = playerList; + this.action = action; + this.friendlyFlags = friendlyFlags; + this.color = color; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S45.java b/src/main/java/keystrokesmod/script/packet/clientbound/S45.java index 7f19096..a161844 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S45.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S45.java @@ -1,31 +1,31 @@ -package keystrokesmod.script.packet.clientbound; - -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.server.S45PacketTitle; -import net.minecraft.util.ChatComponentText; - -public class S45 extends SPacket { - public String type; - public String message; - private int fadeInTime; - private int displayTime; - private int fadeOutTime; - - public S45(S45PacketTitle packet) { - super(packet); - this.type = packet.getType().name(); - this.message = packet.getMessage().getUnformattedText(); - this.fadeInTime = packet.getFadeInTime(); - this.displayTime = packet.getDisplayTime(); - this.fadeOutTime = packet.getFadeOutTime(); - } - - public S45(String type, String message, int fadeInTime, int displayTime, int fadeOutTime) { - super(new S45PacketTitle(Utils.getEnum(S45PacketTitle.Type.class, type), new ChatComponentText(message), fadeInTime, displayTime, fadeOutTime)); - this.type = type; - this.message = message; - this.fadeInTime = fadeInTime; - this.displayTime = displayTime; - this.fadeOutTime = fadeOutTime; - } -} +package keystrokesmod.script.packet.clientbound; + +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.server.S45PacketTitle; +import net.minecraft.util.ChatComponentText; + +public class S45 extends SPacket { + public String type; + public String message; + private int fadeInTime; + private int displayTime; + private int fadeOutTime; + + public S45(S45PacketTitle packet) { + super(packet); + this.type = packet.getType().name(); + this.message = packet.getMessage().getUnformattedText(); + this.fadeInTime = packet.getFadeInTime(); + this.displayTime = packet.getDisplayTime(); + this.fadeOutTime = packet.getFadeOutTime(); + } + + public S45(String type, String message, int fadeInTime, int displayTime, int fadeOutTime) { + super(new S45PacketTitle(Utils.getEnum(S45PacketTitle.Type.class, type), new ChatComponentText(message), fadeInTime, displayTime, fadeOutTime)); + this.type = type; + this.message = message; + this.fadeInTime = fadeInTime; + this.displayTime = displayTime; + this.fadeOutTime = fadeOutTime; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/S48.java b/src/main/java/keystrokesmod/script/packet/clientbound/S48.java index 89456f7..ac4354c 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/S48.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/S48.java @@ -1,20 +1,20 @@ -package keystrokesmod.script.packet.clientbound; - -import net.minecraft.network.play.server.S48PacketResourcePackSend; - -public class S48 extends SPacket { - public String url; - public String hash; - - public S48(S48PacketResourcePackSend packet) { - super(packet); - this.url = packet.getURL(); - this.hash = packet.getHash(); - } - - public S48(String url, String hash) { - super(new S48PacketResourcePackSend(url, hash)); - this.url = url; - this.hash = hash; - } -} +package keystrokesmod.script.packet.clientbound; + +import net.minecraft.network.play.server.S48PacketResourcePackSend; + +public class S48 extends SPacket { + public String url; + public String hash; + + public S48(S48PacketResourcePackSend packet) { + super(packet); + this.url = packet.getURL(); + this.hash = packet.getHash(); + } + + public S48(String url, String hash) { + super(new S48PacketResourcePackSend(url, hash)); + this.url = url; + this.hash = hash; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/clientbound/SPacket.java b/src/main/java/keystrokesmod/script/packet/clientbound/SPacket.java index 96490c5..c07cbd2 100644 --- a/src/main/java/keystrokesmod/script/packet/clientbound/SPacket.java +++ b/src/main/java/keystrokesmod/script/packet/clientbound/SPacket.java @@ -1,11 +1,11 @@ -package keystrokesmod.script.packet.clientbound; - -public class SPacket { - public String name; - public net.minecraft.network.Packet packet; - - public SPacket(net.minecraft.network.Packet packet) { - this.packet = packet; - this.name = packet.getClass().getSimpleName(); - } -} +package keystrokesmod.script.packet.clientbound; + +public class SPacket { + public String name; + public net.minecraft.network.Packet packet; + + public SPacket(net.minecraft.network.Packet packet) { + this.packet = packet; + this.name = packet.getClass().getSimpleName(); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C01.java b/src/main/java/keystrokesmod/script/packet/serverbound/C01.java index 72272f3..742fe26 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C01.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C01.java @@ -1,22 +1,22 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.play.client.C01PacketChatMessage; - -public class C01 extends CPacket { - public String message; - - public C01(String message) { - super(null); - this.message = message; - } - - public C01(C01PacketChatMessage packet, byte f) { - super(packet); - this.message = packet.getMessage(); - } - - @Override - public C01PacketChatMessage convert() { - return new C01PacketChatMessage(this.message); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.play.client.C01PacketChatMessage; + +public class C01 extends CPacket { + public String message; + + public C01(String message) { + super(null); + this.message = message; + } + + public C01(C01PacketChatMessage packet, byte f) { + super(packet); + this.message = packet.getMessage(); + } + + @Override + public C01PacketChatMessage convert() { + return new C01PacketChatMessage(this.message); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C02.java b/src/main/java/keystrokesmod/script/packet/serverbound/C02.java index 1ac372c..636681e 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C02.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C02.java @@ -1,43 +1,43 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.Entity; -import keystrokesmod.script.model.Vec3; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.network.play.client.C02PacketUseEntity; - -public class C02 extends CPacket { - public Entity entity; - public String action; - public Vec3 hitVec; - - public C02(Entity entity, String action, Vec3 hitVec) { - super(null); - this.entity = entity; - this.action = action; - this.hitVec = hitVec; - } - - public C02(C02PacketUseEntity packet) { - super(packet); - if (packet.getEntityFromWorld(Minecraft.getMinecraft().theWorld) == null) { - this.entity = null; - } - else { - this.entity = Entity.convert(packet.getEntityFromWorld(Minecraft.getMinecraft().theWorld)); - } - this.action = packet.getAction().name(); - if (packet.getHitVec() != null) { - this.hitVec = new Vec3(packet.getHitVec().xCoord, packet.getHitVec().yCoord, packet.getHitVec().zCoord); - } - } - - @Override - public C02PacketUseEntity convert() { - C02PacketUseEntity.Action action = Utils.getEnum(C02PacketUseEntity.Action.class, this.action); - if (this.hitVec != null && action == C02PacketUseEntity.Action.INTERACT_AT) { - return new C02PacketUseEntity(this.entity.entity, new net.minecraft.util.Vec3(this.hitVec.x, this.hitVec.y, this.hitVec.z)); - } - return new C02PacketUseEntity(this.entity.entity, action); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.Entity; +import keystrokesmod.script.model.Vec3; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.network.play.client.C02PacketUseEntity; + +public class C02 extends CPacket { + public Entity entity; + public String action; + public Vec3 hitVec; + + public C02(Entity entity, String action, Vec3 hitVec) { + super(null); + this.entity = entity; + this.action = action; + this.hitVec = hitVec; + } + + public C02(C02PacketUseEntity packet) { + super(packet); + if (packet.getEntityFromWorld(Minecraft.getMinecraft().theWorld) == null) { + this.entity = null; + } + else { + this.entity = Entity.convert(packet.getEntityFromWorld(Minecraft.getMinecraft().theWorld)); + } + this.action = packet.getAction().name(); + if (packet.getHitVec() != null) { + this.hitVec = new Vec3(packet.getHitVec().xCoord, packet.getHitVec().yCoord, packet.getHitVec().zCoord); + } + } + + @Override + public C02PacketUseEntity convert() { + C02PacketUseEntity.Action action = Utils.getEnum(C02PacketUseEntity.Action.class, this.action); + if (this.hitVec != null && action == C02PacketUseEntity.Action.INTERACT_AT) { + return new C02PacketUseEntity(this.entity.entity, new net.minecraft.util.Vec3(this.hitVec.x, this.hitVec.y, this.hitVec.z)); + } + return new C02PacketUseEntity(this.entity.entity, action); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C03.java b/src/main/java/keystrokesmod/script/packet/serverbound/C03.java index f642a7c..2d16985 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C03.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C03.java @@ -1,49 +1,49 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.client.C03PacketPlayer; - -public class C03 extends CPacket { - public Vec3 position; - public float yaw; - public float pitch; - public boolean ground; - - public C03(C03PacketPlayer packet, byte f1, byte f2, byte f3, byte f4, byte f5, byte f6) { // goofy asf but cba to - super(packet); - if (packet instanceof C03PacketPlayer.C04PacketPlayerPosition || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - this.position = new Vec3(packet.getPositionX(), packet.getPositionY(), packet.getPositionZ()); - } - if (packet instanceof C03PacketPlayer.C05PacketPlayerLook || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - this.yaw = packet.getYaw(); - this.pitch = packet.getPitch(); - } - this.ground = packet.isOnGround(); - } - - public C03(boolean ground) { - super(new C03PacketPlayer(ground)); - this.ground = ground; - } - - public C03(Vec3 position, boolean ground) { - super(new C03PacketPlayer.C04PacketPlayerPosition(position.x, position.y, position.z, ground)); - this.position = position; - this.ground = ground; - } - - public C03(float yaw, float pitch, boolean ground) { - super(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, ground)); - this.yaw = yaw; - this.pitch = pitch; - this.ground = ground; - } - - public C03(Vec3 position, float yaw, float pitch, boolean ground) { - super(new C03PacketPlayer.C06PacketPlayerPosLook(position.x, position.y, position.z, yaw, pitch, ground)); - this.position = position; - this.yaw = yaw; - this.pitch = pitch; - this.ground = ground; - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.client.C03PacketPlayer; + +public class C03 extends CPacket { + public Vec3 position; + public float yaw; + public float pitch; + public boolean ground; + + public C03(C03PacketPlayer packet, byte f1, byte f2, byte f3, byte f4, byte f5, byte f6) { // goofy asf but cba to + super(packet); + if (packet instanceof C03PacketPlayer.C04PacketPlayerPosition || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { + this.position = new Vec3(packet.getPositionX(), packet.getPositionY(), packet.getPositionZ()); + } + if (packet instanceof C03PacketPlayer.C05PacketPlayerLook || packet instanceof C03PacketPlayer.C06PacketPlayerPosLook) { + this.yaw = packet.getYaw(); + this.pitch = packet.getPitch(); + } + this.ground = packet.isOnGround(); + } + + public C03(boolean ground) { + super(new C03PacketPlayer(ground)); + this.ground = ground; + } + + public C03(Vec3 position, boolean ground) { + super(new C03PacketPlayer.C04PacketPlayerPosition(position.x, position.y, position.z, ground)); + this.position = position; + this.ground = ground; + } + + public C03(float yaw, float pitch, boolean ground) { + super(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, ground)); + this.yaw = yaw; + this.pitch = pitch; + this.ground = ground; + } + + public C03(Vec3 position, float yaw, float pitch, boolean ground) { + super(new C03PacketPlayer.C06PacketPlayerPosLook(position.x, position.y, position.z, yaw, pitch, ground)); + this.position = position; + this.yaw = yaw; + this.pitch = pitch; + this.ground = ground; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C07.java b/src/main/java/keystrokesmod/script/packet/serverbound/C07.java index 83a1dc8..884a465 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C07.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C07.java @@ -1,32 +1,32 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.Vec3; -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; - -public class C07 extends CPacket { - public Vec3 position; - public String status; - public String facing; - - public C07(Vec3 position, String status, String facing) { - super(null); - this.position = position; - this.status = status; - this.facing = facing; - } - - public C07(C07PacketPlayerDigging packet) { - super(packet); - this.position = Vec3.convert(packet.getPosition()); - this.status = packet.getStatus().name(); - this.facing = packet.getFacing().name(); - } - - @Override - public C07PacketPlayerDigging convert() { - return new C07PacketPlayerDigging(Utils.getEnum(C07PacketPlayerDigging.Action.class, this.status), new BlockPos(this.position.x, this.position.y, this.position.z), Utils.getEnum(EnumFacing.class, this.facing)); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.Vec3; +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; + +public class C07 extends CPacket { + public Vec3 position; + public String status; + public String facing; + + public C07(Vec3 position, String status, String facing) { + super(null); + this.position = position; + this.status = status; + this.facing = facing; + } + + public C07(C07PacketPlayerDigging packet) { + super(packet); + this.position = Vec3.convert(packet.getPosition()); + this.status = packet.getStatus().name(); + this.facing = packet.getFacing().name(); + } + + @Override + public C07PacketPlayerDigging convert() { + return new C07PacketPlayerDigging(Utils.getEnum(C07PacketPlayerDigging.Action.class, this.status), new BlockPos(this.position.x, this.position.y, this.position.z), Utils.getEnum(EnumFacing.class, this.facing)); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C08.java b/src/main/java/keystrokesmod/script/packet/serverbound/C08.java index 35f424e..ccbda57 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C08.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C08.java @@ -1,33 +1,33 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.ItemStack; -import keystrokesmod.script.model.Vec3; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; - -public class C08 extends CPacket { - public ItemStack itemStack; - public Vec3 position; - public int direction; - public Vec3 offset; - - public C08(ItemStack itemStack, Vec3 position, int direction, Vec3 offset) { - super(null); - this.itemStack = itemStack; - this.position = position; - this.direction = direction; - this.offset = offset; - } - - public C08(C08PacketPlayerBlockPlacement packet) { - super(packet); - this.itemStack = ItemStack.convert(packet.getStack()); - this.position = Vec3.convert(packet.getPosition()); - this.direction = packet.getPlacedBlockDirection(); - this.offset = new Vec3(packet.getPlacedBlockOffsetX(), packet.getPlacedBlockOffsetY(), packet.getPlacedBlockOffsetZ()); - } - - @Override - public C08PacketPlayerBlockPlacement convert() { - return new C08PacketPlayerBlockPlacement(Vec3.getBlockPos(this.position), this.direction, this.itemStack != null ? this.itemStack.itemStack : null, (float) this.offset.x, (float) this.offset.y, (float) this.offset.z); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.ItemStack; +import keystrokesmod.script.model.Vec3; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; + +public class C08 extends CPacket { + public ItemStack itemStack; + public Vec3 position; + public int direction; + public Vec3 offset; + + public C08(ItemStack itemStack, Vec3 position, int direction, Vec3 offset) { + super(null); + this.itemStack = itemStack; + this.position = position; + this.direction = direction; + this.offset = offset; + } + + public C08(C08PacketPlayerBlockPlacement packet) { + super(packet); + this.itemStack = ItemStack.convert(packet.getStack()); + this.position = Vec3.convert(packet.getPosition()); + this.direction = packet.getPlacedBlockDirection(); + this.offset = new Vec3(packet.getPlacedBlockOffsetX(), packet.getPlacedBlockOffsetY(), packet.getPlacedBlockOffsetZ()); + } + + @Override + public C08PacketPlayerBlockPlacement convert() { + return new C08PacketPlayerBlockPlacement(Vec3.getBlockPos(this.position), this.direction, this.itemStack != null ? this.itemStack.itemStack : null, (float) this.offset.x, (float) this.offset.y, (float) this.offset.z); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C09.java b/src/main/java/keystrokesmod/script/packet/serverbound/C09.java index fc75ec0..053b6b4 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C09.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C09.java @@ -1,22 +1,22 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.play.client.C09PacketHeldItemChange; - -public class C09 extends CPacket { - public int slot; - - public C09(int slot) { - super(null); - this.slot = slot; - } - - public C09(C09PacketHeldItemChange packet, boolean identifier) { - super(packet); - this.slot = packet.getSlotId(); - } - - @Override - public C09PacketHeldItemChange convert() { - return new C09PacketHeldItemChange(this.slot); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.play.client.C09PacketHeldItemChange; + +public class C09 extends CPacket { + public int slot; + + public C09(int slot) { + super(null); + this.slot = slot; + } + + public C09(C09PacketHeldItemChange packet, boolean identifier) { + super(packet); + this.slot = packet.getSlotId(); + } + + @Override + public C09PacketHeldItemChange convert() { + return new C09PacketHeldItemChange(this.slot); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C0A.java b/src/main/java/keystrokesmod/script/packet/serverbound/C0A.java index 3168c35..86c396f 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C0A.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C0A.java @@ -1,13 +1,13 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.play.client.C0APacketAnimation; - -public class C0A extends CPacket { - public C0A(C0APacketAnimation packet) { - super(packet); - } - - public C0A() { - super(new C0APacketAnimation()); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.play.client.C0APacketAnimation; + +public class C0A extends CPacket { + public C0A(C0APacketAnimation packet) { + super(packet); + } + + public C0A() { + super(new C0APacketAnimation()); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C0B.java b/src/main/java/keystrokesmod/script/packet/serverbound/C0B.java index a4c0eaf..e0d1a6e 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C0B.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C0B.java @@ -1,26 +1,26 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.network.play.client.C0BPacketEntityAction; - -public class C0B extends CPacket { - public String action; - public int horsePower; - - public C0B(String action, int horsePower) { - super(null); - this.action = action; - this.horsePower = horsePower; - } - public C0B(C0BPacketEntityAction packet) { - super(packet); - this.action = packet.getAction().name(); - this.horsePower = packet.getAuxData(); - } - - @Override - public C0BPacketEntityAction convert() { - return new C0BPacketEntityAction(Minecraft.getMinecraft().thePlayer, Utils.getEnum(C0BPacketEntityAction.Action.class, this.action), horsePower); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.network.play.client.C0BPacketEntityAction; + +public class C0B extends CPacket { + public String action; + public int horsePower; + + public C0B(String action, int horsePower) { + super(null); + this.action = action; + this.horsePower = horsePower; + } + public C0B(C0BPacketEntityAction packet) { + super(packet); + this.action = packet.getAction().name(); + this.horsePower = packet.getAuxData(); + } + + @Override + public C0BPacketEntityAction convert() { + return new C0BPacketEntityAction(Minecraft.getMinecraft().thePlayer, Utils.getEnum(C0BPacketEntityAction.Action.class, this.action), horsePower); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C0D.java b/src/main/java/keystrokesmod/script/packet/serverbound/C0D.java index bac9fdb..17d7960 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C0D.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C0D.java @@ -1,20 +1,20 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.play.client.C0DPacketCloseWindow; - -public class C0D extends CPacket { - public int windowId; - public C0D(int windowId) { - super(null); - this.windowId = windowId; - } - - public C0D(C0DPacketCloseWindow packet) { - super(packet); - } - - @Override - public C0DPacketCloseWindow convert() { - return new C0DPacketCloseWindow(this.windowId); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.play.client.C0DPacketCloseWindow; + +public class C0D extends CPacket { + public int windowId; + public C0D(int windowId) { + super(null); + this.windowId = windowId; + } + + public C0D(C0DPacketCloseWindow packet) { + super(packet); + } + + @Override + public C0DPacketCloseWindow convert() { + return new C0DPacketCloseWindow(this.windowId); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C0E.java b/src/main/java/keystrokesmod/script/packet/serverbound/C0E.java index b838109..5ac7fcd 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C0E.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C0E.java @@ -1,37 +1,37 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.ItemStack; -import net.minecraft.network.play.client.C0EPacketClickWindow; - -public class C0E extends CPacket { - public int windowId; - public int slot; - public int button; - public int mode; - public short action; - public ItemStack itemStack; - - public C0E(int windowId, int slot, int button, int mode, ItemStack itemStack) { - super(null); - this.windowId = windowId; - this.slot = slot; - this.button = button; - this.mode = mode; - this.itemStack = itemStack; - } - - public C0E(C0EPacketClickWindow packet) { - super(packet); - this.windowId = packet.getWindowId(); - this.slot = packet.getSlotId(); - this.button = packet.getUsedButton(); - this.mode = packet.getMode(); - this.action = packet.getActionNumber(); - this.itemStack = new ItemStack(packet.getClickedItem(), (byte) 0); - } - - @Override - public C0EPacketClickWindow convert() { - return new C0EPacketClickWindow(this.windowId, this.slot, this.button, this.mode, this.itemStack.itemStack, this.action); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.ItemStack; +import net.minecraft.network.play.client.C0EPacketClickWindow; + +public class C0E extends CPacket { + public int windowId; + public int slot; + public int button; + public int mode; + public short action; + public ItemStack itemStack; + + public C0E(int windowId, int slot, int button, int mode, ItemStack itemStack) { + super(null); + this.windowId = windowId; + this.slot = slot; + this.button = button; + this.mode = mode; + this.itemStack = itemStack; + } + + public C0E(C0EPacketClickWindow packet) { + super(packet); + this.windowId = packet.getWindowId(); + this.slot = packet.getSlotId(); + this.button = packet.getUsedButton(); + this.mode = packet.getMode(); + this.action = packet.getActionNumber(); + this.itemStack = new ItemStack(packet.getClickedItem(), (byte) 0); + } + + @Override + public C0EPacketClickWindow convert() { + return new C0EPacketClickWindow(this.windowId, this.slot, this.button, this.mode, this.itemStack.itemStack, this.action); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C0F.java b/src/main/java/keystrokesmod/script/packet/serverbound/C0F.java index eb6c642..fd8f505 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C0F.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C0F.java @@ -1,25 +1,25 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.play.client.C0FPacketConfirmTransaction; - -public class C0F extends CPacket { - public int windowId; - public short uid; - - public C0F(int windowId, short uid) { - super(null); - this.windowId = windowId; - this.uid = uid; - } - - public C0F(C0FPacketConfirmTransaction packet) { - super(packet); - this.windowId = packet.getWindowId(); - this.uid = packet.getUid(); - } - - @Override - public C0FPacketConfirmTransaction convert() { - return new C0FPacketConfirmTransaction(this.windowId, this.uid, true); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; + +public class C0F extends CPacket { + public int windowId; + public short uid; + + public C0F(int windowId, short uid) { + super(null); + this.windowId = windowId; + this.uid = uid; + } + + public C0F(C0FPacketConfirmTransaction packet) { + super(packet); + this.windowId = packet.getWindowId(); + this.uid = packet.getUid(); + } + + @Override + public C0FPacketConfirmTransaction convert() { + return new C0FPacketConfirmTransaction(this.windowId, this.uid, true); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C10.java b/src/main/java/keystrokesmod/script/packet/serverbound/C10.java index 3396a85..eb24cbb 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C10.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C10.java @@ -1,26 +1,26 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.model.ItemStack; -import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; - -public class C10 extends CPacket { - public int slot; - public ItemStack itemStack; - - public C10(int slot, ItemStack itemStack) { - super(null); - this.slot = slot; - this.itemStack = itemStack; - } - - public C10(C10PacketCreativeInventoryAction packet) { - super(packet); - this.slot = packet.getSlotId(); - this.itemStack = ItemStack.convert(packet.getStack()); - } - - @Override - public C10PacketCreativeInventoryAction convert() { - return new C10PacketCreativeInventoryAction(slot, itemStack.itemStack); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.model.ItemStack; +import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; + +public class C10 extends CPacket { + public int slot; + public ItemStack itemStack; + + public C10(int slot, ItemStack itemStack) { + super(null); + this.slot = slot; + this.itemStack = itemStack; + } + + public C10(C10PacketCreativeInventoryAction packet) { + super(packet); + this.slot = packet.getSlotId(); + this.itemStack = ItemStack.convert(packet.getStack()); + } + + @Override + public C10PacketCreativeInventoryAction convert() { + return new C10PacketCreativeInventoryAction(slot, itemStack.itemStack); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C13.java b/src/main/java/keystrokesmod/script/packet/serverbound/C13.java index 2f87c86..8c12585 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C13.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C13.java @@ -1,39 +1,39 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.entity.player.PlayerCapabilities; -import net.minecraft.network.play.client.C13PacketPlayerAbilities; - -public class C13 extends CPacket { - public boolean invulnerable; - public boolean flying; - public boolean allowFlying; - public boolean creativeMode; - public float flySpeed; - public float walkSpeed; - - public C13(boolean invulnerable, boolean flying, boolean allowFlying, boolean creativeMode, float flySpeed, float walkSpeed) { - super(null); - this.invulnerable = invulnerable; - this.flying = flying; - this.allowFlying = allowFlying; - this.creativeMode = creativeMode; - this.flySpeed = flySpeed; - this.walkSpeed = walkSpeed; - } - - public C13(C13PacketPlayerAbilities packet) { - super(packet); - } - - @Override - public C13PacketPlayerAbilities convert() { - PlayerCapabilities capabilities = new PlayerCapabilities(); - capabilities.disableDamage = this.invulnerable; - capabilities.isFlying = this.flying; - capabilities.allowFlying = this.allowFlying; - capabilities.isCreativeMode = this.creativeMode; - capabilities.setFlySpeed(this.flySpeed); - capabilities.setPlayerWalkSpeed(this.walkSpeed); - return new C13PacketPlayerAbilities(capabilities); - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; + +public class C13 extends CPacket { + public boolean invulnerable; + public boolean flying; + public boolean allowFlying; + public boolean creativeMode; + public float flySpeed; + public float walkSpeed; + + public C13(boolean invulnerable, boolean flying, boolean allowFlying, boolean creativeMode, float flySpeed, float walkSpeed) { + super(null); + this.invulnerable = invulnerable; + this.flying = flying; + this.allowFlying = allowFlying; + this.creativeMode = creativeMode; + this.flySpeed = flySpeed; + this.walkSpeed = walkSpeed; + } + + public C13(C13PacketPlayerAbilities packet) { + super(packet); + } + + @Override + public C13PacketPlayerAbilities convert() { + PlayerCapabilities capabilities = new PlayerCapabilities(); + capabilities.disableDamage = this.invulnerable; + capabilities.isFlying = this.flying; + capabilities.allowFlying = this.allowFlying; + capabilities.isCreativeMode = this.creativeMode; + capabilities.setFlySpeed(this.flySpeed); + capabilities.setPlayerWalkSpeed(this.walkSpeed); + return new C13PacketPlayerAbilities(capabilities); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/C16.java b/src/main/java/keystrokesmod/script/packet/serverbound/C16.java index 8b245a3..f7fb204 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/C16.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/C16.java @@ -1,23 +1,23 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.utility.Utils; -import net.minecraft.network.play.client.C16PacketClientStatus; - -public class C16 extends CPacket { - public String status; - - public C16(String status) { - super(null); - this.status = status; - } - - public C16(C16PacketClientStatus packet) { - super(packet); - this.status = packet.getStatus().name(); - } - - @Override - public C16PacketClientStatus convert() { - return new C16PacketClientStatus(Utils.getEnum(C16PacketClientStatus.EnumState.class, this.status)); - } -} +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.utility.Utils; +import net.minecraft.network.play.client.C16PacketClientStatus; + +public class C16 extends CPacket { + public String status; + + public C16(String status) { + super(null); + this.status = status; + } + + public C16(C16PacketClientStatus packet) { + super(packet); + this.status = packet.getStatus().name(); + } + + @Override + public C16PacketClientStatus convert() { + return new C16PacketClientStatus(Utils.getEnum(C16PacketClientStatus.EnumState.class, this.status)); + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/CPacket.java b/src/main/java/keystrokesmod/script/packet/serverbound/CPacket.java index 56aac8d..c5ebc8b 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/CPacket.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/CPacket.java @@ -1,20 +1,20 @@ -package keystrokesmod.script.packet.serverbound; - -import net.minecraft.network.Packet; - -public class CPacket { - public String name; - public net.minecraft.network.Packet packet; - - public CPacket(net.minecraft.network.Packet packet) { - if (packet == null) { - return; - } - this.packet = packet; - this.name = packet.getClass().getSimpleName(); - } - - public Packet convert() { - return packet; - } -} +package keystrokesmod.script.packet.serverbound; + +import net.minecraft.network.Packet; + +public class CPacket { + public String name; + public net.minecraft.network.Packet packet; + + public CPacket(net.minecraft.network.Packet packet) { + if (packet == null) { + return; + } + this.packet = packet; + this.name = packet.getClass().getSimpleName(); + } + + public Packet convert() { + return packet; + } +} diff --git a/src/main/java/keystrokesmod/script/packet/serverbound/PacketHandler.java b/src/main/java/keystrokesmod/script/packet/serverbound/PacketHandler.java index 155b7e5..b54a7bf 100644 --- a/src/main/java/keystrokesmod/script/packet/serverbound/PacketHandler.java +++ b/src/main/java/keystrokesmod/script/packet/serverbound/PacketHandler.java @@ -1,124 +1,124 @@ -package keystrokesmod.script.packet.serverbound; - -import keystrokesmod.script.packet.PacketMappings; -import keystrokesmod.script.packet.clientbound.*; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.*; - -public class PacketHandler { - public static CPacket convertServerBound(net.minecraft.network.Packet packet) { - if (packet == null || packet.getClass().getSimpleName().startsWith("S")) { - return null; - } - Class asClass = PacketMappings.minecraftToScriptC.get(packet.getClass()); - CPacket newPacket; - if (asClass != null) { - if (packet instanceof C03PacketPlayer) { - newPacket = new C03((C03PacketPlayer)packet, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0); - } - else if (packet instanceof C01PacketChatMessage) { - newPacket = new C01((C01PacketChatMessage)packet, (byte) 0); - } - else if (packet instanceof C09PacketHeldItemChange) { - newPacket = new C09(((C09PacketHeldItemChange)packet), true); - } - else { - try { - newPacket = asClass.getConstructor(packet.getClass()).newInstance(packet); - } - catch (Exception e) { - newPacket = new CPacket(packet); - } - } - } - else { - newPacket = new CPacket(packet); - } - return newPacket; - } - - public static SPacket convertClientBound(Packet packet) { - Class asClass = PacketMappings.minecraftToScriptS.get(packet.getClass()); - SPacket newPacket; - if (asClass != null) { - if (packet instanceof S3APacketTabComplete) { - newPacket = new S3A((S3APacketTabComplete) packet, (byte) 0); - } - else if (packet instanceof S23PacketBlockChange) { - newPacket = new S23((S23PacketBlockChange) packet, (byte) 0); - } - else { - try { - newPacket = asClass.getConstructor(packet.getClass()).newInstance(packet); - } - catch (Exception e) { - newPacket = new SPacket(packet); - } - } - } - else { - newPacket = new SPacket(packet); - } - return newPacket; - } - - public static Packet convertCPacket(CPacket cPacket) { - try { - if (cPacket instanceof C0A) { - return new C0APacketAnimation(); - } - else if (cPacket instanceof C0B) { - return ((C0B) cPacket).convert(); - } - else if (cPacket instanceof C0D) { - return ((C0D) cPacket).convert(); - } - else if (cPacket instanceof C09) { - return ((C09) cPacket).convert(); - } - else if (cPacket instanceof C0E) { - return ((C0E) cPacket).convert(); - } - else if (cPacket instanceof C0F) { - return ((C0F) cPacket).convert(); - } - else if (cPacket instanceof C08) { - return ((C08) cPacket).convert(); - } - else if (cPacket instanceof C07) { - return ((C07) cPacket).convert(); - } - else if (cPacket instanceof C01) { - return ((C01) cPacket).convert(); - } - else if (cPacket instanceof C02) { - return ((C02) cPacket).convert(); - } - else if (cPacket instanceof C03) { - return cPacket.packet; - } - else if (cPacket instanceof C10) { - return ((C10) cPacket).convert(); - } - else if (cPacket instanceof C13) { - return ((C13) cPacket).convert(); - } - else if (cPacket instanceof C16) { - return ((C16) cPacket).convert(); - } - } - catch (Exception e) { - if (cPacket != null && cPacket.packet != null && !cPacket.name.startsWith("S")) { - return cPacket.packet; - } - else { - return null; - } - } - if (cPacket == null && cPacket.packet == null) { - return null; - } - return cPacket.packet; - } +package keystrokesmod.script.packet.serverbound; + +import keystrokesmod.script.packet.PacketMappings; +import keystrokesmod.script.packet.clientbound.*; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.*; + +public class PacketHandler { + public static CPacket convertServerBound(net.minecraft.network.Packet packet) { + if (packet == null || packet.getClass().getSimpleName().startsWith("S")) { + return null; + } + Class asClass = PacketMappings.minecraftToScriptC.get(packet.getClass()); + CPacket newPacket; + if (asClass != null) { + if (packet instanceof C03PacketPlayer) { + newPacket = new C03((C03PacketPlayer)packet, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0); + } + else if (packet instanceof C01PacketChatMessage) { + newPacket = new C01((C01PacketChatMessage)packet, (byte) 0); + } + else if (packet instanceof C09PacketHeldItemChange) { + newPacket = new C09(((C09PacketHeldItemChange)packet), true); + } + else { + try { + newPacket = asClass.getConstructor(packet.getClass()).newInstance(packet); + } + catch (Exception e) { + newPacket = new CPacket(packet); + } + } + } + else { + newPacket = new CPacket(packet); + } + return newPacket; + } + + public static SPacket convertClientBound(Packet packet) { + Class asClass = PacketMappings.minecraftToScriptS.get(packet.getClass()); + SPacket newPacket; + if (asClass != null) { + if (packet instanceof S3APacketTabComplete) { + newPacket = new S3A((S3APacketTabComplete) packet, (byte) 0); + } + else if (packet instanceof S23PacketBlockChange) { + newPacket = new S23((S23PacketBlockChange) packet, (byte) 0); + } + else { + try { + newPacket = asClass.getConstructor(packet.getClass()).newInstance(packet); + } + catch (Exception e) { + newPacket = new SPacket(packet); + } + } + } + else { + newPacket = new SPacket(packet); + } + return newPacket; + } + + public static Packet convertCPacket(CPacket cPacket) { + try { + if (cPacket instanceof C0A) { + return new C0APacketAnimation(); + } + else if (cPacket instanceof C0B) { + return ((C0B) cPacket).convert(); + } + else if (cPacket instanceof C0D) { + return ((C0D) cPacket).convert(); + } + else if (cPacket instanceof C09) { + return ((C09) cPacket).convert(); + } + else if (cPacket instanceof C0E) { + return ((C0E) cPacket).convert(); + } + else if (cPacket instanceof C0F) { + return ((C0F) cPacket).convert(); + } + else if (cPacket instanceof C08) { + return ((C08) cPacket).convert(); + } + else if (cPacket instanceof C07) { + return ((C07) cPacket).convert(); + } + else if (cPacket instanceof C01) { + return ((C01) cPacket).convert(); + } + else if (cPacket instanceof C02) { + return ((C02) cPacket).convert(); + } + else if (cPacket instanceof C03) { + return cPacket.packet; + } + else if (cPacket instanceof C10) { + return ((C10) cPacket).convert(); + } + else if (cPacket instanceof C13) { + return ((C13) cPacket).convert(); + } + else if (cPacket instanceof C16) { + return ((C16) cPacket).convert(); + } + } + catch (Exception e) { + if (cPacket != null && cPacket.packet != null && !cPacket.name.startsWith("S")) { + return cPacket.packet; + } + else { + return null; + } + } + if (cPacket == null && cPacket.packet == null) { + return null; + } + return cPacket.packet; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/BlinkHandler.java b/src/main/java/keystrokesmod/utility/BlinkHandler.java new file mode 100644 index 0000000..a295acf --- /dev/null +++ b/src/main/java/keystrokesmod/utility/BlinkHandler.java @@ -0,0 +1,234 @@ +package keystrokesmod.utility; + +import keystrokesmod.Raven; +import keystrokesmod.event.*; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.module.impl.movement.NoSlow; +import keystrokesmod.module.impl.render.HUD; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.network.Packet; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.Timer; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentSkipListMap; + +public class BlinkHandler { + private final Minecraft mc; + + public BlinkHandler(Minecraft mc) { + this.mc = mc; + } + + private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); + private boolean active; + public static int blinkTicks; + private int color = new Color(0, 187, 255, 255).getRGB(); + private Vec3 bPos; + + public static boolean blinkModule() { + if (ModuleManager.antiVoid != null && ModuleManager.antiVoid.isEnabled() && ModuleManager.antiVoid.blink) { + return true; + } + if (ModuleManager.blink != null && ModuleManager.blink.isEnabled() && ModuleManager.blink.blink) { + return true; + } + if (ModuleManager.noFall != null && ModuleManager.noFall.isEnabled() && ModuleManager.noFall.mode.getInput() == 6 && ModuleManager.noFall.blink) { + return true; + } + if (ModuleManager.noSlow != null && ModuleManager.noSlow.isEnabled() && NoSlow.mode.getInput() == 5 && ModuleManager.noSlow.blink) { + return true; + } + if (ModuleManager.killAura != null && ModuleManager.killAura.isEnabled() && ModuleManager.killAura.blink) { + return true; + } + if (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && ModuleManager.scaffold.blink) { + return true; + } + if (ModuleManager.tower != null && ModuleManager.tower.canTower() && ModuleManager.tower.blink) { + return true; + } + if (ModuleManager.velocity != null && ModuleManager.velocity.isEnabled() && ModuleManager.velocity.blink) { + return true; + } + if (ModuleManager.lagRange != null && ModuleManager.lagRange.isEnabled() && ModuleManager.lagRange.blink) { + return true; + } + return false; + } + + private boolean renderTimer() { + if (ModuleManager.antiVoid != null && ModuleManager.antiVoid.isEnabled() && ModuleManager.antiVoid.blink && ModuleManager.antiVoid.renderTimer.isToggled()) { + return true; + } + if (ModuleManager.blink != null && ModuleManager.blink.isEnabled() && ModuleManager.blink.blink && ModuleManager.blink.renderTimer.isToggled()) { + return true; + } + if (ModuleManager.noFall != null && ModuleManager.noFall.isEnabled() && ModuleManager.noFall.blink && ModuleManager.noFall.mode.getInput() == 6 && ModuleManager.noFall.renderTimer.isToggled()) { + return true; + } + if (ModuleManager.noSlow != null && ModuleManager.noSlow.isEnabled() && ModuleManager.noSlow.blink && NoSlow.mode.getInput() == 5 && ModuleManager.noSlow.renderTimer.isToggled()) { + return true; + } + return false; + } + + private boolean renderBox() { + if (ModuleManager.blink != null && ModuleManager.blink.isEnabled() && ModuleManager.blink.blink && ModuleManager.blink.initialPosition.isToggled()) { + return true; + } + if (ModuleManager.lagRange != null && ModuleManager.lagRange.isEnabled() && ModuleManager.lagRange.blink && ModuleManager.lagRange.initialPosition.isToggled()) { + return true; + } + return false; + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.entity == mc.thePlayer) { + release(); + } + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (!renderBox()) { + bPos = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); + } + + if (active) { + blinkTicks++; + } + + if (!active || blinkModule()) { + return; + } + release(); + } + + private void release() { + if (blinkedPackets.isEmpty()) { + return; + } + if (ModuleManager.antiVoid.setPos) { + PacketUtils.sendPacketNoEvent(new C03PacketPlayer.C06PacketPlayerPosLook(mc.thePlayer.posX, -0.55, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, mc.thePlayer.onGround)); + ModuleManager.antiVoid.setPos = false; + } + synchronized (blinkedPackets) { + for (Packet packet : blinkedPackets) { + Raven.packetsHandler.handlePacket(packet); + PacketUtils.sendPacketNoEvent(packet); + } + } + blinkedPackets.clear(); + blinkTicks = 0; + active = false; + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck() || mc.isSingleplayer() || e.isCanceled() || e.getPacket().getClass().getSimpleName().startsWith("S") || e.getPacket() instanceof C00PacketLoginStart || e.getPacket() instanceof C00Handshake) { + return; + } + if (blinkModule()) { + active = true; + } + if (active) { + blinkedPackets.add(e.getPacket()); + e.setCanceled(true); + } + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (!Utils.nullCheck() || blinkTicks == 0 || !renderTimer() || !blinkModule()) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + } + ticksTimer(blinkTicks); + } + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent e) { + if (!Utils.nullCheck() || bPos == null || !renderBox() || !blinkModule()) { + return; + } + drawBox(bPos); + } + + private void ticksTimer(int ticks) { + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + int widthOffset = (ticks < 10) ? 4 : (ticks >= 10 && ticks < 100) ? 7 : (ticks >= 100 && ticks < 1000) ? 10 : (ticks >= 1000) ? 13 : 16; + String text = ("" + ticks); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + } + + private void secondsTimer(int ticks) { + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + ticks = ticks / 20; + int widthOffset = (ticks < 10) ? 4 : (ticks >= 10 && ticks < 100) ? 7 : (ticks >= 100 && ticks < 1000) ? 10 : (ticks >= 1000) ? 13 : 16; + String text = (ticks + "s"); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + } + + private void drawBox(Vec3 pos) { + GlStateManager.pushMatrix(); + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + double x = pos.xCoord - mc.getRenderManager().viewerPosX; + double y = pos.yCoord - mc.getRenderManager().viewerPosY; + double z = pos.zCoord - mc.getRenderManager().viewerPosZ; + AxisAlignedBB bbox = mc.thePlayer.getEntityBoundingBox().expand(0.1D, 0.1, 0.1); + AxisAlignedBB axis = new AxisAlignedBB(bbox.minX - mc.thePlayer.posX + x, bbox.minY - mc.thePlayer.posY + y, bbox.minZ - mc.thePlayer.posZ + z, bbox.maxX - mc.thePlayer.posX + x, bbox.maxY - mc.thePlayer.posY + y, bbox.maxZ - mc.thePlayer.posZ + z); + float a = (float) (color >> 24 & 255) / 255.0F; + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; + GL11.glBlendFunc(770, 771); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glLineWidth(2.0F); + GL11.glColor4f(r, g, b, a); + RenderUtils.drawBoundingBox(axis, r, g, b); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GlStateManager.popMatrix(); + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/BlockUtils.java b/src/main/java/keystrokesmod/utility/BlockUtils.java index c6fa6c7..38fdf83 100644 --- a/src/main/java/keystrokesmod/utility/BlockUtils.java +++ b/src/main/java/keystrokesmod/utility/BlockUtils.java @@ -1,179 +1,179 @@ -package keystrokesmod.utility; - -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.init.Blocks; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; - -public class BlockUtils { - public static final Minecraft mc = Minecraft.getMinecraft(); - - public static boolean isSamePos(BlockPos blockPos, BlockPos blockPos2) { - return blockPos == blockPos2 || (blockPos.getX() == blockPos2.getX() && blockPos.getY() == blockPos2.getY() && blockPos.getZ() == blockPos2.getZ()); - } - - public static boolean notFull(Block block) { - return block instanceof BlockFenceGate || block instanceof BlockLadder || block instanceof BlockFlowerPot || block instanceof BlockBasePressurePlate || isFluid(block) || block instanceof BlockFence || block instanceof BlockAnvil || block instanceof BlockEnchantmentTable || block instanceof BlockChest; - } - - public static boolean isNormalBlock(final Block block) { - return block == Blocks.glass || (block.isFullBlock() && block != Blocks.gravel && block != Blocks.sand && block != Blocks.soul_sand && block != Blocks.tnt && block != Blocks.crafting_table && block != Blocks.furnace && block != Blocks.dispenser && block != Blocks.dropper && block != Blocks.noteblock && block != Blocks.command_block); - } - - - public static BlockPos pos(final double x, final double y, final double z) { - return new BlockPos(x, y, z); - } - - public static boolean isBlockPosEqual(final BlockPos pos1, final BlockPos pos2) { - return pos1 == pos2 || (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY() && pos1.getZ() == pos2.getZ()); - } - - public static BlockPos offsetPos(MovingObjectPosition mop) { - return mop.getBlockPos().offset(mop.sideHit); - } - - public static boolean isFluid(Block block) { - return block.getMaterial() == Material.lava || block.getMaterial() == Material.water; - } - - public static boolean isInteractable(Block block) { - return block instanceof BlockFurnace || block instanceof BlockTrapDoor || block instanceof BlockDoor || block instanceof BlockContainer || block instanceof BlockJukebox || block instanceof BlockFenceGate || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockEnchantmentTable || block instanceof BlockBrewingStand || block instanceof BlockBed || block instanceof BlockDropper || block instanceof BlockDispenser || block instanceof BlockHopper || block instanceof BlockAnvil || block instanceof BlockNote || block instanceof BlockWorkbench; - } - - public static boolean isInteractable(MovingObjectPosition mv) { - if (mv == null || mv.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mv.getBlockPos() == null) { - return false; - } - if (!mc.thePlayer.isSneaking() || mc.thePlayer.getHeldItem() == null) { - return isInteractable(BlockUtils.getBlock(mv.getBlockPos())); - } - return false; - } - - public static float getBlockHardness(final Block block, final ItemStack itemStack, boolean ignoreSlow, boolean ignoreGround) { - final float getBlockHardness = block.getBlockHardness(mc.theWorld, null); - if (getBlockHardness < 0.0f) { - return 0.0f; - } - return (block.getMaterial().isToolNotRequired() || (itemStack != null && itemStack.canHarvestBlock(block))) ? (getToolDigEfficiency(itemStack, block, ignoreSlow, ignoreGround) / getBlockHardness / 30.0f) : (getToolDigEfficiency(itemStack, block, ignoreSlow, ignoreGround) / getBlockHardness / 100.0f); - } - - public static float getToolDigEfficiency(ItemStack itemStack, Block block, boolean ignoreSlow, boolean ignoreGround) { - float n = (itemStack == null) ? 1.0f : itemStack.getItem().getStrVsBlock(itemStack, block); - if (n > 1.0f) { - final int getEnchantmentLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, itemStack); - if (getEnchantmentLevel > 0 && itemStack != null) { - n += getEnchantmentLevel * getEnchantmentLevel + 1; - } - } - if (mc.thePlayer.isPotionActive(Potion.digSpeed)) { - n *= 1.0f + (mc.thePlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2f; - } - if (!ignoreSlow) { - if (mc.thePlayer.isPotionActive(Potion.digSlowdown)) { - float n2; - switch (mc.thePlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) { - case 0: { - n2 = 0.3f; - break; - } - case 1: { - n2 = 0.09f; - break; - } - case 2: { - n2 = 0.0027f; - break; - } - default: { - n2 = 8.1E-4f; - break; - } - } - n *= n2; - } - if (mc.thePlayer.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(mc.thePlayer)) { - n /= 5.0f; - } - if (!mc.thePlayer.onGround && !ignoreGround) { - n /= 5.0f; - } - } - return n; - } - - public static Block getBlock(BlockPos blockPos) { - return getBlockState(blockPos).getBlock(); - } - - public static Block getBlock(double x, double y, double z) { - return getBlockState(new BlockPos(x, y, z)).getBlock(); - } - - public static IBlockState getBlockState(BlockPos blockPos) { - return mc.theWorld.getBlockState(blockPos); - } - - public static boolean check(final BlockPos blockPos, final Block block) { - return getBlock(blockPos) == block; - } - - public static boolean replaceable(BlockPos blockPos) { - if (!Utils.nullCheck()) { - return true; - } - return getBlock(blockPos).isReplaceable(mc.theWorld, blockPos); - } - - public static boolean canSeeVecBlock(final BlockPos pos, final Vec3 vecPlayer, final Vec3 vecBlockPoint) { - final MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(vecPlayer, vecBlockPoint, false, false, false); - if (mop == null) { - return true; - } - if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - final BlockPos mopPos = mop.getBlockPos(); - if (mopPos.getX() == pos.getX() && mopPos.getY() == pos.getY() && mopPos.getZ() == pos.getZ()) { - return true; - } - } - return false; - } - - public static boolean canBlockBeSeen(final BlockPos pos) { - final Vec3 vecPlayer = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.getEyeHeight(), mc.thePlayer.posZ); - for (double offsetY = 0.0; offsetY <= 0.5; offsetY += 0.5) { - final double y = pos.getY() + offsetY; - Vec3 vecBlockPoint = new Vec3(pos.getX() + 1, y, pos.getZ() + 0.5); - if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { - return true; - } - vecBlockPoint = new Vec3(pos.getX(), y, pos.getZ() + 0.5); - if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { - return true; - } - vecBlockPoint = new Vec3(pos.getX() + 0.5, y, (double)(pos.getZ() + 1)); - if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { - return true; - } - vecBlockPoint = new Vec3(pos.getX() + 0.5, y, (double)pos.getZ()); - if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { - return true; - } - } - return false; - } - - public static EnumDyeColor getWoolColor(final IBlockState state) { - return (EnumDyeColor)state.getProperties().get(BlockColored.COLOR); - } -} +package keystrokesmod.utility; + +import net.minecraft.block.*; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; + +public class BlockUtils { + public static final Minecraft mc = Minecraft.getMinecraft(); + + public static boolean isSamePos(BlockPos blockPos, BlockPos blockPos2) { + return blockPos == blockPos2 || (blockPos.getX() == blockPos2.getX() && blockPos.getY() == blockPos2.getY() && blockPos.getZ() == blockPos2.getZ()); + } + + public static boolean notFull(Block block) { + return block instanceof BlockFenceGate || block instanceof BlockLadder || block instanceof BlockFlowerPot || block instanceof BlockBasePressurePlate || isFluid(block) || block instanceof BlockFence || block instanceof BlockAnvil || block instanceof BlockEnchantmentTable || block instanceof BlockChest; + } + + public static boolean isNormalBlock(final Block block) { + return block == Blocks.glass || (block.isFullBlock() && block != Blocks.gravel && block != Blocks.sand && block != Blocks.soul_sand && block != Blocks.tnt && block != Blocks.crafting_table && block != Blocks.furnace && block != Blocks.dispenser && block != Blocks.dropper && block != Blocks.noteblock && block != Blocks.command_block); + } + + + public static BlockPos pos(final double x, final double y, final double z) { + return new BlockPos(x, y, z); + } + + public static boolean isBlockPosEqual(final BlockPos pos1, final BlockPos pos2) { + return pos1 == pos2 || (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY() && pos1.getZ() == pos2.getZ()); + } + + public static BlockPos offsetPos(MovingObjectPosition mop) { + return mop.getBlockPos().offset(mop.sideHit); + } + + public static boolean isFluid(Block block) { + return block.getMaterial() == Material.lava || block.getMaterial() == Material.water; + } + + public static boolean isInteractable(Block block) { + return block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockTrapDoor || block instanceof BlockDoor || block instanceof BlockContainer || block instanceof BlockJukebox || block instanceof BlockFenceGate || block instanceof BlockEnchantmentTable || block instanceof BlockBrewingStand || block instanceof BlockBed || block instanceof BlockDropper || block instanceof BlockDispenser || block instanceof BlockHopper || block instanceof BlockAnvil || block instanceof BlockNote || block instanceof BlockWorkbench; + } + + public static boolean isInteractable(MovingObjectPosition mv) { + if (mv == null || mv.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || mv.getBlockPos() == null) { + return false; + } + if (!mc.thePlayer.isSneaking() || mc.thePlayer.getHeldItem() == null) { + return isInteractable(BlockUtils.getBlock(mv.getBlockPos())); + } + return false; + } + + public static float getBlockHardness(final Block block, final ItemStack itemStack, boolean ignoreSlow, boolean ignoreGround) { + final float getBlockHardness = block.getBlockHardness(mc.theWorld, null); + if (getBlockHardness < 0.0f) { + return 0.0f; + } + return (block.getMaterial().isToolNotRequired() || (itemStack != null && itemStack.canHarvestBlock(block))) ? (getToolDigEfficiency(itemStack, block, ignoreSlow, ignoreGround) / getBlockHardness / 30.0f) : (getToolDigEfficiency(itemStack, block, ignoreSlow, ignoreGround) / getBlockHardness / 100.0f); + } + + public static float getToolDigEfficiency(ItemStack itemStack, Block block, boolean ignoreSlow, boolean ignoreGround) { + float n = (itemStack == null) ? 1.0f : itemStack.getItem().getStrVsBlock(itemStack, block); + if (n > 1.0f) { + final int getEnchantmentLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, itemStack); + if (getEnchantmentLevel > 0 && itemStack != null) { + n += getEnchantmentLevel * getEnchantmentLevel + 1; + } + } + if (mc.thePlayer.isPotionActive(Potion.digSpeed)) { + n *= 1.0f + (mc.thePlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2f; + } + if (!ignoreSlow) { + if (mc.thePlayer.isPotionActive(Potion.digSlowdown)) { + float n2; + switch (mc.thePlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) { + case 0: { + n2 = 0.3f; + break; + } + case 1: { + n2 = 0.09f; + break; + } + case 2: { + n2 = 0.0027f; + break; + } + default: { + n2 = 8.1E-4f; + break; + } + } + n *= n2; + } + if (mc.thePlayer.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(mc.thePlayer)) { + n /= 5.0f; + } + if (!mc.thePlayer.onGround && !ignoreGround) { + n /= 5.0f; + } + } + return n; + } + + public static Block getBlock(BlockPos blockPos) { + return getBlockState(blockPos).getBlock(); + } + + public static Block getBlock(double x, double y, double z) { + return getBlockState(new BlockPos(x, y, z)).getBlock(); + } + + public static IBlockState getBlockState(BlockPos blockPos) { + return mc.theWorld.getBlockState(blockPos); + } + + public static boolean check(final BlockPos blockPos, final Block block) { + return getBlock(blockPos) == block; + } + + public static boolean replaceable(BlockPos blockPos) { + if (!Utils.nullCheck()) { + return true; + } + return getBlock(blockPos).isReplaceable(mc.theWorld, blockPos); + } + + public static boolean canSeeVecBlock(final BlockPos pos, final Vec3 vecPlayer, final Vec3 vecBlockPoint) { + final MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(vecPlayer, vecBlockPoint, false, false, false); + if (mop == null) { + return true; + } + if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + final BlockPos mopPos = mop.getBlockPos(); + if (mopPos.getX() == pos.getX() && mopPos.getY() == pos.getY() && mopPos.getZ() == pos.getZ()) { + return true; + } + } + return false; + } + + public static boolean canBlockBeSeen(final BlockPos pos) { + final Vec3 vecPlayer = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.getEyeHeight(), mc.thePlayer.posZ); + for (double offsetY = 0.0; offsetY <= 0.5; offsetY += 0.5) { + final double y = pos.getY() + offsetY; + Vec3 vecBlockPoint = new Vec3(pos.getX() + 1, y, pos.getZ() + 0.5); + if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { + return true; + } + vecBlockPoint = new Vec3(pos.getX(), y, pos.getZ() + 0.5); + if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { + return true; + } + vecBlockPoint = new Vec3(pos.getX() + 0.5, y, (double)(pos.getZ() + 1)); + if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { + return true; + } + vecBlockPoint = new Vec3(pos.getX() + 0.5, y, (double)pos.getZ()); + if (canSeeVecBlock(pos, vecPlayer, vecBlockPoint)) { + return true; + } + } + return false; + } + + public static EnumDyeColor getWoolColor(final IBlockState state) { + return (EnumDyeColor)state.getProperties().get(BlockColored.COLOR); + } +} diff --git a/src/main/java/keystrokesmod/utility/KnockBackHelper.java b/src/main/java/keystrokesmod/utility/KnockBackHelper.java index 3843990..01e78da 100644 --- a/src/main/java/keystrokesmod/utility/KnockBackHelper.java +++ b/src/main/java/keystrokesmod/utility/KnockBackHelper.java @@ -1,80 +1,80 @@ -package keystrokesmod.utility; - -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.RunGameLoopEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.ArrayDeque; -import java.util.Queue; - -public class KnockBackHelper { - - private final Minecraft mc = Minecraft.getMinecraft(); - - private final Queue packets = new ArrayDeque<>(); - - private boolean cancel = false; - - private boolean releasePackets = false; - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onReceivePacket(ReceivePacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (e.getPacket() instanceof S12PacketEntityVelocity || e.getPacket() instanceof S27PacketExplosion) { - if (e.getPacket() instanceof S12PacketEntityVelocity && - ((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId() && - cancel) - { - this.packets.add(e.getPacket()); - e.setCanceled(true); - } - else if (e.getPacket() instanceof S27PacketExplosion && cancel) { - this.packets.add(e.getPacket()); - e.setCanceled(true); - } - } - } - - @SubscribeEvent - public void onGameLoop(RunGameLoopEvent e) { - if (!Utils.nullCheck() || !this.releasePackets) { - return; - } - while (!this.packets.isEmpty()) { - Packet p = this.packets.poll(); - if (p != null) p.processPacket(mc.getNetHandler()); - } - this.releasePackets = false; - } - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - this.packets.clear(); // Clears the buffered packets when you join a new world. - } - } - - /** - * Starts capturing packets, buffering them until {@link #releasePackets()} is called. - */ - public void capturePackets() { - this.cancel = true; - } - - /** - * Releases the buffered packets and sends them to your client. - */ - public void releasePackets() { - this.cancel = false; - this.releasePackets = true; - } - +package keystrokesmod.utility; + +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.RunGameLoopEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.ArrayDeque; +import java.util.Queue; + +public class KnockBackHelper { + + private final Minecraft mc = Minecraft.getMinecraft(); + + private final Queue packets = new ArrayDeque<>(); + + private boolean cancel = false; + + private boolean releasePackets = false; + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onReceivePacket(ReceivePacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.getPacket() instanceof S12PacketEntityVelocity || e.getPacket() instanceof S27PacketExplosion) { + if (e.getPacket() instanceof S12PacketEntityVelocity && + ((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId() && + cancel) + { + this.packets.add(e.getPacket()); + e.setCanceled(true); + } + else if (e.getPacket() instanceof S27PacketExplosion && cancel) { + this.packets.add(e.getPacket()); + e.setCanceled(true); + } + } + } + + @SubscribeEvent + public void onGameLoop(RunGameLoopEvent e) { + if (!Utils.nullCheck() || !this.releasePackets) { + return; + } + while (!this.packets.isEmpty()) { + Packet p = this.packets.poll(); + if (p != null) p.processPacket(mc.getNetHandler()); + } + this.releasePackets = false; + } + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (e.entity == mc.thePlayer) { + this.packets.clear(); // Clears the buffered packets when you join a new world. + } + } + + /** + * Starts capturing packets, buffering them until {@link #releasePackets()} is called. + */ + public void capturePackets() { + this.cancel = true; + } + + /** + * Releases the buffered packets and sends them to your client. + */ + public void releasePackets() { + this.cancel = false; + this.releasePackets = true; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/ModuleUtils.java b/src/main/java/keystrokesmod/utility/ModuleUtils.java index 509ca8c..60fead9 100644 --- a/src/main/java/keystrokesmod/utility/ModuleUtils.java +++ b/src/main/java/keystrokesmod/utility/ModuleUtils.java @@ -1,560 +1,663 @@ -package keystrokesmod.utility; - -import keystrokesmod.event.*; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.combat.Velocity; -import keystrokesmod.module.impl.movement.Bhop; -import keystrokesmod.module.impl.movement.LongJump; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.utility.command.CommandManager; -import net.minecraft.block.*; -import net.minecraft.client.Minecraft; -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.S12PacketEntityVelocity; -import net.minecraft.network.play.server.S27PacketExplosion; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.Iterator; -import java.util.Map; -import java.util.Objects; - -public class ModuleUtils { - private final Minecraft mc; - - public ModuleUtils(Minecraft mc) { - this.mc = mc; - } - - public static boolean isBreaking; - public static boolean threwFireball, threwFireballLow; - public static long MAX_EXPLOSION_DIST_SQ = 10; - private long FIREBALL_TIMEOUT = 500L, fireballTime = 0; - public static int inAirTicks, groundTicks, stillTicks; - public static int fadeEdge; - public static double offsetValue = 0.00100012; - public static boolean isAttacking; - private int attackingTicks; - public static int unTargetTicks; - public static int profileTicks = -1, swapTick; - public static int lastY, thisY; - public static boolean lastTickOnGround, lastTickPos1, lastYDif; - private boolean thisTickOnGround, thisTickPos1; - public static boolean firstDamage; - private int ft; - - public static boolean isBlocked; - - public static boolean damage; - private int damageTicks; - private boolean lowhopAir; - - private int edgeTick; - - private boolean dontCheckFD; - - public static boolean canSlow, didSlow, setSlow, hasSlowed; - private static boolean allowFriction; - - private float yaw; - - private boolean ldmg; - - @SubscribeEvent - public void onWorldJoin(EntityJoinWorldEvent e) { - if (e.entity == mc.thePlayer) { - ModuleManager.disabler.disablerLoaded = false; - inAirTicks = 0; - } - } - - @SubscribeEvent - public void onSendPacketAll(SendAllPacketsEvent e) { - if (!Utils.nullCheck()) { - return; - } - Packet packet = e.getPacket(); - if (packet instanceof C07PacketPlayerDigging && isBlocked) { - C07PacketPlayerDigging c07 = (C07PacketPlayerDigging) packet; - if (Objects.equals(String.valueOf(c07.getStatus()), "RELEASE_USE_ITEM")) { - isBlocked = false; - } - } - if (packet instanceof C09PacketHeldItemChange && isBlocked) { - isBlocked = false; - } - if (packet instanceof C08PacketPlayerBlockPlacement && Utils.holdingSword() && !BlockUtils.isInteractable(mc.objectMouseOver) && !isBlocked) { - isBlocked = true; - } - if (packet instanceof C02PacketUseEntity) { - isAttacking = true; - attackingTicks = 5; - } - - - if (e.getPacket() instanceof C07PacketPlayerDigging) { - C07PacketPlayerDigging c07 = (C07PacketPlayerDigging) packet; - if (Objects.equals(String.valueOf(c07.getStatus()), "START_DESTROY_BLOCK")) { - isBreaking = true; - } - if (Objects.equals(String.valueOf(c07.getStatus()), "ABORT_DESTROY_BLOCK")) { - isBreaking = false; - } - } - } - - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (!Utils.nullCheck()) { - return; - } - Packet packet = e.getPacket(); - - if (e.getPacket() instanceof C09PacketHeldItemChange) { - swapTick = 2; - } - - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && Utils.holdingFireball()) { - if (Utils.keybinds.isMouseDown(1)) { - fireballTime = System.currentTimeMillis(); - threwFireball = true; - if (mc.thePlayer.rotationPitch > 50F) { - threwFireballLow = true; - } - } - } - - } - - @SubscribeEvent - public void onReceivePacketAll(ReceiveAllPacketsEvent e) { - if (!Utils.nullCheck()) { - return; - } - if (e.isCanceled()) { - return; - } - if (e.getPacket() instanceof S27PacketExplosion) { - firstDamage = false; - - dontCheckFD = true; - } - if (e.getPacket() instanceof S12PacketEntityVelocity) { - if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { - - damage = true; - damageTicks = 0; - - if (!dontCheckFD) { - firstDamage = true; - } - dontCheckFD = false; - - ldmg = true; - - } - } - } - - @SubscribeEvent - public void onPostMotion(PostMotionEvent e) { - - } - - private boolean bhopBoostConditions() { - if (ModuleManager.bhop.isEnabled() && ModuleManager.bhop.damageBoost.isToggled() && (!ModuleManager.bhop.damageBoostRequireKey.isToggled() || ModuleManager.bhop.damageBoostKey.isPressed())) { - return true; - } - return false; - } - - private boolean veloBoostConditions() { - if (ModuleManager.velocity.isEnabled() && ModuleManager.velocity.velocityModes.getInput() == 2) { - return true; - } - return false; - } - - @SubscribeEvent - public void onPreUpdate(PreUpdateEvent e) { - - if (bhopBoostConditions()) { - if (firstDamage && ++ft >= 2) { - Utils.setSpeed(Utils.getHorizontalSpeed()); - firstDamage = false; - ft = 0; - } - } - if (veloBoostConditions()) { - if (firstDamage && ++ft >= 2) { - double added = 0; - if (Utils.getHorizontalSpeed() <= Velocity.minExtraSpeed.getInput()) { - added = Velocity.extraSpeedBoost.getInput() / 100; - if (Velocity.reverseDebug.isToggled()) { - Utils.print("&7[&dR&7] Applied extra boost | Original speed: " + Utils.getHorizontalSpeed()); - } - } - Utils.setSpeed((Utils.getHorizontalSpeed() * (Velocity.reverseHorizontal.getInput() / 100)) * (1 + added)); - firstDamage = false; - ft = 0; - } - } - - //-0.0784000015258789 = ground value - - //§ - - double ed = Math.toDegrees(Math.atan2(mc.thePlayer.motionZ, mc.thePlayer.motionX)); - //Utils.print("" + ed); - - if (swapTick > 0) { - --swapTick; - } - - if (ModuleManager.killAura.stoppedTargeting && ++unTargetTicks >= 2) { - ModuleManager.killAura.stoppedTargeting = false; - } - - if (canSlow || ModuleManager.scaffold.isEnabled) { - double motionVal = 0.9507832 - ((double) inAirTicks / 10000) - Utils.randomizeDouble(0.00001, 0.00006); - if (!hasSlowed) motionVal = motionVal - 0.15; - if (mc.thePlayer.hurtTime == 0 && !setSlow && !mc.thePlayer.onGround) { - setSlow = hasSlowed = true; - //Utils.print("Slow " + motionVal); - } - didSlow = true; - //Utils.print(mc.thePlayer.ticksExisted + " : " + Utils.getHorizontalSpeed()); - } - if (didSlow && mc.thePlayer.onGround) { - canSlow = didSlow = false; - } - if (groundTicks > 1) { - hasSlowed = false; - } - if (mc.thePlayer.onGround || mc.thePlayer.hurtTime != 0) { - setSlow = false; - } - - if (!ModuleManager.bhop.running && !ModuleManager.scaffold.fastScaffoldKeepY) { - allowFriction = false; - } - else if (!mc.thePlayer.onGround) { - allowFriction = true; - } - - if (damage && ++damageTicks >= 8) { - damage = firstDamage = false; - damageTicks = 0; - } - - profileTicks++; - - if (isAttacking) { - if (attackingTicks <= 0) { - isAttacking = false; - } - else { - --attackingTicks; - } - } - - if (LongJump.slotReset && ++LongJump.slotResetTicks >= 2) { - LongJump.stopModules = false; - LongJump.slotResetTicks = 0; - LongJump.slotReset = false; - } - - if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT / 3) { - threwFireballLow = false; - ModuleManager.velocity.disableVelo = false; - } - - if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT) { - threwFireball = threwFireballLow = false; - fireballTime = 0; - ModuleManager.velocity.disableVelo = false; - } - - if (CommandManager.status.cooldown != 0) { - if (mc.thePlayer.ticksExisted % 20 == 0) { - CommandManager.status.cooldown--; - } - } - } - - private boolean tower() { - return ModuleManager.tower.canTower() && ModuleManager.tower.towerMove.getInput() != 8; - } - - @SubscribeEvent - public void onPreMotion(PreMotionEvent e) { - int simpleY = (int) Math.round((e.posY % 1) * 10000); - - if (ModuleManager.scaffold.offsetDelay > 0) { - --ModuleManager.scaffold.offsetDelay; - } - - lastTickOnGround = thisTickOnGround; - thisTickOnGround = mc.thePlayer.onGround; - - lastTickPos1 = thisTickPos1; - thisTickPos1 = mc.thePlayer.posY % 1 == 0; - - lastY = thisY; - thisY = (int) mc.thePlayer.posY; - - if (thisY >= lastY + 2 || thisY <= lastY - 2) { - lastYDif = true; - } - else { - lastYDif = false; - } - - inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; - groundTicks = !mc.thePlayer.onGround ? 0 : ++groundTicks; - stillTicks = Utils.isMoving() ? 0 : ++stillTicks; - - handleLowhop(); - - if (ModuleManager.bhop.setRotation) { - if (!ModuleManager.killAura.rotating && !ModuleManager.scaffold.isEnabled) { - yaw = ModuleManager.scaffold.getMotionYaw() - 130.625F * Math.signum( - MathHelper.wrapAngleTo180_float(ModuleManager.scaffold.getMotionYaw() - yaw) - ); - e.setYaw(yaw); - RotationUtils.setFakeRotations(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); - } - if (mc.thePlayer.onGround) { - ModuleManager.bhop.setRotation = false; - } - } - - if (ModuleManager.scaffold.canBlockFade && !ModuleManager.scaffold.isEnabled && ++fadeEdge >= 45) { - ModuleManager.scaffold.canBlockFade = false; - fadeEdge = 0; - ModuleManager.scaffold.highlight.clear(); - } - - ldmg = false; - } - - private void resetLowhop() { - ModuleManager.bhop.lowhop = ModuleManager.scaffold.lowhop = false; - ModuleManager.bhop.didMove = false; - lowhopAir = false; - edgeTick = 0; - } - - public static void handleSlow() { - didSlow = false; - canSlow = true; - } - - public static double applyFrictionMulti() { - final int speedAmplifier = Utils.getSpeedAmplifier(); - if (speedAmplifier > 1 && allowFriction) { - return Bhop.friction.getInput(); - } - return 1; - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onRenderWorld(RenderWorldLastEvent e) { - if (!ModuleManager.scaffold.canBlockFade) { - return; - } - if (!Utils.nullCheck() || !ModuleManager.scaffold.highlightBlocks.isToggled() || ModuleManager.scaffold.highlight.isEmpty()) { - return; - } - Iterator> iterator = ModuleManager.scaffold.highlight.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - if (entry.getValue() == null) { - entry.setValue(new Timer(750)); - entry.getValue().start(); - } - int alpha = entry.getValue() == null ? 210 : 210 - entry.getValue().getValueInt(0, 210, 1); - if (alpha == 0) { - iterator.remove(); - continue; - } - RenderUtils.renderBlock(entry.getKey(), Utils.mergeAlpha(Theme.getGradient((int) HUD.theme.getInput(), 0), alpha), true, false); - } - } - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent e) { - if (!Utils.nullCheck()) { - return; - } - String stripped = Utils.stripColor(e.message.getUnformattedText()); - - //online - if (stripped.contains("You tipped ") && stripped.contains(" in") && stripped.contains("!") && CommandManager.status.start) { - CommandManager.status.start = false; - Utils.print("§a " + CommandManager.status.ign + " is online"); - e.setCanceled(true); - } - if ((stripped.contains("You've already tipped someone in the past hour in") && stripped.contains("! Wait a bit and try again!") || stripped.contains("You've already tipped that person today in ")) && CommandManager.status.start) { - CommandManager.status.start = false; - Utils.print("§a " + CommandManager.status.ign + " is online"); - //client.print(util.colorSymbol + "7^ if player recently left the server this may be innacurate (rate limited)"); - e.setCanceled(true); - } - //offline - if (stripped.contains("That player is not online, try another user!") && CommandManager.status.start) { - CommandManager.status.start = false; - Utils.print("§7 " + CommandManager.status.ign + " is offline"); - e.setCanceled(true); - } - //invalid name - if (stripped.contains("Can't find a player by the name of '") && CommandManager.status.start) { - CommandManager.status.cooldown = 0; - CommandManager.status.start = false; - CommandManager.status.currentMode = CommandManager.status.lastMode; - Utils.print("§7 " + CommandManager.status.ign + " doesn't exist"); - e.setCanceled(true); - } - if (stripped.contains("That's not a valid username!") && CommandManager.status.start) { - CommandManager.status.cooldown = 0; - CommandManager.status.start = false; - CommandManager.status.currentMode = CommandManager.status.lastMode; - Utils.print("§binvalid username"); - e.setCanceled(true); - } - //checking urself - if (stripped.contains("You cannot give yourself tips!") && CommandManager.status.start) { - CommandManager.status.cooldown = 0; - CommandManager.status.start = false; - CommandManager.status.currentMode = CommandManager.status.lastMode; - Utils.print("§a " + CommandManager.status.ign + " is online"); - e.setCanceled(true); - } - } - - private void handleLowhop() { - Block blockAbove = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY + 2, mc.thePlayer.posZ)); - Block blockBelow = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1, mc.thePlayer.posZ)); - Block blockBelow2 = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 2, mc.thePlayer.posZ)); - Block block = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)); - int simpleY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); - - if ((ModuleManager.bhop.didMove || ModuleManager.scaffold.lowhop) && (!ModuleManager.bhop.disablerOnly.isToggled() || ModuleManager.bhop.disablerOnly.isToggled() && ModuleManager.disabler.disablerLoaded)) { - if (ModuleManager.scaffold.lowhop) { - switch (simpleY) { - case 4200: - mc.thePlayer.motionY = 0.39; - break; - case 1138: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.13; - break; - case 2031: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.2; - resetLowhop(); - break; - } - } - else if (ModuleManager.bhop.didMove) { - if (mc.thePlayer.isCollidedVertically || ldmg && Velocity.vertical.getInput() != 0 && !ModuleManager.velocity.dontEditMotion() || block instanceof BlockSlab) {// || !ModuleManager.bhop.lowhop && (!(block instanceof BlockAir) || !(blockAbove instanceof BlockAir) || blockBelow instanceof BlockSlab || (blockBelow instanceof BlockAir && blockBelow2 instanceof BlockAir))) { - resetLowhop(); - return; - } - switch ((int) ModuleManager.bhop.mode.getInput()) { - case 2: // 9 tick - switch (simpleY) { - case 13: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.02483; - ModuleManager.bhop.lowhop = true; - break; - case 2000: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.1913; - break; - case 7016: - mc.thePlayer.motionY = mc.thePlayer.motionY + 0.08; - break; - } - if (ModuleUtils.inAirTicks >= 7 && Utils.isMoving()) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); - } - if (ModuleUtils.inAirTicks >= 9) { - resetLowhop(); - } - break; - case 3: // 8 tick - if (!ModuleManager.bhop.isNormalPos || (block instanceof BlockStairs)) { - resetLowhop(); - break; - } - boolean g1 = Utils.distanceToGround(mc.thePlayer) <= 1.2; - //disable - if (inAirTicks >= 9 || inAirTicks >= 5 && !g1) { - resetLowhop(); - break; - } - if (inAirTicks == 1) { - mc.thePlayer.motionY = 0.38999998569488; - ModuleManager.bhop.lowhop = true; - } - if (inAirTicks == 2) { - mc.thePlayer.motionY = 0.30379999189377; - } - if (inAirTicks == 3) { - mc.thePlayer.motionY = 0.08842400075912; - } - if (inAirTicks == 4) { - mc.thePlayer.motionY = -0.19174457909538; - } - if (inAirTicks == 5 && g1) { - mc.thePlayer.motionY = -0.26630949469659; - } - if (inAirTicks == 6 && g1) { - mc.thePlayer.motionY = -0.26438340940798; - } - if (inAirTicks == 7 && g1) { - mc.thePlayer.motionY = -0.33749574778843; - } - //strafe - if (inAirTicks >= 6 && Utils.isMoving()) { - Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); - } - break; - case 4: // 7 tick - switch (simpleY) { - case 4200: - mc.thePlayer.motionY = 0.39; - ModuleManager.bhop.lowhop = true; - break; - case 1138: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.13; - break; - case 2031: - mc.thePlayer.motionY = mc.thePlayer.motionY - 0.2; - resetLowhop(); - break; - } - break; - } - } - } - if (!mc.thePlayer.onGround) { - lowhopAir = true; - } - else if (lowhopAir) { - resetLowhop(); - if (!ModuleManager.bhop.isEnabled()) { - ModuleManager.bhop.isNormalPos = false; - } - } - } - +package keystrokesmod.utility; + +import keystrokesmod.event.*; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.combat.Velocity; +import keystrokesmod.module.impl.movement.Bhop; +import keystrokesmod.module.impl.movement.LongJump; +import keystrokesmod.module.impl.player.Safewalk; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.utility.command.CommandManager; +import net.minecraft.block.*; +import net.minecraft.client.Minecraft; +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; + +public class ModuleUtils { + private final Minecraft mc; + + public ModuleUtils(Minecraft mc) { + this.mc = mc; + } + + public static boolean isBreaking; + public static boolean threwFireball, threwFireballLow; + public static long MAX_EXPLOSION_DIST_SQ = 10; + private long FIREBALL_TIMEOUT = 500L, fireballTime = 0; + public static int inAirTicks, groundTicks, stillTicks, rcTick; + public static int fadeEdge; + public static double offsetValue = 0.00100012; + public static boolean isAttacking; + private int attackingTicks; + public static int unTargetTicks; + public static int profileTicks = -1, swapTick; + public static int lastY, thisY; + public static boolean lastTickOnGround, lastTickPos1, lastYDif; + private boolean thisTickOnGround, thisTickPos1; + public static boolean firstDamage; + + public static boolean isBlocked; + + public static boolean damage; + private int damageTicks; + private boolean lowhopAir; + + private int edgeTick; + + private boolean dontCheckFD; + + public static boolean canSlow, didSlow, setSlow, hasSlowed; + private static boolean allowFriction; + + private float yaw; + + private boolean ldmg; + + private int placeFrequency, removeFrequency, heldDelay, rcDelay; + + public static boolean worldChange; + + + //-0.0784000015258789 = ground value + + //§ + + @SubscribeEvent + public void onWorldJoin(EntityJoinWorldEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.entity == mc.thePlayer) { + ModuleManager.disabler.disablerLoaded = false; + inAirTicks = 0; + worldChange = true; + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + public void onSendPacketsAll(SendAllPacketsEvent e) { + if (!Utils.nullCheck()) { + return; + } + Packet packet = e.getPacket(); + if (packet instanceof C07PacketPlayerDigging && isBlocked) { + C07PacketPlayerDigging c07 = (C07PacketPlayerDigging) packet; + if (Objects.equals(String.valueOf(c07.getStatus()), "RELEASE_USE_ITEM")) { + isBlocked = false; + } + } + if (packet instanceof C09PacketHeldItemChange && isBlocked) { + isBlocked = false; + } + if (packet instanceof C08PacketPlayerBlockPlacement && Utils.holdingSword() && !BlockUtils.isInteractable(mc.objectMouseOver) && !isBlocked) { + isBlocked = true; + } + if (packet instanceof C02PacketUseEntity) { + isAttacking = true; + attackingTicks = 5; + } + + + if (e.getPacket() instanceof C07PacketPlayerDigging) { + C07PacketPlayerDigging c07 = (C07PacketPlayerDigging) packet; + if (Objects.equals(String.valueOf(c07.getStatus()), "START_DESTROY_BLOCK")) { + isBreaking = true; + } + if (Objects.equals(String.valueOf(c07.getStatus()), "ABORT_DESTROY_BLOCK") || Objects.equals(String.valueOf(c07.getStatus()), "STOP_DESTROY_BLOCK")) { + isBreaking = false; + } + } + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onSendPacket(SendPacketEvent e) { + if (!Utils.nullCheck()) { + return; + } + + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement) { + placeFrequency++; + } + + if (e.getPacket() instanceof C09PacketHeldItemChange) { + swapTick = 2; + } + + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && Utils.holdingFireball()) { + if (Utils.keybinds.isMouseDown(1)) { + fireballTime = System.currentTimeMillis(); + threwFireball = true; + if (mc.thePlayer.rotationPitch > 50F) { + threwFireballLow = true; + } + } + } + + } + + public static boolean hasTeleported; + private int htpt; + + @SubscribeEvent + public void onReceivePacketsAll(ReceiveAllPacketsEvent e) { + if (!Utils.nullCheck()) { + return; + } + if (e.isCanceled()) { + return; + } + if (e.getPacket() instanceof S27PacketExplosion) { + firstDamage = false; + + dontCheckFD = true; + } + if (e.getPacket() instanceof S12PacketEntityVelocity) { + if (((S12PacketEntityVelocity) e.getPacket()).getEntityID() == mc.thePlayer.getEntityId()) { + + damage = true; + damageTicks = 0; + + if (!dontCheckFD) { + firstDamage = true; + } + dontCheckFD = false; + + ldmg = true; + + } + } + if (e.getPacket() instanceof S08PacketPlayerPosLook) { + hasTeleported = true; + htpt = 2; + } + } + + private int ft = 0; + + @SubscribeEvent + public void onPostMotion(PostMotionEvent e) { + if (mc.thePlayer.hurtTime == 9 || mc.thePlayer.hurtTime == 0) { + ft = 0; + } + if (bhopBoostConditions()) { + if (mc.thePlayer.hurtTime > 0 && ft == 0 && firstDamage) { + double base = Utils.getHorizontalSpeed(); + if (base <= 0) { + base = 0.01; + } + Utils.setSpeed(base); + ft = -1; + } + } + if (veloBoostConditions()) { + if (mc.thePlayer.hurtTime > 0 && ft == 0 && firstDamage) { + double added = 0; + if (Utils.getHorizontalSpeed() <= Velocity.minExtraSpeed.getInput()) { + added = Velocity.extraSpeedBoost.getInput() / 100; + if (Velocity.reverseDebug.isToggled()) { + Utils.modulePrint("&7[&dR&7] Applied extra boost | Original speed: " + Utils.getHorizontalSpeed()); + } + } + double base = Utils.getHorizontalSpeed(); + if (base <= 0) { + base = 0.01; + } + Utils.setSpeed((base * (Velocity.reverseHorizontal.getInput() / 100)) * (1 + added)); + ft = -1; + } + } + firstDamage = false; + worldChange = false; + } + + private boolean bhopBoostConditions() { + if (ModuleManager.bhop.isEnabled() && ModuleManager.bhop.damageBoost.isToggled() && (!ModuleManager.bhop.damageBoostRequireKey.isToggled() || ModuleManager.bhop.damageBoostKey.isPressed())) { + return true; + } + return false; + } + + private boolean veloBoostConditions() { + if (ModuleManager.velocity.isEnabled() && ModuleManager.velocity.mode.getInput() == 2) { + return true; + } + return false; + } + + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { + + if (hasTeleported && htpt > 0) { + htpt--; + } + else { + htpt = 0; + hasTeleported = false; + } + + rcTick = Utils.keybinds.isMouseDown(1) ? ++rcTick : 0; + + //Autoswap option "Legit" + + if (placeFrequency > 0) { + if (++removeFrequency > 2) { + removeFrequency = 0; + placeFrequency--; + } + } + else { + removeFrequency = 0; + } + if (!Utils.keybinds.isMouseDown(1)) { + if (++rcDelay > 3) { + placeFrequency = 0; + } + heldDelay = 0; + } + else { + rcDelay = 0; + } + if (holdingBlocks() && rcDelay == 0) { + heldDelay++; + } else { + if (heldDelay > 0) { + heldDelay--; + } + if (rcDelay == 0) { + if (heldDelay > 0 && (placeFrequency > 1 || heldDelay > 4)) { + if (getSlot() != -1 && ModuleManager.autoSwap.legit.isToggled()) { + mc.thePlayer.inventory.currentItem = getSlot(); + } + } + } + } + + if (swapTick > 0) { + --swapTick; + } + + if (ModuleManager.killAura.stoppedTargeting && ++unTargetTicks >= 2) { + ModuleManager.killAura.stoppedTargeting = false; + } + + if (canSlow || ModuleManager.scaffold.isEnabled) { + double motionVal = 0.9507832 - ((double) inAirTicks / 10000) - Utils.randomizeDouble(0.00001, 0.00006); + if (!hasSlowed) motionVal = motionVal - 0.15; + if (mc.thePlayer.hurtTime == 0 && !setSlow && !mc.thePlayer.onGround) { + setSlow = hasSlowed = true; + } + didSlow = true; + } + if (didSlow && mc.thePlayer.onGround) { + canSlow = didSlow = false; + } + if (groundTicks > 1) { + hasSlowed = false; + } + if (mc.thePlayer.onGround || mc.thePlayer.hurtTime != 0) { + setSlow = false; + } + + if (!ModuleManager.bhop.running && !ModuleManager.scaffold.fastScaffoldKeepY) { + allowFriction = false; + } + else if (!mc.thePlayer.onGround) { + allowFriction = true; + } + + if (damage && ++damageTicks >= 8) { + damage = firstDamage = false; + damageTicks = 0; + } + + profileTicks++; + + if (isAttacking) { + if (attackingTicks <= 0) { + isAttacking = false; + } + else { + --attackingTicks; + } + } + + if (LongJump.slotReset && ++LongJump.slotResetTicks >= 2) { + LongJump.stopModules = false; + LongJump.slotResetTicks = 0; + LongJump.slotReset = false; + } + + if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT / 3) { + threwFireballLow = false; + ModuleManager.velocity.disableVelo = false; + } + + if (fireballTime > 0 && (System.currentTimeMillis() - fireballTime) > FIREBALL_TIMEOUT) { + threwFireball = threwFireballLow = false; + fireballTime = 0; + ModuleManager.velocity.disableVelo = false; + } + + if (CommandManager.status.cooldown != 0) { + if (mc.thePlayer.ticksExisted % 20 == 0) { + CommandManager.status.cooldown--; + } + } + } + + private int getSlot() { + int slot = -1; + int highestStack = -1; + ItemStack heldItem = mc.thePlayer.getHeldItem(); + for (int i = 0; i < 9; ++i) { + final ItemStack itemStack = mc.thePlayer.inventory.mainInventory[i]; + if (itemStack != null && itemStack.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) itemStack.getItem()) && itemStack.stackSize > 0) { + if (Utils.getBedwarsStatus() == 2 && ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockTNT) { + continue; + } + if (heldItem != null && heldItem.getItem() instanceof ItemBlock && Utils.canBePlaced((ItemBlock) heldItem.getItem()) && !itemStack.getItem().getClass().equals(heldItem.getItem().getClass())) { + continue; + } + if (itemStack.stackSize > highestStack) { + highestStack = itemStack.stackSize; + slot = i; + } + } + } + return slot; + } + + private boolean holdingBlocks() { + ItemStack heldItem = mc.thePlayer.getHeldItem(); + if (heldItem == null || !(heldItem.getItem() instanceof ItemBlock) || !Utils.canBePlaced((ItemBlock) heldItem.getItem())) { + return false; + } + return true; + } + + private boolean tower() { + return ModuleManager.tower.canTower() && ModuleManager.tower.towerMove.getInput() != 8; + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent e) { + int simpleY = (int) Math.round((e.posY % 1) * 10000); + + if (ModuleManager.scaffold.offsetDelay > 0) { + --ModuleManager.scaffold.offsetDelay; + } + + lastTickOnGround = thisTickOnGround; + thisTickOnGround = mc.thePlayer.onGround; + + lastTickPos1 = thisTickPos1; + thisTickPos1 = mc.thePlayer.posY % 1 == 0; + + lastY = thisY; + thisY = (int) mc.thePlayer.posY; + + if (thisY >= lastY + 2 || thisY <= lastY - 2) { + lastYDif = true; + } + else { + lastYDif = false; + } + + inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; + groundTicks = !mc.thePlayer.onGround ? 0 : ++groundTicks; + stillTicks = Utils.isMoving() ? 0 : ++stillTicks; + + handleLowhop(); + + if (ModuleManager.bhop.setRotation) { + if (!ModuleManager.killAura.rotating && !ModuleManager.scaffold.isEnabled) { + yaw = ModuleManager.scaffold.getMotionYaw() - 130.625F * Math.signum( + MathHelper.wrapAngleTo180_float(ModuleManager.scaffold.getMotionYaw() - yaw) + ); + e.setYaw(yaw); + RotationUtils.setFakeRotations(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); + } + if (mc.thePlayer.onGround) { + ModuleManager.bhop.setRotation = false; + } + } + + if (ModuleManager.scaffold.canBlockFade && !ModuleManager.scaffold.isEnabled && ++fadeEdge >= 45) { + ModuleManager.scaffold.canBlockFade = false; + fadeEdge = 0; + ModuleManager.scaffold.highlight.clear(); + } + + ldmg = false; + } + + private void resetLowhop() { + ModuleManager.bhop.lowhop = ModuleManager.scaffold.lowhop = false; + ModuleManager.bhop.didMove = false; + lowhopAir = false; + edgeTick = 0; + } + + public static void handleSlow() { + didSlow = false; + canSlow = true; + } + + public static double applyFrictionMulti() { + final int speedAmplifier = Utils.getSpeedAmplifier(); + if (speedAmplifier > 1 && allowFriction) { + return Bhop.friction.getInput(); + } + return 1; + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onRenderWorld(RenderWorldLastEvent e) { + if (!ModuleManager.scaffold.canBlockFade) { + return; + } + if (!Utils.nullCheck() || !ModuleManager.scaffold.highlightBlocks.isToggled() || ModuleManager.scaffold.highlight.isEmpty()) { + return; + } + Iterator> iterator = ModuleManager.scaffold.highlight.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + if (entry.getValue() == null) { + entry.setValue(new Timer(750)); + entry.getValue().start(); + } + int alpha = entry.getValue() == null ? 210 : 210 - entry.getValue().getValueInt(0, 210, 1); + if (alpha == 0) { + iterator.remove(); + continue; + } + RenderUtils.renderBlock(entry.getKey(), Utils.mergeAlpha(Theme.getGradient((int) HUD.theme.getInput(), 0), alpha), true, false); + } + } + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent e) { + if (!Utils.nullCheck()) { + return; + } + String stripped = Utils.stripColor(e.message.getUnformattedText()); + + //online + if (stripped.contains("You tipped ") && stripped.contains(" in") && stripped.contains("!") && CommandManager.status.start) { + CommandManager.status.start = false; + Utils.modulePrint("§a " + CommandManager.status.ign + " is online"); + e.setCanceled(true); + } + if ((stripped.contains("You've already tipped someone in the past hour in") && stripped.contains("! Wait a bit and try again!") || stripped.contains("You've already tipped that person today in ")) && CommandManager.status.start) { + CommandManager.status.start = false; + Utils.modulePrint("§a " + CommandManager.status.ign + " is online"); + //client.print(util.colorSymbol + "7^ if player recently left the server this may be innacurate (rate limited)"); + e.setCanceled(true); + } + //offline + if (stripped.contains("That player is not online, try another user!") && CommandManager.status.start) { + CommandManager.status.start = false; + Utils.modulePrint("§7 " + CommandManager.status.ign + " is offline"); + e.setCanceled(true); + } + //invalid name + if (stripped.contains("Can't find a player by the name of '") && CommandManager.status.start) { + CommandManager.status.cooldown = 0; + CommandManager.status.start = false; + CommandManager.status.currentMode = CommandManager.status.lastMode; + Utils.modulePrint("§7 " + CommandManager.status.ign + " doesn't exist"); + e.setCanceled(true); + } + if (stripped.contains("That's not a valid username!") && CommandManager.status.start) { + CommandManager.status.cooldown = 0; + CommandManager.status.start = false; + CommandManager.status.currentMode = CommandManager.status.lastMode; + Utils.modulePrint("§binvalid username"); + e.setCanceled(true); + } + //checking urself + if (stripped.contains("You cannot give yourself tips!") && CommandManager.status.start) { + CommandManager.status.cooldown = 0; + CommandManager.status.start = false; + CommandManager.status.currentMode = CommandManager.status.lastMode; + Utils.modulePrint("§a " + CommandManager.status.ign + " is online"); + e.setCanceled(true); + } + } + + private void handleLowhop() { + Block blockAbove = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY + 2, mc.thePlayer.posZ)); + Block blockBelow = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1, mc.thePlayer.posZ)); + Block blockBelow2 = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 2, mc.thePlayer.posZ)); + Block block = BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)); + int simpleY = (int) Math.round((mc.thePlayer.posY % 1) * 10000); + + if ((ModuleManager.bhop.didMove || ModuleManager.scaffold.lowhop) && (!ModuleManager.bhop.disablerOnly.isToggled() || ModuleManager.bhop.disablerOnly.isToggled() && ModuleManager.disabler.disablerLoaded)) { + if (ModuleManager.scaffold.lowhop) { + switch (simpleY) { + case 4200: + mc.thePlayer.motionY = 0.39; + break; + case 1138: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.13; + break; + case 2031: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.2; + resetLowhop(); + break; + } + } + else if (ModuleManager.bhop.didMove) { + if (mc.thePlayer.isCollidedVertically || ldmg && Velocity.vertical.getInput() != 0 && !ModuleManager.velocity.dontEditMotion() || block instanceof BlockSlab) {// || !ModuleManager.bhop.lowhop && (!(block instanceof BlockAir) || !(blockAbove instanceof BlockAir) || blockBelow instanceof BlockSlab || (blockBelow instanceof BlockAir && blockBelow2 instanceof BlockAir))) { + resetLowhop(); + return; + } + switch ((int) ModuleManager.bhop.mode.getInput()) { + case 2: // 9 tick + switch (simpleY) { + case 13: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.02483; + ModuleManager.bhop.lowhop = true; + break; + case 2000: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.1913; + break; + case 7016: + mc.thePlayer.motionY = mc.thePlayer.motionY + 0.08; + break; + } + if (ModuleUtils.inAirTicks >= 7 && Utils.isMoving()) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); + } + if (ModuleUtils.inAirTicks >= 9) { + resetLowhop(); + } + break; + case 3: // 8 tick + if (!ModuleManager.bhop.isNormalPos || (block instanceof BlockStairs)) { + resetLowhop(); + break; + } + boolean g1 = Utils.distanceToGround(mc.thePlayer) <= 1.2; + //disable + if (inAirTicks >= 9 || inAirTicks >= 5 && !g1) { + resetLowhop(); + break; + } + if (inAirTicks == 1) { + mc.thePlayer.motionY = 0.38999998569488; + ModuleManager.bhop.lowhop = true; + } + if (inAirTicks == 2) { + mc.thePlayer.motionY = 0.30379999189377; + } + if (inAirTicks == 3) { + mc.thePlayer.motionY = 0.08842400075912; + } + if (inAirTicks == 4) { + mc.thePlayer.motionY = -0.19174457909538; + } + if (inAirTicks == 5 && g1) { + mc.thePlayer.motionY = -0.26630949469659; + } + if (inAirTicks == 6 && g1) { + mc.thePlayer.motionY = -0.26438340940798; + } + if (inAirTicks == 7 && g1) { + mc.thePlayer.motionY = -0.33749574778843; + } + //strafe + if (inAirTicks >= 6 && Utils.isMoving()) { + Utils.setSpeed(Utils.getHorizontalSpeed(mc.thePlayer)); + } + break; + case 4: // 7 tick + switch (simpleY) { + case 4200: + mc.thePlayer.motionY = 0.39; + ModuleManager.bhop.lowhop = true; + break; + case 1138: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.13; + break; + case 2031: + mc.thePlayer.motionY = mc.thePlayer.motionY - 0.2; + resetLowhop(); + break; + } + break; + } + } + } + if (!mc.thePlayer.onGround) { + lowhopAir = true; + } + else if (lowhopAir) { + resetLowhop(); + if (!ModuleManager.bhop.isEnabled()) { + ModuleManager.bhop.isNormalPos = false; + } + } + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/PacketUtils.java b/src/main/java/keystrokesmod/utility/PacketUtils.java index 4ec2413..5e23add 100644 --- a/src/main/java/keystrokesmod/utility/PacketUtils.java +++ b/src/main/java/keystrokesmod/utility/PacketUtils.java @@ -1,30 +1,30 @@ -package keystrokesmod.utility; - -import keystrokesmod.Raven; -import net.minecraft.network.Packet; - -import java.util.ArrayList; -import java.util.List; - -public class PacketUtils { - public static List skipSendEvent = new ArrayList<>(); - public static List skipReceiveEvent = new ArrayList<>(); - - public static void sendPacketNoEvent(Packet packet) { - if (packet == null || packet.getClass().getSimpleName().startsWith("S")) { - return; - } - skipSendEvent.add(packet); - Raven.mc.thePlayer.sendQueue.addToSendQueue(packet); - } - - public static void receivePacketNoEvent(Packet packet) { - try { - skipReceiveEvent.add(packet); - packet.processPacket(Raven.mc.getNetHandler()); - } - catch (Exception e) { - e.printStackTrace(); - } - } -} +package keystrokesmod.utility; + +import keystrokesmod.Raven; +import net.minecraft.network.Packet; + +import java.util.ArrayList; +import java.util.List; + +public class PacketUtils { + public static List skipSendEvent = new ArrayList<>(); + public static List skipReceiveEvent = new ArrayList<>(); + + public static void sendPacketNoEvent(Packet packet) { + if (packet == null || packet.getClass().getSimpleName().startsWith("S")) { + return; + } + skipSendEvent.add(packet); + Raven.mc.thePlayer.sendQueue.addToSendQueue(packet); + } + + public static void receivePacketNoEvent(Packet packet) { + try { + skipReceiveEvent.add(packet); + packet.processPacket(Raven.mc.getNetHandler()); + } + catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/PacketsHandler.java b/src/main/java/keystrokesmod/utility/PacketsHandler.java index 00cc879..bf5d252 100644 --- a/src/main/java/keystrokesmod/utility/PacketsHandler.java +++ b/src/main/java/keystrokesmod/utility/PacketsHandler.java @@ -1,151 +1,151 @@ -package keystrokesmod.utility; - -import keystrokesmod.Raven; -import keystrokesmod.event.PostUpdateEvent; -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.SendPacketEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.*; -import net.minecraft.network.play.server.S09PacketHeldItemChange; -import net.minecraft.network.play.server.S0CPacketSpawnPlayer; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -public class PacketsHandler { - public Minecraft mc = Minecraft.getMinecraft(); - - public PacketData C0A = new PacketData(); - public PacketData C08 = new PacketData(); - public PacketData C07 = new PacketData(); - public PacketData C02 = new PacketData(); - public PacketData C02_INTERACT_AT = new PacketData(); - public PacketData C09 = new PacketData(); - - public AtomicInteger playerSlot = new AtomicInteger(-1); - public AtomicInteger serverSlot = new AtomicInteger(-1); - private final boolean handleSlots = true; - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onSendPacket(SendPacketEvent e) { - if (e.isCanceled()) { - return; - } - Packet packet = e.getPacket(); - if (packet instanceof C02PacketUseEntity) { - if (C07.sentCurrentTick.get()) { - e.setCanceled(true); - return; - } - if (((C02PacketUseEntity) packet).getAction() == C02PacketUseEntity.Action.INTERACT_AT) { - C02_INTERACT_AT.sentCurrentTick.set(true); - } - C02.sentCurrentTick.set(true); - } - else if (packet instanceof C08PacketPlayerBlockPlacement) { - C08.sentCurrentTick.set(true); - } - else if (packet instanceof C07PacketPlayerDigging) { - C07.sentCurrentTick.set(true); - } - else if (packet instanceof C0APacketAnimation) { - C0A.sentCurrentTick.set(true); - } - else if (packet instanceof C09PacketHeldItemChange && handleSlots) { - C09PacketHeldItemChange slotPacket = (C09PacketHeldItemChange) packet; - int slotId = slotPacket.getSlotId(); - if (slotId == playerSlot.get() && slotId == serverSlot.get()) { - if (Raven.debug) { - Utils.sendMessage("&7bad packet detected (same slot): &b" + slotId); - } - e.setCanceled(true); - return; - } - C09.sentCurrentTick.set(true); - playerSlot.set(slotId); - serverSlot.set(slotId); - } - } - - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S09PacketHeldItemChange && handleSlots) { - S09PacketHeldItemChange packet = (S09PacketHeldItemChange) e.getPacket(); - int index = packet.getHeldItemHotbarIndex(); - if (index >= 0 && index < InventoryPlayer.getHotbarSize()) { - serverSlot.set(index); - } - } - else if (e.getPacket() instanceof S0CPacketSpawnPlayer && Minecraft.getMinecraft().thePlayer != null && handleSlots) { - S0CPacketSpawnPlayer packet = (S0CPacketSpawnPlayer) e.getPacket(); - if (packet.getEntityID() != Minecraft.getMinecraft().thePlayer.getEntityId()) { - return; - } - playerSlot.set(-1); - } - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPostUpdate(PostUpdateEvent e) { - C08.updateStatesPostUpdate(); - C07.updateStatesPostUpdate(); - C02.updateStatesPostUpdate(); - C0A.updateStatesPostUpdate(); - C02_INTERACT_AT.updateStatesPostUpdate(); - C09.updateStatesPostUpdate(); - } - - public void handlePacket(Packet packet) { - if (packet instanceof C09PacketHeldItemChange && handleSlots) { - int slotId = ((C09PacketHeldItemChange) packet).getSlotId(); - this.playerSlot.set(slotId); - C09.sentCurrentTick.set(true); - } - else if (packet instanceof C02PacketUseEntity) { - C02.sentCurrentTick.set(true); - if (((C02PacketUseEntity) packet).getAction() == C02PacketUseEntity.Action.INTERACT_AT) { - C02_INTERACT_AT.sentCurrentTick.set(true); - } - } - else if (packet instanceof C07PacketPlayerDigging) { - C07.sentCurrentTick.set(true); - } - else if (packet instanceof C08PacketPlayerBlockPlacement) { - C08.sentCurrentTick.set(true); - } - else if (packet instanceof C0APacketAnimation) { - C0A.sentCurrentTick.set(true); - } - } - - public boolean sent() { - return C02.sentCurrentTick.get() || C08.sentCurrentTick.get() || C09.sentCurrentTick.get() || C07.sentCurrentTick.get() || C0A.sentCurrentTick.get(); - } - - public boolean updateSlot(int slot) { - if (!handleSlots) { - mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot)); - return true; - } - if (playerSlot.get() == slot || slot == -1) { - return false; - } - mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot)); - playerSlot.set(slot); - return true; - } - - public static class PacketData { - public AtomicBoolean sentLastTick = new AtomicBoolean(false); - public AtomicBoolean sentCurrentTick = new AtomicBoolean(false); - - public void updateStatesPostUpdate() { - sentLastTick.set(sentCurrentTick.get()); - sentCurrentTick.set(false); - } - } +package keystrokesmod.utility; + +import keystrokesmod.Raven; +import keystrokesmod.event.PostUpdateEvent; +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.event.SendPacketEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.S09PacketHeldItemChange; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +public class PacketsHandler { + public Minecraft mc = Minecraft.getMinecraft(); + + public PacketData C0A = new PacketData(); + public PacketData C08 = new PacketData(); + public PacketData C07 = new PacketData(); + public PacketData C02 = new PacketData(); + public PacketData C02_INTERACT_AT = new PacketData(); + public PacketData C09 = new PacketData(); + + public AtomicInteger playerSlot = new AtomicInteger(-1); + public AtomicInteger serverSlot = new AtomicInteger(-1); + private final boolean handleSlots = true; + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onSendPacket(SendPacketEvent e) { + if (e.isCanceled()) { + return; + } + Packet packet = e.getPacket(); + if (packet instanceof C02PacketUseEntity) { + if (C07.sentCurrentTick.get()) { + e.setCanceled(true); + return; + } + if (((C02PacketUseEntity) packet).getAction() == C02PacketUseEntity.Action.INTERACT_AT) { + C02_INTERACT_AT.sentCurrentTick.set(true); + } + C02.sentCurrentTick.set(true); + } + else if (packet instanceof C08PacketPlayerBlockPlacement) { + C08.sentCurrentTick.set(true); + } + else if (packet instanceof C07PacketPlayerDigging) { + C07.sentCurrentTick.set(true); + } + else if (packet instanceof C0APacketAnimation) { + C0A.sentCurrentTick.set(true); + } + else if (packet instanceof C09PacketHeldItemChange && handleSlots) { + C09PacketHeldItemChange slotPacket = (C09PacketHeldItemChange) packet; + int slotId = slotPacket.getSlotId(); + if (slotId == playerSlot.get() && slotId == serverSlot.get()) { + if (Raven.debug) { + Utils.sendMessage("&7bad packet detected (same slot): &b" + slotId); + } + e.setCanceled(true); + return; + } + C09.sentCurrentTick.set(true); + playerSlot.set(slotId); + serverSlot.set(slotId); + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent e) { + if (e.getPacket() instanceof S09PacketHeldItemChange && handleSlots) { + S09PacketHeldItemChange packet = (S09PacketHeldItemChange) e.getPacket(); + int index = packet.getHeldItemHotbarIndex(); + if (index >= 0 && index < InventoryPlayer.getHotbarSize()) { + serverSlot.set(index); + } + } + else if (e.getPacket() instanceof S0CPacketSpawnPlayer && Minecraft.getMinecraft().thePlayer != null && handleSlots) { + S0CPacketSpawnPlayer packet = (S0CPacketSpawnPlayer) e.getPacket(); + if (packet.getEntityID() != Minecraft.getMinecraft().thePlayer.getEntityId()) { + return; + } + playerSlot.set(-1); + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPostUpdate(PostUpdateEvent e) { + C08.updateStatesPostUpdate(); + C07.updateStatesPostUpdate(); + C02.updateStatesPostUpdate(); + C0A.updateStatesPostUpdate(); + C02_INTERACT_AT.updateStatesPostUpdate(); + C09.updateStatesPostUpdate(); + } + + public void handlePacket(Packet packet) { + if (packet instanceof C09PacketHeldItemChange && handleSlots) { + int slotId = ((C09PacketHeldItemChange) packet).getSlotId(); + this.playerSlot.set(slotId); + C09.sentCurrentTick.set(true); + } + else if (packet instanceof C02PacketUseEntity) { + C02.sentCurrentTick.set(true); + if (((C02PacketUseEntity) packet).getAction() == C02PacketUseEntity.Action.INTERACT_AT) { + C02_INTERACT_AT.sentCurrentTick.set(true); + } + } + else if (packet instanceof C07PacketPlayerDigging) { + C07.sentCurrentTick.set(true); + } + else if (packet instanceof C08PacketPlayerBlockPlacement) { + C08.sentCurrentTick.set(true); + } + else if (packet instanceof C0APacketAnimation) { + C0A.sentCurrentTick.set(true); + } + } + + public boolean sent() { + return C02.sentCurrentTick.get() || C08.sentCurrentTick.get() || C09.sentCurrentTick.get() || C07.sentCurrentTick.get() || C0A.sentCurrentTick.get(); + } + + public boolean updateSlot(int slot) { + if (!handleSlots) { + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot)); + return true; + } + if (playerSlot.get() == slot || slot == -1) { + return false; + } + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot)); + playerSlot.set(slot); + return true; + } + + public static class PacketData { + public AtomicBoolean sentLastTick = new AtomicBoolean(false); + public AtomicBoolean sentCurrentTick = new AtomicBoolean(false); + + public void updateStatesPostUpdate() { + sentLastTick.set(sentCurrentTick.get()); + sentCurrentTick.set(false); + } + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/PlayerData.java b/src/main/java/keystrokesmod/utility/PlayerData.java index 87579fe..ecb1a50 100644 --- a/src/main/java/keystrokesmod/utility/PlayerData.java +++ b/src/main/java/keystrokesmod/utility/PlayerData.java @@ -1,78 +1,78 @@ -package keystrokesmod.utility; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; - -public class PlayerData { - public double speed; - public int aboveVoidTicks; - public int fastTick; - public int autoBlockTicks; - public int ticksExisted; - public int lastSneakTick; - public double posZ; - public int sneakTicks; - public int noSlowTicks; - public double posY; - public boolean sneaking; - public double posX; - public double serverPosX; - public double serverPosY; - public double serverPosZ; - - public void update(EntityPlayer entityPlayer) { - final int ticksExisted = entityPlayer.ticksExisted; - this.posX = entityPlayer.posX - entityPlayer.lastTickPosX; - this.posY = entityPlayer.posY - entityPlayer.lastTickPosY; - this.posZ = entityPlayer.posZ - entityPlayer.lastTickPosZ; - this.speed = Math.max(Math.abs(this.posX), Math.abs(this.posZ)); - if (this.speed >= 0.07) { - ++this.fastTick; - this.ticksExisted = ticksExisted; - } - else { - this.fastTick = 0; - } - if (Math.abs(this.posY) >= 0.1) { - this.aboveVoidTicks = ticksExisted; - } - if (entityPlayer.isSneaking()) { - this.lastSneakTick = ticksExisted; - } - if (entityPlayer.isSwingInProgress && entityPlayer.isBlocking()) { - ++this.autoBlockTicks; - } - else { - this.autoBlockTicks = 0; - } - if (entityPlayer.isSprinting() && entityPlayer.isUsingItem()) { - ++this.noSlowTicks; - } - else { - this.noSlowTicks = 0; - } - if (entityPlayer.rotationPitch >= 70.0f && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemBlock) { - if (entityPlayer.swingProgressInt == 1) { - if (!this.sneaking && entityPlayer.isSneaking()) { - ++this.sneakTicks; - } - else { - this.sneakTicks = 0; - } - } - } - else { - this.sneakTicks = 0; - } - } - - public void updateSneak(final EntityPlayer entityPlayer) { - this.sneaking = entityPlayer.isSneaking(); - } - - public void updateServerPos(EntityPlayer entityPlayer) { - this.serverPosX = entityPlayer.serverPosX / 32; - this.serverPosY = entityPlayer.serverPosY / 32; - this.serverPosZ = entityPlayer.serverPosZ / 32; - } -} +package keystrokesmod.utility; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; + +public class PlayerData { + public double speed; + public int aboveVoidTicks; + public int fastTick; + public int autoBlockTicks; + public int ticksExisted; + public int lastSneakTick; + public double posZ; + public int sneakTicks; + public int noSlowTicks; + public double posY; + public boolean sneaking; + public double posX; + public double serverPosX; + public double serverPosY; + public double serverPosZ; + + public void update(EntityPlayer entityPlayer) { + final int ticksExisted = entityPlayer.ticksExisted; + this.posX = entityPlayer.posX - entityPlayer.lastTickPosX; + this.posY = entityPlayer.posY - entityPlayer.lastTickPosY; + this.posZ = entityPlayer.posZ - entityPlayer.lastTickPosZ; + this.speed = Math.max(Math.abs(this.posX), Math.abs(this.posZ)); + if (this.speed >= 0.07) { + ++this.fastTick; + this.ticksExisted = ticksExisted; + } + else { + this.fastTick = 0; + } + if (Math.abs(this.posY) >= 0.1) { + this.aboveVoidTicks = ticksExisted; + } + if (entityPlayer.isSneaking()) { + this.lastSneakTick = ticksExisted; + } + if (entityPlayer.isSwingInProgress && entityPlayer.isBlocking()) { + ++this.autoBlockTicks; + } + else { + this.autoBlockTicks = 0; + } + if (entityPlayer.isSprinting() && entityPlayer.isUsingItem()) { + ++this.noSlowTicks; + } + else { + this.noSlowTicks = 0; + } + if (entityPlayer.rotationPitch >= 70.0f && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemBlock) { + if (entityPlayer.swingProgressInt == 1) { + if (!this.sneaking && entityPlayer.isSneaking()) { + ++this.sneakTicks; + } + else { + this.sneakTicks = 0; + } + } + } + else { + this.sneakTicks = 0; + } + } + + public void updateSneak(final EntityPlayer entityPlayer) { + this.sneaking = entityPlayer.isSneaking(); + } + + public void updateServerPos(EntityPlayer entityPlayer) { + this.serverPosX = entityPlayer.serverPosX / 32; + this.serverPosY = entityPlayer.serverPosY / 32; + this.serverPosZ = entityPlayer.serverPosZ / 32; + } +} diff --git a/src/main/java/keystrokesmod/utility/ProfileUtils.java b/src/main/java/keystrokesmod/utility/ProfileUtils.java index cc5941c..148b6ce 100644 --- a/src/main/java/keystrokesmod/utility/ProfileUtils.java +++ b/src/main/java/keystrokesmod/utility/ProfileUtils.java @@ -17,7 +17,7 @@ public class ProfileUtils { return result; } - public static int[] getHypixelStats(String playerName, ProfileUtils.DM dm) { + public static int[] getHypixelStats(String playerName, DM dm) { int[] s = new int[]{0, 0, 0}; String u = getMojangProfile(playerName); if (u.isEmpty()) { diff --git a/src/main/java/keystrokesmod/utility/RandomUtils.java b/src/main/java/keystrokesmod/utility/RandomUtils.java index db29427..f0aa828 100644 --- a/src/main/java/keystrokesmod/utility/RandomUtils.java +++ b/src/main/java/keystrokesmod/utility/RandomUtils.java @@ -1,29 +1,29 @@ -package keystrokesmod.utility; - -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -public class RandomUtils { - private static SecureRandom secureRandom; - - static { - try { - secureRandom = SecureRandom.getInstance("SHA1PRNG"); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } - - public static double getRandom(double multiplier) { - if (multiplier == 0) { - return 0; - } - byte[] bytes = new byte[512]; - secureRandom.nextBytes(bytes); - double firstRandom = secureRandom.nextDouble(); - int seedByteCount = 10; - byte[] seed = secureRandom.generateSeed(seedByteCount); - secureRandom.setSeed(seed); - return (secureRandom.nextDouble() - firstRandom) * multiplier; - } -} +package keystrokesmod.utility; + +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +public class RandomUtils { + private static SecureRandom secureRandom; + + static { + try { + secureRandom = SecureRandom.getInstance("SHA1PRNG"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + + public static double getRandom(double multiplier) { + if (multiplier == 0) { + return 0; + } + byte[] bytes = new byte[512]; + secureRandom.nextBytes(bytes); + double firstRandom = secureRandom.nextDouble(); + int seedByteCount = 10; + byte[] seed = secureRandom.generateSeed(seedByteCount); + secureRandom.setSeed(seed); + return (secureRandom.nextDouble() - firstRandom) * multiplier; + } +} diff --git a/src/main/java/keystrokesmod/utility/ReflectionUtils.java b/src/main/java/keystrokesmod/utility/ReflectionUtils.java index 01d14e3..c492898 100644 --- a/src/main/java/keystrokesmod/utility/ReflectionUtils.java +++ b/src/main/java/keystrokesmod/utility/ReflectionUtils.java @@ -1,95 +1,99 @@ -package keystrokesmod.utility; - -import keystrokesmod.mixin.impl.accessor.IAccessorEntityPlayer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiEnchantment; -import net.minecraft.client.gui.inventory.GuiBrewingStand; -import net.minecraft.client.gui.inventory.GuiDispenser; -import net.minecraft.client.gui.inventory.GuiFurnace; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.inventory.*; -import net.minecraftforge.client.event.MouseEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import org.lwjgl.input.Mouse; - -import java.lang.reflect.Field; -import java.nio.ByteBuffer; -import java.util.*; - -public class ReflectionUtils { - - public static Field button; - public static Field buttonstate; - public static Field buttons; - - public static HashMap containerInventoryPlayer = new HashMap<>(); - - private static List containerClasses = Arrays.asList(GuiFurnace.class, GuiBrewingStand.class, GuiEnchantment.class, ContainerHopper.class, GuiDispenser.class, ContainerWorkbench.class, ContainerMerchant.class, ContainerHorseInventory.class); - - public static boolean ERROR = false; // Set to true to alert the player when reflection fails - - public static Map keybinds = new HashMap<>(); - - public static void setupFields() { - try { - button = MouseEvent.class.getDeclaredField("button"); - buttonstate = MouseEvent.class.getDeclaredField("buttonstate"); - buttons = Mouse.class.getDeclaredField("buttons"); - for (Class clazz : containerClasses) { - for (Field field : clazz.getDeclaredFields()) { - addToMap(clazz, field); - } - } - } - catch (Exception var2) { - System.out.println("There was an error, relaunch the game."); - var2.printStackTrace(); - ERROR = true; - } - } - - public static void setKeyBindings() { - for (KeyBinding keyBind : Minecraft.getMinecraft().gameSettings.keyBindings) { - String keyName = keyBind.getKeyDescription().replaceFirst("key\\.", ""); - keybinds.put(keyName, keyBind); - } - } - - public static void setButton(int button, boolean state) { - if (ReflectionUtils.button != null && buttonstate != null && buttons != null) { - MouseEvent m = new MouseEvent(); - try { - ReflectionUtils.button.setAccessible(true); - ReflectionUtils.button.set(m, button); - buttonstate.setAccessible(true); - buttonstate.set(m, state); - MinecraftForge.EVENT_BUS.post(m); - buttons.setAccessible(true); - ByteBuffer bf = (ByteBuffer) buttons.get(null); - buttons.setAccessible(false); - bf.put(button, (byte) (state ? 1 : 0)); - } - catch (IllegalAccessException var4) { - } - } - } - - private static void addToMap(Class clazz, Field field) { - if (field == null || field.getType() != IInventory.class) { - return; - } - field = ReflectionHelper.findField(clazz, field.getName()); - if (field == null) { - return; - } - field.setAccessible(true); - containerInventoryPlayer.put(clazz, field); - } - - public static boolean setItemInUse(boolean blocking) { - ((IAccessorEntityPlayer) Minecraft.getMinecraft().thePlayer).setItemInUseCount(blocking ? 1 : 0); - return blocking; - } - +package keystrokesmod.utility; + +import keystrokesmod.mixin.impl.accessor.IAccessorEntityPlayer; +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiEnchantment; +import net.minecraft.client.gui.inventory.GuiBrewingStand; +import net.minecraft.client.gui.inventory.GuiDispenser; +import net.minecraft.client.gui.inventory.GuiFurnace; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.inventory.*; +import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.relauncher.ReflectionHelper; +import org.lwjgl.input.Mouse; + +import java.lang.reflect.Field; +import java.nio.ByteBuffer; +import java.util.*; + +public class ReflectionUtils { + + public static Field button; + public static Field buttonstate; + public static Field buttons; + + public static HashMap containerInventoryPlayer = new HashMap<>(); + + private static List containerClasses = Arrays.asList(GuiFurnace.class, GuiBrewingStand.class, GuiEnchantment.class, ContainerHopper.class, GuiDispenser.class, ContainerWorkbench.class, ContainerMerchant.class, ContainerHorseInventory.class); + + public static boolean ERROR = false; // Set to true to alert the player when reflection fails + + public static Map keybinds = new HashMap<>(); + + public static void setupFields() { + try { + button = MouseEvent.class.getDeclaredField("button"); + buttonstate = MouseEvent.class.getDeclaredField("buttonstate"); + buttons = Mouse.class.getDeclaredField("buttons"); + for (Class clazz : containerClasses) { + for (Field field : clazz.getDeclaredFields()) { + addToMap(clazz, field); + } + } + } + catch (Exception var2) { + System.out.println("There was an error, relaunch the game."); + var2.printStackTrace(); + ERROR = true; + } + } + + public static void setKeyBindings() { + for (KeyBinding keyBind : Minecraft.getMinecraft().gameSettings.keyBindings) { + String keyName = keyBind.getKeyDescription().replaceFirst("key\\.", ""); + keybinds.put(keyName, keyBind); + } + } + + public static void setButton(int button, boolean state) { + if (ReflectionUtils.button != null && buttonstate != null && buttons != null) { + MouseEvent m = new MouseEvent(); + try { + ReflectionUtils.button.setAccessible(true); + ReflectionUtils.button.set(m, button); + buttonstate.setAccessible(true); + buttonstate.set(m, state); + MinecraftForge.EVENT_BUS.post(m); + buttons.setAccessible(true); + ByteBuffer bf = (ByteBuffer) buttons.get(null); + buttons.setAccessible(false); + bf.put(button, (byte) (state ? 1 : 0)); + } + catch (IllegalAccessException var4) { + } + } + } + + private static void addToMap(Class clazz, Field field) { + if (field == null || field.getType() != IInventory.class) { + return; + } + field = ReflectionHelper.findField(clazz, field.getName()); + if (field == null) { + return; + } + field.setAccessible(true); + containerInventoryPlayer.put(clazz, field); + } + + public static boolean setItemInUse(boolean blocking) { + if (!blocking && (ModuleManager.killAura.blockingClient || ModuleManager.noSlow.blockingClient)) { + return blocking; + } + ((IAccessorEntityPlayer) Minecraft.getMinecraft().thePlayer).setItemInUseCount(blocking ? 2 : 0); + return blocking; + } + } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/RotationUtils.java b/src/main/java/keystrokesmod/utility/RotationUtils.java index ee21149..635ab5b 100644 --- a/src/main/java/keystrokesmod/utility/RotationUtils.java +++ b/src/main/java/keystrokesmod/utility/RotationUtils.java @@ -1,472 +1,472 @@ -package keystrokesmod.utility; - -import com.google.common.base.Predicates; -import keystrokesmod.event.PreMotionEvent; -import keystrokesmod.module.impl.client.Settings; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.*; - -import java.util.List; - -public class RotationUtils { - public static final Minecraft mc = Minecraft.getMinecraft(); - public static float renderPitch; - public static float prevRenderPitch; - public static float renderYaw; - public static float prevRenderYaw; - public static float[] serverRotations = new float[] { 0, 0 } ; - public static float finalYaw = 0; - public static Float[] fakeRotations; - public static boolean setFakeRotations; - - public static void setFakeRotations(float yaw, float pitch) { - fakeRotations = new Float[] { yaw, pitch }; - setFakeRotations = true; - } - - public static void setRenderYaw(float yaw) { - mc.thePlayer.rotationYawHead = yaw; - if (Settings.rotateBody.isToggled() && Settings.fullBody.isToggled()) { - mc.thePlayer.prevRenderYawOffset = prevRenderYaw; - mc.thePlayer.renderYawOffset = yaw; - } - } - - public static float[] getRotations(BlockPos blockPos, final float n, final float n2) { - final float[] array = getRotations(blockPos); - return fixRotation(array[0], array[1], n, n2); - } - - public static float[] getRotationsToBlock(BlockPos blockPos, EnumFacing facing, final float yaw, final float pitch) { - final float[] array = getRotationsToBlock(blockPos, facing); - return fixRotation(array[0], array[1], yaw, pitch); - } - - public static float[] getRotations(BlockPos blockPos) { - double x = blockPos.getX() + 0.45 - mc.thePlayer.posX; - double y = blockPos.getY() + 0.45 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - double z = blockPos.getZ() + 0.45 - mc.thePlayer.posZ; - - float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; - float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); - float yaw = mc.thePlayer.rotationYaw + deltaYaw; - - double distance = MathHelper.sqrt_double(x * x + z * z); - float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); - float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); - float pitch = mc.thePlayer.rotationPitch + deltaPitch; - - pitch = clampPitch(pitch); - - return new float[] { yaw, pitch }; - } - - public static float[] getRotations(double posX, double posY, double posZ) { - double x = posX + 1.0 - mc.thePlayer.posX; - double y = posY + 1.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - double z = posZ + 1.0 - mc.thePlayer.posZ; - - float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; - float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); - float yaw = mc.thePlayer.rotationYaw + deltaYaw; - - double distance = MathHelper.sqrt_double(x * x + z * z); - float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); - float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); - float pitch = mc.thePlayer.rotationPitch + deltaPitch; - - pitch = clampPitch(pitch); - - return new float[] { yaw, pitch }; - } - - public static float[] getRotations(Vec3 vec3) { - double x = vec3.xCoord + 1.0D - mc.thePlayer.posX; - double y = vec3.yCoord + 1.0D - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - double z = vec3.zCoord + 1.0D - mc.thePlayer.posZ; - - float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; - float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); - float yaw = mc.thePlayer.rotationYaw + deltaYaw; - - double distance = MathHelper.sqrt_double(x * x + z * z); - float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); - float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); - float pitch = mc.thePlayer.rotationPitch + deltaPitch; - - pitch = clampPitch(pitch); - - return new float[] { yaw, pitch }; - } - - public static float[] getRotations(Entity entity, final float yaw, final float pitch) { - final float[] array = getRotations(entity); - if (array == null) { - return null; - } - return fixRotation(array[0], array[1], yaw, pitch); - } - - public static float[] getRotationsToBlock(final BlockPos pos, final EnumFacing facing) { - double diffX = pos.getX() + 0.45 - mc.thePlayer.posX; - double diffY = pos.getY() + 0.45 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - double diffZ = pos.getZ() + 0.45 - mc.thePlayer.posZ; - if (facing != null) { - diffX += facing.getDirectionVec().getX() * 0.5; - diffY += facing.getDirectionVec().getY() * 0.5; - diffZ += facing.getDirectionVec().getZ() * 0.5; - } - final double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ); - final float yaw = (float)(Math.atan2(diffZ, diffX) * 57.295780181884766) - 90.0f; - final float pitch = (float)(-(Math.atan2(diffY, dist) * 57.295780181884766)); - return new float[] { mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float(yaw - mc.thePlayer.rotationYaw), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float(pitch - mc.thePlayer.rotationPitch)) }; - } - - public static double distanceFromYaw(final Entity entity, final boolean b) { - return Math.abs(MathHelper.wrapAngleTo180_double(i(entity.posX, entity.posZ) - ((b && PreMotionEvent.setRenderYaw()) ? RotationUtils.renderYaw : mc.thePlayer.rotationYaw))); - } - - public static float i(final double n, final double n2) { - return (float)(Math.atan2(n - mc.thePlayer.posX, n2 - mc.thePlayer.posZ) * 57.295780181884766 * -1.0); - } - - public static boolean isPossibleToHit(Entity target, double reach, float[] rotations) { - final Vec3 eyePosition = mc.thePlayer.getPositionEyes(1.0f); - - final float yaw = rotations[0]; - final float pitch = rotations[1]; - - final float radianYaw = -yaw * 0.017453292f - (float)Math.PI; - final float radianPitch = -pitch * 0.017453292f; - - final float cosYaw = MathHelper.cos(radianYaw); - final float sinYaw = MathHelper.sin(radianYaw); - final float cosPitch = -MathHelper.cos(radianPitch); - final float sinPitch = MathHelper.sin(radianPitch); - - final Vec3 lookVector = new Vec3( - sinYaw * cosPitch, // x - sinPitch, // y - cosYaw * cosPitch // z - ); - - final double lookVecX = lookVector.xCoord * reach; - final double lookVecY = lookVector.yCoord * reach; - final double lookVecZ = lookVector.zCoord * reach; - - final Vec3 endPosition = eyePosition.addVector(lookVecX, lookVecY, lookVecZ); - - final Entity renderViewEntity = mc.getRenderViewEntity(); - final AxisAlignedBB expandedBox = renderViewEntity - .getEntityBoundingBox() - .addCoord(lookVecX, lookVecY, lookVecZ) - .expand(1.0, 1.0, 1.0); - - final List entitiesInPath = mc.theWorld.getEntitiesWithinAABBExcludingEntity(renderViewEntity, expandedBox); - for (Entity entity : entitiesInPath) { - if (entity == target && entity.canBeCollidedWith()) { - final float borderSize = entity.getCollisionBorderSize(); - final AxisAlignedBB entityBox = entity.getEntityBoundingBox() - .expand(borderSize, borderSize, borderSize); - final MovingObjectPosition intercept = entityBox.calculateIntercept(eyePosition, endPosition); - return intercept != null; - } - } - - return false; - } - - public static boolean inRange(final BlockPos blockPos, final double n) { - final float[] array = RotationUtils.getRotations(blockPos); - final Vec3 getPositionEyes = mc.thePlayer.getPositionEyes(1.0f); - final float n2 = -array[0] * 0.017453292f; - final float n3 = -array[1] * 0.017453292f; - final float cos = MathHelper.cos(n2 - 3.1415927f); - final float sin = MathHelper.sin(n2 - 3.1415927f); - final float n4 = -MathHelper.cos(n3); - final Vec3 vec3 = new Vec3(sin * n4, MathHelper.sin(n3), cos * n4); - Block block = BlockUtils.getBlock(blockPos); - IBlockState blockState = BlockUtils.getBlockState(blockPos); - if (block != null && blockState != null) { - AxisAlignedBB boundingBox = block.getCollisionBoundingBox(mc.theWorld, blockPos, blockState); - if (boundingBox != null) { - Vec3 targetVec = getPositionEyes.addVector(vec3.xCoord * n, vec3.yCoord * n, vec3.zCoord * n); - MovingObjectPosition intercept = boundingBox.calculateIntercept(getPositionEyes, targetVec); - if (intercept != null) { - return true; - } - } - } - return false; - } - - public static float[] getRotations(final Entity entity) { - return getRotations(entity, PLAYER_OFFSETS.NONE); - } - - public static float[] getRotations(final Entity entity, PLAYER_OFFSETS playerOffset) { - if (entity == null) { - return null; - } - final double n = entity.posX - mc.thePlayer.posX; - final double n2 = entity.posZ - mc.thePlayer.posZ; - double n3; - if (entity instanceof EntityLivingBase) { - final EntityLivingBase entityLivingBase = (EntityLivingBase) entity; - n3 = entityLivingBase.posY + playerOffset.getHeightOffset(entityLivingBase) * 0.9 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - } - else { - n3 = (entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY) / 2.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - } - return new float[] { mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float((float) (Math.atan2(n2, n) * 57.295780181884766) - 90.0f - mc.thePlayer.rotationYaw), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float((float) (-(Math.atan2(n3, MathHelper.sqrt_double(n * n + n2 * n2)) * 57.295780181884766)) - mc.thePlayer.rotationPitch) + 3.0f)}; - } - - public static float[] getRotationsPredicated(final Entity entity, final int ticks) { - if (entity == null) { - return null; - } - if (ticks == 0) { - return getRotations(entity); - } - double posX = entity.posX; - final double posY = entity.posY; - double posZ = entity.posZ; - final double n2 = posX - entity.lastTickPosX; - final double n3 = posZ - entity.lastTickPosZ; - for (int i = 0; i < ticks; ++i) { - posX += n2; - posZ += n3; - } - final double n4 = posX - mc.thePlayer.posX; - double n5; - if (entity instanceof EntityLivingBase) { - n5 = posY + entity.getEyeHeight() * 0.9 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - } - else { - n5 = (entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY) / 2.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); - } - final double n6 = posZ - mc.thePlayer.posZ; - return new float[] { applyVanilla(mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float((float)(Math.atan2(n6, n4) * 57.295780181884766) - 90.0f - mc.thePlayer.rotationYaw)), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float((float)(-(Math.atan2(n5, MathHelper.sqrt_double(n4 * n4 + n6 * n6)) * 57.295780181884766)) - mc.thePlayer.rotationPitch) + 3.0f) }; - } - - public static float clampPitch(final float n) { - return MathHelper.clamp_float(n, -90.0f, 90.0f); - } - - public static float[] fixRotation(float targetYaw, float targetPitch, final float yaw, final float pitch) { - float n5 = targetYaw - yaw; - final float abs = Math.abs(n5); - final float n7 = targetPitch - pitch; - final float n8 = mc.gameSettings.mouseSensitivity * 0.6f + 0.2f; - final double n9 = n8 * n8 * n8 * 1.2; - final float n10 = (float) (Math.round((double) n5 / n9) * n9); - final float n11 = (float) (Math.round((double) n7 / n9) * n9); - targetYaw = yaw + n10; - targetPitch = pitch + n11; - if (abs >= 1.0f) { - final int n12 = (int) Settings.randomYawFactor.getInput(); - if (n12 != 0) { - final int n13 = n12 * 100 + Utils.randomizeInt(-30, 30); - targetYaw += Utils.randomizeInt(-n13, n13) / 100.0; - } - } else if (abs <= 0.04) { - targetYaw += ((abs > 0.0f) ? 0.01 : -0.01); - } - return new float[] { targetYaw, clampPitch(targetPitch) }; - } - - public static float angle(final double n, final double n2) { - return (float) (Math.atan2(n - mc.thePlayer.posX, n2 - mc.thePlayer.posZ) * 57.295780181884766 * -1.0); - } - - public static MovingObjectPosition rayCast(double distance, float yaw, float pitch, boolean collisionCheck) { - final Vec3 getPositionEyes = mc.thePlayer.getPositionEyes(1.0f); - final float n4 = -yaw * 0.017453292f; - final float n5 = -pitch * 0.017453292f; - final float cos = MathHelper.cos(n4 - 3.1415927f); - final float sin = MathHelper.sin(n4 - 3.1415927f); - final float n6 = -MathHelper.cos(n5); - final Vec3 vec3 = new Vec3(sin * n6, MathHelper.sin(n5), cos * n6); - return mc.theWorld.rayTraceBlocks(getPositionEyes, getPositionEyes.addVector(vec3.xCoord * distance, vec3.yCoord * distance, vec3.zCoord * distance), true, collisionCheck, true); - } - - public static MovingObjectPosition rayTraceCustom(double blockReachDistance, float yaw, float pitch) { - final Vec3 vec3 = mc.thePlayer.getPositionEyes(1.0F); - final Vec3 vec31 = getVectorForRotation(pitch, yaw); - final Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance); - return mc.theWorld.rayTraceBlocks(vec3, vec32, false, false, true); - } - - public static Vec3 getVectorForRotation(float pitch, float yaw) { - float f = MathHelper.cos(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); - float f1 = MathHelper.sin(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); - float f2 = -MathHelper.cos(-pitch * ((float)Math.PI / 180F)); - float f3 = MathHelper.sin(-pitch * ((float)Math.PI / 180F)); - return new Vec3(f1 * f2, f3, f * f2); - } - - public static float applyVanilla(float yaw, boolean stop) { - if (stop) { - return yaw; - } - int scaleFactor = (int) Math.floor(serverRotations[0] / 360); - float unwrappedYaw = yaw + 360 * scaleFactor; - if (unwrappedYaw < serverRotations[0] - 180) { - unwrappedYaw += 360; - } - else if (unwrappedYaw > serverRotations[0] + 180) { - unwrappedYaw -= 360; - } - - float deltaYaw = unwrappedYaw - serverRotations[0]; - return serverRotations[0] + deltaYaw; - } - - public static MovingObjectPosition rayTrace(double range, float partialTicks, float[] rotations, EntityLivingBase ignoreCollision) { - if (ignoreCollision != null) { - MovingObjectPosition target = rayTraceIgnore(range, partialTicks, rotations, ignoreCollision); - if (target != null) { - return target; - } - } - Entity targetEntity = null; - MovingObjectPosition hitObject; - double d0 = range; - if (rotations == null) { - rotations = new float[] { mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch }; - } - hitObject = rayTraceCustom(d0, rotations[0], rotations[1]); - double distanceTo = d0; - Vec3 vec3 = mc.thePlayer.getPositionEyes(partialTicks); - if (mc.playerController.extendedReach()) { - d0 = 6.0; - distanceTo = 6.0; - } - - if (hitObject != null) { - distanceTo = hitObject.hitVec.distanceTo(vec3); - } - - Vec3 vec31 = RotationUtils.getVectorForRotation(rotations[1], rotations[0]); - Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0); - Vec3 vec33 = null; - float f = 1.0F; - List list = mc.theWorld.getEntitiesInAABBexcluding(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, Entity::canBeCollidedWith)); - double d2 = distanceTo; - - for(int j = 0; j < list.size(); ++j) { - Entity entity1 = list.get(j); - float f1 = entity1.getCollisionBorderSize(); - AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1); - MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32); - if (axisalignedbb.isVecInside(vec3)) { - if (d2 >= 0.0) { - targetEntity = entity1; - vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec; - d2 = 0.0; - } - } - else if (movingobjectposition != null) { - double d3 = vec3.distanceTo(movingobjectposition.hitVec); - if (d3 < d2 || d2 == 0.0) { - if (entity1 == mc.thePlayer.ridingEntity && !mc.thePlayer.canRiderInteract()) { - if (d2 == 0.0) { - targetEntity = entity1; - vec33 = movingobjectposition.hitVec; - } - } - else { - targetEntity = entity1; - vec33 = movingobjectposition.hitVec; - d2 = d3; - } - } - } - } - - if (targetEntity != null && d2 < distanceTo) { - return new MovingObjectPosition(targetEntity, vec33); - } - return null; - } - - public static MovingObjectPosition rayTraceIgnore(double range, float partialTicks, float[] rotations, EntityLivingBase ignoreCollision) { - MovingObjectPosition blockHit = rayTraceCustom(range, - rotations[0], - rotations[1]); - - Vec3 start = mc.thePlayer.getPositionEyes(partialTicks); - double blockDistance = range; - if (blockHit != null) { - blockDistance = blockHit.hitVec.distanceTo(start); - } - - if (ignoreCollision != null) { - if (rotations == null) { - rotations = new float[]{ - mc.thePlayer.rotationYaw, - mc.thePlayer.rotationPitch - }; - } - Vec3 lookVec = RotationUtils.getVectorForRotation( - rotations[1], // pitch - rotations[0] // yaw - ); - Vec3 end = start.addVector( - lookVec.xCoord * range, - lookVec.yCoord * range, - lookVec.zCoord * range - ); - - float f1 = ignoreCollision.getCollisionBorderSize(); - AxisAlignedBB aabb = ignoreCollision.getEntityBoundingBox() - .expand(f1, f1, f1); - MovingObjectPosition ignoreMOP = aabb.calculateIntercept(start, end); - - if (aabb.isVecInside(start)) { - return new MovingObjectPosition(ignoreCollision, start); - } - if (ignoreMOP != null) { - double ignoreDist = start.distanceTo(ignoreMOP.hitVec); - if (ignoreDist < blockDistance) { - return new MovingObjectPosition( - ignoreCollision, - ignoreMOP.hitVec - ); - } - } - } - if (blockHit != null) { - return blockHit; - } - return null; - } - - public static float applyVanilla(float yaw) { - return applyVanilla(yaw, false); - } - - public static enum PLAYER_OFFSETS { - EYE, - CHEST, - FOOT, - NONE; - - public double getHeightOffset(Entity entity) { - switch (this) { - case NONE: - case EYE: - return entity.getEyeHeight(); - case CHEST: - return entity.height / 2; - case FOOT: - return 0; - } - return entity.getEyeHeight(); - } - } -} +package keystrokesmod.utility; + +import com.google.common.base.Predicates; +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.module.impl.client.Settings; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.*; + +import java.util.List; + +public class RotationUtils { + public static final Minecraft mc = Minecraft.getMinecraft(); + public static float renderPitch; + public static float prevRenderPitch; + public static float renderYaw; + public static float prevRenderYaw; + public static float[] serverRotations = new float[] { 0, 0 } ; + + public static Float[] fakeRotations; + public static boolean setFakeRotations; + + public static void setFakeRotations(float yaw, float pitch) { + fakeRotations = new Float[] { yaw, pitch }; + setFakeRotations = true; + } + + public static void setRenderYaw(float yaw) { + mc.thePlayer.rotationYawHead = yaw; + if (Settings.rotateBody.isToggled() && Settings.fullBody.isToggled()) { + mc.thePlayer.prevRenderYawOffset = prevRenderYaw; + mc.thePlayer.renderYawOffset = yaw; + } + } + + public static float[] getRotations(BlockPos blockPos, final float n, final float n2) { + final float[] array = getRotations(blockPos); + return fixRotation(array[0], array[1], n, n2); + } + + public static float[] getRotationsToBlock(BlockPos blockPos, EnumFacing facing, final float yaw, final float pitch) { + final float[] array = getRotationsToBlock(blockPos, facing); + return fixRotation(array[0], array[1], yaw, pitch); + } + + public static float[] getRotations(BlockPos blockPos) { + double x = blockPos.getX() + 0.45 - mc.thePlayer.posX; + double y = blockPos.getY() + 0.45 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + double z = blockPos.getZ() + 0.45 - mc.thePlayer.posZ; + + float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; + float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); + float yaw = mc.thePlayer.rotationYaw + deltaYaw; + + double distance = MathHelper.sqrt_double(x * x + z * z); + float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); + float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); + float pitch = mc.thePlayer.rotationPitch + deltaPitch; + + pitch = clampPitch(pitch); + + return new float[] { yaw, pitch }; + } + + public static float[] getRotations(double posX, double posY, double posZ) { + double x = posX + 1.0 - mc.thePlayer.posX; + double y = posY + 1.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + double z = posZ + 1.0 - mc.thePlayer.posZ; + + float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; + float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); + float yaw = mc.thePlayer.rotationYaw + deltaYaw; + + double distance = MathHelper.sqrt_double(x * x + z * z); + float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); + float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); + float pitch = mc.thePlayer.rotationPitch + deltaPitch; + + pitch = clampPitch(pitch); + + return new float[] { yaw, pitch }; + } + + public static float[] getRotations(Vec3 vec3) { + double x = vec3.xCoord + 1.0D - mc.thePlayer.posX; + double y = vec3.yCoord + 1.0D - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + double z = vec3.zCoord + 1.0D - mc.thePlayer.posZ; + + float angleToBlock = (float) (Math.atan2(z, x) * (180 / Math.PI)) - 90.0f; + float deltaYaw = MathHelper.wrapAngleTo180_float(angleToBlock - mc.thePlayer.rotationYaw); + float yaw = mc.thePlayer.rotationYaw + deltaYaw; + + double distance = MathHelper.sqrt_double(x * x + z * z); + float angleToBlockPitch = (float) (-(Math.atan2(y, distance) * (180 / Math.PI))); + float deltaPitch = MathHelper.wrapAngleTo180_float(angleToBlockPitch - mc.thePlayer.rotationPitch); + float pitch = mc.thePlayer.rotationPitch + deltaPitch; + + pitch = clampPitch(pitch); + + return new float[] { yaw, pitch }; + } + + public static float[] getRotations(Entity entity, final float yaw, final float pitch) { + final float[] array = getRotations(entity); + if (array == null) { + return null; + } + return fixRotation(array[0], array[1], yaw, pitch); + } + + public static float[] getRotationsToBlock(final BlockPos pos, final EnumFacing facing) { + double diffX = pos.getX() + 0.45 - mc.thePlayer.posX; + double diffY = pos.getY() + 0.45 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + double diffZ = pos.getZ() + 0.45 - mc.thePlayer.posZ; + if (facing != null) { + diffX += facing.getDirectionVec().getX() * 0.5; + diffY += facing.getDirectionVec().getY() * 0.5; + diffZ += facing.getDirectionVec().getZ() * 0.5; + } + final double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ); + final float yaw = (float)(Math.atan2(diffZ, diffX) * 57.295780181884766) - 90.0f; + final float pitch = (float)(-(Math.atan2(diffY, dist) * 57.295780181884766)); + return new float[] { mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float(yaw - mc.thePlayer.rotationYaw), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float(pitch - mc.thePlayer.rotationPitch)) }; + } + + public static double distanceFromYaw(final Entity entity, final boolean b) { + return Math.abs(MathHelper.wrapAngleTo180_double(i(entity.posX, entity.posZ) - ((b && PreMotionEvent.setRenderYaw()) ? RotationUtils.renderYaw : mc.thePlayer.rotationYaw))); + } + + public static float i(final double n, final double n2) { + return (float)(Math.atan2(n - mc.thePlayer.posX, n2 - mc.thePlayer.posZ) * 57.295780181884766 * -1.0); + } + + public static boolean isPossibleToHit(Entity target, double reach, float[] rotations) { + final Vec3 eyePosition = mc.thePlayer.getPositionEyes(1.0f); + + final float yaw = rotations[0]; + final float pitch = rotations[1]; + + final float radianYaw = -yaw * 0.017453292f - (float)Math.PI; + final float radianPitch = -pitch * 0.017453292f; + + final float cosYaw = MathHelper.cos(radianYaw); + final float sinYaw = MathHelper.sin(radianYaw); + final float cosPitch = -MathHelper.cos(radianPitch); + final float sinPitch = MathHelper.sin(radianPitch); + + final Vec3 lookVector = new Vec3( + sinYaw * cosPitch, // x + sinPitch, // y + cosYaw * cosPitch // z + ); + + final double lookVecX = lookVector.xCoord * reach; + final double lookVecY = lookVector.yCoord * reach; + final double lookVecZ = lookVector.zCoord * reach; + + final Vec3 endPosition = eyePosition.addVector(lookVecX, lookVecY, lookVecZ); + + final Entity renderViewEntity = mc.getRenderViewEntity(); + final AxisAlignedBB expandedBox = renderViewEntity + .getEntityBoundingBox() + .addCoord(lookVecX, lookVecY, lookVecZ) + .expand(1.0, 1.0, 1.0); + + final List entitiesInPath = mc.theWorld.getEntitiesWithinAABBExcludingEntity(renderViewEntity, expandedBox); + for (Entity entity : entitiesInPath) { + if (entity == target && entity.canBeCollidedWith()) { + final float borderSize = entity.getCollisionBorderSize(); + final AxisAlignedBB entityBox = entity.getEntityBoundingBox() + .expand(borderSize, borderSize, borderSize); + final MovingObjectPosition intercept = entityBox.calculateIntercept(eyePosition, endPosition); + return intercept != null; + } + } + + return false; + } + + public static boolean inRange(final BlockPos blockPos, final double n) { + final float[] array = RotationUtils.getRotations(blockPos); + final Vec3 getPositionEyes = mc.thePlayer.getPositionEyes(1.0f); + final float n2 = -array[0] * 0.017453292f; + final float n3 = -array[1] * 0.017453292f; + final float cos = MathHelper.cos(n2 - 3.1415927f); + final float sin = MathHelper.sin(n2 - 3.1415927f); + final float n4 = -MathHelper.cos(n3); + final Vec3 vec3 = new Vec3(sin * n4, MathHelper.sin(n3), cos * n4); + Block block = BlockUtils.getBlock(blockPos); + IBlockState blockState = BlockUtils.getBlockState(blockPos); + if (block != null && blockState != null) { + AxisAlignedBB boundingBox = block.getCollisionBoundingBox(mc.theWorld, blockPos, blockState); + if (boundingBox != null) { + Vec3 targetVec = getPositionEyes.addVector(vec3.xCoord * n, vec3.yCoord * n, vec3.zCoord * n); + MovingObjectPosition intercept = boundingBox.calculateIntercept(getPositionEyes, targetVec); + if (intercept != null) { + return true; + } + } + } + return false; + } + + public static float[] getRotations(final Entity entity) { + return getRotations(entity, PLAYER_OFFSETS.NONE); + } + + public static float[] getRotations(final Entity entity, PLAYER_OFFSETS playerOffset) { + if (entity == null) { + return null; + } + final double n = entity.posX - mc.thePlayer.posX; + final double n2 = entity.posZ - mc.thePlayer.posZ; + double n3; + if (entity instanceof EntityLivingBase) { + final EntityLivingBase entityLivingBase = (EntityLivingBase) entity; + n3 = entityLivingBase.posY + playerOffset.getHeightOffset(entityLivingBase) * 0.9 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + } + else { + n3 = (entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY) / 2.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + } + return new float[] { mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float((float) (Math.atan2(n2, n) * 57.295780181884766) - 90.0f - mc.thePlayer.rotationYaw), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float((float) (-(Math.atan2(n3, MathHelper.sqrt_double(n * n + n2 * n2)) * 57.295780181884766)) - mc.thePlayer.rotationPitch) + 3.0f)}; + } + + public static float[] getRotationsPredicated(final Entity entity, final int ticks) { + if (entity == null) { + return null; + } + if (ticks == 0) { + return getRotations(entity); + } + double posX = entity.posX; + final double posY = entity.posY; + double posZ = entity.posZ; + final double n2 = posX - entity.lastTickPosX; + final double n3 = posZ - entity.lastTickPosZ; + for (int i = 0; i < ticks; ++i) { + posX += n2; + posZ += n3; + } + final double n4 = posX - mc.thePlayer.posX; + double n5; + if (entity instanceof EntityLivingBase) { + n5 = posY + entity.getEyeHeight() * 0.9 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + } + else { + n5 = (entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY) / 2.0 - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight()); + } + final double n6 = posZ - mc.thePlayer.posZ; + return new float[] { applyVanilla(mc.thePlayer.rotationYaw + MathHelper.wrapAngleTo180_float((float)(Math.atan2(n6, n4) * 57.295780181884766) - 90.0f - mc.thePlayer.rotationYaw)), clampPitch(mc.thePlayer.rotationPitch + MathHelper.wrapAngleTo180_float((float)(-(Math.atan2(n5, MathHelper.sqrt_double(n4 * n4 + n6 * n6)) * 57.295780181884766)) - mc.thePlayer.rotationPitch) + 3.0f) }; + } + + public static float clampPitch(final float n) { + return MathHelper.clamp_float(n, -90.0f, 90.0f); + } + + public static float[] fixRotation(float targetYaw, float targetPitch, final float yaw, final float pitch) { + float n5 = targetYaw - yaw; + final float abs = Math.abs(n5); + final float n7 = targetPitch - pitch; + final float n8 = mc.gameSettings.mouseSensitivity * 0.6f + 0.2f; + final double n9 = n8 * n8 * n8 * 1.2; + final float n10 = (float) (Math.round((double) n5 / n9) * n9); + final float n11 = (float) (Math.round((double) n7 / n9) * n9); + targetYaw = yaw + n10; + targetPitch = pitch + n11; + if (abs >= 1.0f) { + final int n12 = (int) Settings.randomYawFactor.getInput(); + if (n12 != 0) { + final int n13 = n12 * 100 + Utils.randomizeInt(-30, 30); + targetYaw += Utils.randomizeInt(-n13, n13) / 100.0; + } + } else if (abs <= 0.04) { + targetYaw += ((abs > 0.0f) ? 0.01 : -0.01); + } + return new float[] { targetYaw, clampPitch(targetPitch) }; + } + + public static float angle(final double n, final double n2) { + return (float) (Math.atan2(n - mc.thePlayer.posX, n2 - mc.thePlayer.posZ) * 57.295780181884766 * -1.0); + } + + public static MovingObjectPosition rayCast(double distance, float yaw, float pitch, boolean collisionCheck) { + final Vec3 getPositionEyes = mc.thePlayer.getPositionEyes(1.0f); + final float n4 = -yaw * 0.017453292f; + final float n5 = -pitch * 0.017453292f; + final float cos = MathHelper.cos(n4 - 3.1415927f); + final float sin = MathHelper.sin(n4 - 3.1415927f); + final float n6 = -MathHelper.cos(n5); + final Vec3 vec3 = new Vec3(sin * n6, MathHelper.sin(n5), cos * n6); + return mc.theWorld.rayTraceBlocks(getPositionEyes, getPositionEyes.addVector(vec3.xCoord * distance, vec3.yCoord * distance, vec3.zCoord * distance), true, collisionCheck, true); + } + + public static MovingObjectPosition rayTraceCustom(double blockReachDistance, float yaw, float pitch) { + final Vec3 vec3 = mc.thePlayer.getPositionEyes(1.0F); + final Vec3 vec31 = getVectorForRotation(pitch, yaw); + final Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance); + return mc.theWorld.rayTraceBlocks(vec3, vec32, false, false, true); + } + + public static Vec3 getVectorForRotation(float pitch, float yaw) { + float f = MathHelper.cos(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); + float f1 = MathHelper.sin(-yaw * ((float)Math.PI / 180F) - (float)Math.PI); + float f2 = -MathHelper.cos(-pitch * ((float)Math.PI / 180F)); + float f3 = MathHelper.sin(-pitch * ((float)Math.PI / 180F)); + return new Vec3(f1 * f2, f3, f * f2); + } + + public static float applyVanilla(float yaw, boolean stop) { + if (stop) { + return yaw; + } + int scaleFactor = (int) Math.floor(serverRotations[0] / 360); + float unwrappedYaw = yaw + 360 * scaleFactor; + if (unwrappedYaw < serverRotations[0] - 180) { + unwrappedYaw += 360; + } + else if (unwrappedYaw > serverRotations[0] + 180) { + unwrappedYaw -= 360; + } + + float deltaYaw = unwrappedYaw - serverRotations[0]; + return serverRotations[0] + deltaYaw; + } + + public static MovingObjectPosition rayTrace(double range, float partialTicks, float[] rotations, EntityLivingBase ignoreCollision) { + if (ignoreCollision != null) { + MovingObjectPosition target = rayTraceIgnore(range, partialTicks, rotations, ignoreCollision); + if (target != null) { + return target; + } + } + Entity targetEntity = null; + MovingObjectPosition hitObject; + double d0 = range; + if (rotations == null) { + rotations = new float[] { mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch }; + } + hitObject = rayTraceCustom(d0, rotations[0], rotations[1]); + double distanceTo = d0; + Vec3 vec3 = mc.thePlayer.getPositionEyes(partialTicks); + if (mc.playerController.extendedReach()) { + d0 = 6.0; + distanceTo = 6.0; + } + + if (hitObject != null) { + distanceTo = hitObject.hitVec.distanceTo(vec3); + } + + Vec3 vec31 = RotationUtils.getVectorForRotation(rotations[1], rotations[0]); + Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0); + Vec3 vec33 = null; + float f = 1.0F; + List list = mc.theWorld.getEntitiesInAABBexcluding(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, Entity::canBeCollidedWith)); + double d2 = distanceTo; + + for(int j = 0; j < list.size(); ++j) { + Entity entity1 = list.get(j); + float f1 = entity1.getCollisionBorderSize(); + AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1); + MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32); + if (axisalignedbb.isVecInside(vec3)) { + if (d2 >= 0.0) { + targetEntity = entity1; + vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec; + d2 = 0.0; + } + } + else if (movingobjectposition != null) { + double d3 = vec3.distanceTo(movingobjectposition.hitVec); + if (d3 < d2 || d2 == 0.0) { + if (entity1 == mc.thePlayer.ridingEntity && !mc.thePlayer.canRiderInteract()) { + if (d2 == 0.0) { + targetEntity = entity1; + vec33 = movingobjectposition.hitVec; + } + } + else { + targetEntity = entity1; + vec33 = movingobjectposition.hitVec; + d2 = d3; + } + } + } + } + + if (targetEntity != null && d2 < distanceTo) { + return new MovingObjectPosition(targetEntity, vec33); + } + return null; + } + + public static MovingObjectPosition rayTraceIgnore(double range, float partialTicks, float[] rotations, EntityLivingBase ignoreCollision) { + MovingObjectPosition blockHit = rayTraceCustom(range, + rotations[0], + rotations[1]); + + Vec3 start = mc.thePlayer.getPositionEyes(partialTicks); + double blockDistance = range; + if (blockHit != null) { + blockDistance = blockHit.hitVec.distanceTo(start); + } + + if (ignoreCollision != null) { + if (rotations == null) { + rotations = new float[]{ + mc.thePlayer.rotationYaw, + mc.thePlayer.rotationPitch + }; + } + Vec3 lookVec = RotationUtils.getVectorForRotation( + rotations[1], // pitch + rotations[0] // yaw + ); + Vec3 end = start.addVector( + lookVec.xCoord * range, + lookVec.yCoord * range, + lookVec.zCoord * range + ); + + float f1 = ignoreCollision.getCollisionBorderSize(); + AxisAlignedBB aabb = ignoreCollision.getEntityBoundingBox() + .expand(f1, f1, f1); + MovingObjectPosition ignoreMOP = aabb.calculateIntercept(start, end); + + if (aabb.isVecInside(start)) { + return new MovingObjectPosition(ignoreCollision, start); + } + if (ignoreMOP != null) { + double ignoreDist = start.distanceTo(ignoreMOP.hitVec); + if (ignoreDist < blockDistance) { + return new MovingObjectPosition( + ignoreCollision, + ignoreMOP.hitVec + ); + } + } + } + if (blockHit != null) { + return blockHit; + } + return null; + } + + public static float applyVanilla(float yaw) { + return applyVanilla(yaw, false); + } + + public static enum PLAYER_OFFSETS { + EYE, + CHEST, + FOOT, + NONE; + + public double getHeightOffset(Entity entity) { + switch (this) { + case NONE: + case EYE: + return entity.getEyeHeight(); + case CHEST: + return entity.height / 2; + case FOOT: + return 0; + } + return entity.getEyeHeight(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/ScaffoldBlockCount.java b/src/main/java/keystrokesmod/utility/ScaffoldBlockCount.java index 9371aee..b48df4c 100644 --- a/src/main/java/keystrokesmod/utility/ScaffoldBlockCount.java +++ b/src/main/java/keystrokesmod/utility/ScaffoldBlockCount.java @@ -1,79 +1,79 @@ -package keystrokesmod.utility; - -import keystrokesmod.module.ModuleManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; - -public class ScaffoldBlockCount { - private final Minecraft mc; - public static Timer fadeTimer; - public static Timer fadeInTimer; - private float previousAlpha; - - public ScaffoldBlockCount(Minecraft mc) { - this.mc = mc; - this.fadeTimer = null; - (this.fadeInTimer = new Timer(150)).start(); - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent ev) { - if (previousAlpha <= 10 && fadeInTimer == null) { - onDisable(); - return; - } - if (!Utils.nullCheck() || !ModuleManager.scaffold.showBlockCount.isToggled()) { - return; - } - if (ev.phase == TickEvent.Phase.END) { - if (mc.currentScreen != null) { - return; - } - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int blocks = ModuleManager.scaffold.totalBlocks(); - String color = "§"; - if (blocks <= 5) { - color += "c"; - } - else if (blocks <= 15) { - color += "6"; - } - else if (blocks <= 25) { - color += "e"; - } - else { - color = ""; - } - float alpha = fadeTimer == null ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); - if (fadeInTimer != null) { - alpha = fadeInTimer.getValueFloat(10, 255, 1); - if (alpha == 255) { - fadeInTimer = null; - } - } - previousAlpha = alpha; - int colorAlpha = Utils.mergeAlpha(-1, (int) previousAlpha); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - mc.fontRendererObj.drawStringWithShadow(color + blocks + " §rblock" + (blocks == 1 ? "" : "s"), scaledResolution.getScaledWidth()/2 + 8, scaledResolution.getScaledHeight()/2 + 4, colorAlpha); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - } - - public void beginFade() { - (this.fadeTimer = new Timer(150)).start(); - this.fadeInTimer = null; - } - - public void onDisable() { - ScaffoldBlockCount.fadeInTimer = null; - ScaffoldBlockCount.fadeTimer = null; - FMLCommonHandler.instance().bus().unregister(this); - } -} +package keystrokesmod.utility; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; + +public class ScaffoldBlockCount { + private final Minecraft mc; + public static Timer fadeTimer; + public static Timer fadeInTimer; + private float previousAlpha; + + public ScaffoldBlockCount(Minecraft mc) { + this.mc = mc; + this.fadeTimer = null; + (this.fadeInTimer = new Timer(150)).start(); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent ev) { + if (previousAlpha <= 10 && fadeInTimer == null) { + onDisable(); + return; + } + if (!Utils.nullCheck() || !ModuleManager.scaffold.showBlockCount.isToggled()) { + return; + } + if (ev.phase == TickEvent.Phase.END) { + if (mc.currentScreen != null) { + return; + } + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int blocks = ModuleManager.scaffold.totalBlocks(); + String color = "§"; + if (blocks <= 5) { + color += "c"; + } + else if (blocks <= 15) { + color += "6"; + } + else if (blocks <= 25) { + color += "e"; + } + else { + color = ""; + } + float alpha = fadeTimer == null ? 255 : (255 - fadeTimer.getValueInt(0, 255, 1)); + if (fadeInTimer != null) { + alpha = fadeInTimer.getValueFloat(10, 255, 1); + if (alpha == 255) { + fadeInTimer = null; + } + } + previousAlpha = alpha; + int colorAlpha = Utils.mergeAlpha(-1, (int) previousAlpha); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + mc.fontRendererObj.drawStringWithShadow(color + blocks + " §rblock" + (blocks == 1 ? "" : "s"), scaledResolution.getScaledWidth()/2 + 8, scaledResolution.getScaledHeight()/2 + 4, colorAlpha); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + + public void beginFade() { + (this.fadeTimer = new Timer(150)).start(); + this.fadeInTimer = null; + } + + public void onDisable() { + ScaffoldBlockCount.fadeInTimer = null; + ScaffoldBlockCount.fadeTimer = null; + FMLCommonHandler.instance().bus().unregister(this); + } +} diff --git a/src/main/java/keystrokesmod/utility/Theme.java b/src/main/java/keystrokesmod/utility/Theme.java index 9a0d186..22e38c3 100644 --- a/src/main/java/keystrokesmod/utility/Theme.java +++ b/src/main/java/keystrokesmod/utility/Theme.java @@ -1,70 +1,70 @@ -package keystrokesmod.utility; - -import keystrokesmod.module.impl.client.Settings; - -import java.awt.*; - -public enum Theme { - Rainbow(null, null), // 0 - Cherry(new Color(255, 200, 200), new Color(243, 58, 106)), // 1 - Cotton_candy(new Color(99, 249, 255), new Color(255, 104, 204)), // 2 - Flare(new Color(231, 39, 24), new Color(245, 173, 49)), // 3 - Flower(new Color(215, 166, 231), new Color(211, 90, 232)), // 4 - Gold(new Color(255, 215, 0), new Color(240, 159, 0)), // from croat, 5 - Grayscale(new Color(240, 240, 240), new Color(110, 110, 110)), // 6 - Royal(new Color(125, 204, 241), new Color(30, 71, 170)), // 7 - Sky(new Color(160, 230, 225), new Color(15, 190, 220)), // 8 - Vine(new Color(17, 192, 45), new Color(201, 234, 198)); // 9 - - private final Color firstGradient; - private final Color secondGradient; - public static Color[] descriptor = new Color[]{new Color(95, 235, 255), new Color(68, 102, 250)}; - public static Color[] hiddenBind = new Color[]{new Color(245, 33, 33), new Color(229, 21, 98)}; - - Theme(Color firstGradient, Color secondGradient) { - this.firstGradient = firstGradient; - this.secondGradient = secondGradient; - } - - public static int getGradient(int index, double delay) { - if (index > 0) { - return convert(values()[index].firstGradient, values()[index].secondGradient, (Math.sin(System.currentTimeMillis() / 1.0E8 * Settings.timeMultiplier.getInput() * 400000.0 + delay * Settings.offset.getInput()) + 1.0) * 0.5).getRGB(); - } - else if (index == 0) { - return getChromaOffset(2, (long) delay); - } - return -1; - } - - public static int getChromaOffset(long speed, long delay) { - double offset = Settings.offset.getInput() * delay; - long time = System.currentTimeMillis() + (long) offset; - float hue = (float) (time % (15000L / speed)) / (15000.0F / (float) speed); - return Color.getHSBColor(hue, 1.0F, 1.0F).getRGB(); - } - - public static int getGradient(Color firstGradient, Color secondGradient, double delay) { - return convert(firstGradient, secondGradient, (Math.sin(System.currentTimeMillis() / 1.0E8 * 0.5 * 400000.0 + delay * 0.550000011920929) + 1.0) * 0.5).getRGB(); - } - - public static Color convert(Color color, Color color2, double delay) { - double n2 = 1.0 - delay; - return new Color((int) (color.getRed() * delay + color2.getRed() * n2), (int) (color.getGreen() * delay + color2.getGreen() * n2), (int) (color.getBlue() * delay + color2.getBlue() * n2)); - } - - public static int[] getGradients(int index) { - Theme[] values = values(); - if (values != null && index >= 0 && index < values.length && values[index] != null) { - Color firstGradient = values[index].firstGradient; - Color secondGradient = values[index].secondGradient; - if (firstGradient != null && secondGradient != null) { - return new int[]{firstGradient.getRGB(), secondGradient.getRGB()}; - } else { - return new int[]{Utils.getChroma(2, (long) 0), Utils.getChroma(2, (long) 0)}; - } - } - return new int[]{0, 0}; - } - - public static String[] themes = new String[]{"Rainbow", "Cherry", "Cotton candy", "Flare", "Flower", "Gold", "Grayscale", "Royal", "Sky", "Vine"}; -} +package keystrokesmod.utility; + +import keystrokesmod.module.impl.client.Settings; + +import java.awt.*; + +public enum Theme { + Rainbow(null, null), // 0 + Cherry(new Color(255, 200, 200), new Color(243, 58, 106)), // 1 + Cotton_candy(new Color(99, 249, 255), new Color(255, 104, 204)), // 2 + Flare(new Color(231, 39, 24), new Color(245, 173, 49)), // 3 + Flower(new Color(215, 166, 231), new Color(211, 90, 232)), // 4 + Gold(new Color(255, 215, 0), new Color(240, 159, 0)), // from croat, 5 + Grayscale(new Color(240, 240, 240), new Color(110, 110, 110)), // 6 + Royal(new Color(125, 204, 241), new Color(30, 71, 170)), // 7 + Sky(new Color(160, 230, 225), new Color(15, 190, 220)), // 8 + Vine(new Color(17, 192, 45), new Color(201, 234, 198)); // 9 + + private final Color firstGradient; + private final Color secondGradient; + public static Color[] descriptor = new Color[]{new Color(95, 235, 255), new Color(68, 102, 250)}; + public static Color[] hiddenBind = new Color[]{new Color(245, 33, 33), new Color(229, 21, 98)}; + + Theme(Color firstGradient, Color secondGradient) { + this.firstGradient = firstGradient; + this.secondGradient = secondGradient; + } + + public static int getGradient(int index, double delay) { + if (index > 0) { + return convert(values()[index].firstGradient, values()[index].secondGradient, (Math.sin(System.currentTimeMillis() / 1.0E8 * Settings.timeMultiplier.getInput() * 400000.0 + delay * Settings.offset.getInput()) + 1.0) * 0.5).getRGB(); + } + else if (index == 0) { + return getChromaOffset(2, (long) delay); + } + return -1; + } + + public static int getChromaOffset(long speed, long delay) { + double offset = Settings.offset.getInput() * delay; + long time = System.currentTimeMillis() + (long) offset; + float hue = (float) (time % (15000L / speed)) / (15000.0F / (float) speed); + return Color.getHSBColor(hue, 1.0F, 1.0F).getRGB(); + } + + public static int getGradient(Color firstGradient, Color secondGradient, double delay) { + return convert(firstGradient, secondGradient, (Math.sin(System.currentTimeMillis() / 1.0E8 * 0.5 * 400000.0 + delay * 0.550000011920929) + 1.0) * 0.5).getRGB(); + } + + public static Color convert(Color color, Color color2, double delay) { + double n2 = 1.0 - delay; + return new Color((int) (color.getRed() * delay + color2.getRed() * n2), (int) (color.getGreen() * delay + color2.getGreen() * n2), (int) (color.getBlue() * delay + color2.getBlue() * n2)); + } + + public static int[] getGradients(int index) { + Theme[] values = values(); + if (values != null && index >= 0 && index < values.length && values[index] != null) { + Color firstGradient = values[index].firstGradient; + Color secondGradient = values[index].secondGradient; + if (firstGradient != null && secondGradient != null) { + return new int[]{firstGradient.getRGB(), secondGradient.getRGB()}; + } else { + return new int[]{Utils.getChroma(2, (long) 0), Utils.getChroma(2, (long) 0)}; + } + } + return new int[]{0, 0}; + } + + public static String[] themes = new String[]{"Rainbow", "Cherry", "Cotton candy", "Flare", "Flower", "Gold", "Grayscale", "Royal", "Sky", "Vine"}; +} diff --git a/src/main/java/keystrokesmod/utility/Utils.java b/src/main/java/keystrokesmod/utility/Utils.java index 635355f..149d40d 100644 --- a/src/main/java/keystrokesmod/utility/Utils.java +++ b/src/main/java/keystrokesmod/utility/Utils.java @@ -14,6 +14,7 @@ import keystrokesmod.module.impl.player.Freecam; import keystrokesmod.module.impl.render.HUD; import keystrokesmod.module.impl.world.AntiBot; import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.script.ScriptDefaults; import net.minecraft.block.*; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; @@ -30,6 +31,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.init.Items; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.item.*; @@ -77,6 +79,58 @@ public class Utils { private static int darkGray = new Color(63, 63, 63).getRGB(); private static int black = new Color(17, 17, 17).getRGB(); + public static boolean sneakState; + + public static void setSneak(boolean state) { + KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), state); + mc.thePlayer.setSneaking(state); + sneakState = state; + } + + public static boolean isMining() { + return tabbedIn() && Mouse.isButtonDown(0) && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.objectMouseOver.getBlockPos() != null; + } + + public static void print(Object s) { + sendRawMessage(String.valueOf(s)); + } + + public static void modulePrint(Object s) { + sendRawMessage(String.valueOf(s)); + } + + public static void ping() { + mc.thePlayer.playSound("note.pling", 1.0f, 1.0f); + } + + public static boolean holdingTNT() { + if (mc.thePlayer.getHeldItem() == null) { + return false; + } + return mc.thePlayer.getHeldItem().getDisplayName().contains("TNT"); + } + + public static float toPositive(float val) { + if (val < 0.0F) { + return (((-val) * (-2)) - val); + } + return val; + } + + public static boolean sneakDown() { + return Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode()); + } + + public static void rsa() { + EntityPlayerSP p = mc.thePlayer; + int armSwingEnd = p.isPotionActive(Potion.digSpeed) ? 6 - (1 + p.getActivePotionEffect(Potion.digSpeed).getAmplifier()) : (p.isPotionActive(Potion.digSlowdown) ? 6 + (1 + p.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6); + if (!p.isSwingInProgress || p.swingProgressInt >= armSwingEnd / 2 || p.swingProgressInt < 0) { + p.swingProgressInt = -1; + p.isSwingInProgress = true; + } + + } + public static boolean addEnemy(String name) { if (enemies.add(name.toLowerCase())) { Utils.sendMessage("&7Added enemy&7: &b" + name); @@ -159,17 +213,17 @@ public class Utils { Utils.sendMessage("&eattacking: &r" + ent.getName()); Utils.sendMessage("&7type: &b" + ent.getClass().getSimpleName()); Utils.sendMessage("&7bot: &r" + (ModuleManager.antiBot.isEnabled() ? AntiBot.isBot(ent) : "&cantibot disabled")); - final boolean isPlayer = ent instanceof EntityPlayer; + boolean isPlayer = ent instanceof EntityPlayer; Utils.sendMessage("&7player: &r" + isPlayer); Utils.sendMessage("&7dist eye: &d" + round(getDistanceToEye(ent), 2)); Utils.sendMessage("&7min dist: &d" + round(Math.sqrt(raycastDistanceSq(ent, 12.0, false)), 2)); - final IChatComponent displayName = ent.getDisplayName(); - final boolean hasDisplayName = displayName != null; + IChatComponent displayName = ent.getDisplayName(); + boolean hasDisplayName = displayName != null; if (isPlayer) { - final EntityPlayer p = (EntityPlayer)ent; - final UUID uuid = p.getUniqueID(); + EntityPlayer p = (EntityPlayer)ent; + UUID uuid = p.getUniqueID(); Utils.sendMessage("&7uuid: &d" + uuid.toString() + " &b" + uuid.variant() + " " + uuid.version()); - final NetworkPlayerInfo clientPlayer = mc.getNetHandler().getPlayerInfo(p.getUniqueID()); + NetworkPlayerInfo clientPlayer = mc.getNetHandler().getPlayerInfo(p.getUniqueID()); Utils.sendMessage("&7ping: &d" + ((clientPlayer == null) ? "&cnot found" : clientPlayer.getResponseTime())); Utils.sendMessage("&7teammate: &r" + isTeammate(p)); Utils.sendMessage("&7tablist: &r" + isInTabList(p)); @@ -189,12 +243,12 @@ public class Utils { Utils.sendMessage("&7dead: &r" + ent.isDead); } - public static double raycastDistanceSq(final Entity en, final double max_reach, final boolean calc_rot) { - final Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); + public static double raycastDistanceSq(Entity en, double max_reach, boolean calc_rot) { + Vec3 eyeVec = mc.thePlayer.getPositionEyes(1.0f); float yaw; float pitch; if (calc_rot) { - final float[] rot = RotationUtils.getRotations(en); + float[] rot = RotationUtils.getRotations(en); yaw = rot[0]; pitch = rot[1]; } @@ -202,23 +256,23 @@ public class Utils { yaw = mc.thePlayer.rotationYaw; pitch = mc.thePlayer.rotationPitch; } - final float ff = MathHelper.cos(-yaw * 0.017453292f - 3.1415927f); - final float ff2 = MathHelper.sin(-yaw * 0.017453292f - 3.1415927f); - final float ff3 = -MathHelper.cos(-pitch * 0.017453292f); - final float ff4 = MathHelper.sin(-pitch * 0.017453292f); - final Vec3 lookVec = new Vec3((double)(ff2 * ff3), (double)ff4, (double)(ff * ff3)); - final double lookVecX = lookVec.xCoord * max_reach; - final double lookVecY = lookVec.yCoord * max_reach; - final double lookVecZ = lookVec.zCoord * max_reach; - final Vec3 sumVec = eyeVec.addVector(lookVecX, lookVecY, lookVecZ); - final List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), mc.getRenderViewEntity().getEntityBoundingBox().addCoord(lookVecX, lookVecY, lookVecZ).expand(1.0, 1.0, 1.0)); + float ff = MathHelper.cos(-yaw * 0.017453292f - 3.1415927f); + float ff2 = MathHelper.sin(-yaw * 0.017453292f - 3.1415927f); + float ff3 = -MathHelper.cos(-pitch * 0.017453292f); + float ff4 = MathHelper.sin(-pitch * 0.017453292f); + Vec3 lookVec = new Vec3((double)(ff2 * ff3), (double)ff4, (double)(ff * ff3)); + double lookVecX = lookVec.xCoord * max_reach; + double lookVecY = lookVec.yCoord * max_reach; + double lookVecZ = lookVec.zCoord * max_reach; + Vec3 sumVec = eyeVec.addVector(lookVecX, lookVecY, lookVecZ); + List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.getRenderViewEntity(), mc.getRenderViewEntity().getEntityBoundingBox().addCoord(lookVecX, lookVecY, lookVecZ).expand(1.0, 1.0, 1.0)); for (int i = 0; i < list.size(); ++i) { - final Entity entity = (Entity)list.get(i); + Entity entity = (Entity)list.get(i); if (entity == en) { if (entity.canBeCollidedWith()) { - final float cbs = entity.getCollisionBorderSize(); - final AxisAlignedBB axis = entity.getEntityBoundingBox().expand((double)cbs, (double)cbs, (double)cbs); - final MovingObjectPosition mop = axis.calculateIntercept(eyeVec, sumVec); + float cbs = entity.getCollisionBorderSize(); + AxisAlignedBB axis = entity.getEntityBoundingBox().expand((double)cbs, (double)cbs, (double)cbs); + MovingObjectPosition mop = axis.calculateIntercept(eyeVec, sumVec); if (mop != null) { return eyeVec.squareDistanceTo(mop.hitVec); } @@ -228,11 +282,11 @@ public class Utils { return -1.0; } - public static double getDistanceToEye(final Entity en) { + public static double getDistanceToEye(Entity en) { return mc.thePlayer.getPositionEyes(1.0f).distanceTo(en.getPositionEyes(1.0f)); } - public static boolean isInTabList(final EntityPlayer p) { + public static boolean isInTabList(EntityPlayer p) { for (NetworkPlayerInfo playerInfo : mc.getNetHandler().getPlayerInfoMap()) { if (playerInfo.getGameProfile().equals(p.getGameProfile())) { return true; @@ -325,18 +379,25 @@ public class Utils { return -1; } - public static boolean overVoid(double posX, double posY, double posZ) { - for (int i = (int) posY; i > -1; i--) { - if (!(mc.theWorld.getBlockState(new BlockPos(posX, i, posZ)).getBlock() instanceof BlockAir)) { + public static int getHurttime(Entity entity) { + if (!(entity instanceof EntityLivingBase)) { + return -1; + } + return ((EntityLivingBase) entity).hurtTime; + } + + public static boolean overVoid() { + for (int i = (int) mc.thePlayer.posY; i > -1; i--) { + if (!(mc.theWorld.getBlockState(new BlockPos(mc.thePlayer.posX, i, mc.thePlayer.posZ)).getBlock() instanceof BlockAir)) { return false; } } return true; } - public static boolean overVoid() { - for (int i = (int) mc.thePlayer.posY; i > -1; i--) { - if (!(mc.theWorld.getBlockState(new BlockPos(mc.thePlayer.posX, i, mc.thePlayer.posZ)).getBlock() instanceof BlockAir)) { + public static boolean overVoid(double posX, double posY, double posZ) { + for (int i = (int) posY; i > -1; i--) { + if (!(mc.theWorld.getBlockState(new BlockPos(posX, i, posZ)).getBlock() instanceof BlockAir)) { return false; } } @@ -387,7 +448,7 @@ public class Utils { } public static List getTablist(boolean removeSelf) { - final ArrayList list = new ArrayList<>(mc.getNetHandler().getPlayerInfoMap()); + ArrayList list = new ArrayList<>(mc.getNetHandler().getPlayerInfoMap()); removeDuplicates(list); if (removeSelf) { list.remove(mc.getNetHandler().getPlayerInfo(mc.thePlayer.getUniqueID())); @@ -692,7 +753,7 @@ public class Utils { } public static boolean isHypixel() { - return !mc.isSingleplayer() && mc.getCurrentServerData() != null && (mc.getCurrentServerData().serverIP.equals("hypixel.net") || mc.getCurrentServerData().serverIP.contains(".hypixel.net")); + return !mc.isSingleplayer() && mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("hypixel.net"); } public static String getHitsToKillStr(final EntityPlayer entityPlayer, final ItemStack itemStack) { @@ -792,13 +853,6 @@ public class Utils { return false; } - public static boolean usingBedAura() { - if (ModuleManager.bedAura != null && ModuleManager.bedAura.currentBlock != null && RotationUtils.inRange(ModuleManager.bedAura.currentBlock, ModuleManager.bedAura.range.getInput())) { - return true; - } - return false; - } - public static String getNetworkDisplayName() { try { NetworkPlayerInfo playerInfo = mc.getNetHandler().getPlayerInfo(mc.thePlayer.getUniqueID()); @@ -808,14 +862,6 @@ public class Utils { return ""; } - public static float getLastReportedYaw() { - return ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw(); - } - - public static float getLastReportedPitch() { - return ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedPitch(); - } - public static void setSpeed(double n) { if (n == 0.0) { mc.thePlayer.motionZ = 0.0; @@ -827,10 +873,6 @@ public class Utils { mc.thePlayer.motionZ = Math.cos(n3) * n; } - public static net.minecraft.util.Timer getTimer() { - return ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "timer", "field_71428_T"); - } - public static void resetTimer() { ((IAccessorMinecraft) mc).getTimer().timerSpeed = 1.0F; } @@ -842,10 +884,6 @@ public class Utils { return (mc.currentScreen != null) && (mc.thePlayer.inventoryContainer != null) && (mc.thePlayer.inventoryContainer instanceof ContainerPlayer) && (mc.currentScreen instanceof GuiInventory); } - public static boolean safeWalkBackwards() { - return ModuleManager.safeWalk.canSafeWalk() && mc.thePlayer.moveForward <= -0.5 && mc.thePlayer.moveStrafing == 0; - } - public static int getSkyWarsStatus() { List sidebar = Utils.getSidebarLines(); if (sidebar == null || sidebar.isEmpty()) { @@ -916,14 +954,6 @@ public class Utils { return validated.toString(); } - public static void print(String s) { - sendRawMessage(s); - } - - public static long time() { - return System.currentTimeMillis(); - } - public static List getSidebarLines() { final List lines = new ArrayList<>(); if (mc.theWorld == null) { @@ -984,10 +1014,23 @@ public class Utils { mc.thePlayer.rotationPitch = p; } } - } } + public static float getAngleDifference(float from, float to) { + float difference = (to - from) % 360.0F; + if (difference < -180.0F) { + difference += 360.0F; + } else if (difference >= 180.0F) { + difference -= 360.0F; + } + return difference; + } + + public static float getPitchDifference(float from, float to) { + return (to - from) % 90.0F; + } + public static float[] getRotationsOld(Entity q) { if (q == null) { return null; @@ -1071,13 +1114,6 @@ public class Utils { } } - public static boolean holdingTNT() { - if (mc.thePlayer.getHeldItem() == null) { - return false; - } - return mc.thePlayer.getHeldItem().getDisplayName().contains("TNT"); - } - public static boolean keysDown() { return Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode()) || Keyboard.isKeyDown(mc.gameSettings.keyBindBack.getKeyCode()) || Keyboard.isKeyDown(mc.gameSettings.keyBindLeft.getKeyCode()) || Keyboard.isKeyDown(mc.gameSettings.keyBindRight.getKeyCode()); } @@ -1086,45 +1122,17 @@ public class Utils { return Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode()); } - public static void handleTimer(int color, int ticks) { - color = Theme.getGradient((int) HUD.theme.getInput(), 0); - int widthOffset = (ticks < 10) ? 4 : (ticks >= 10 && ticks < 100) ? 7 : (ticks >= 100 && ticks < 1000) ? 10 : (ticks >= 1000) ? 13 : 16; - String text = ("" + ticks); - int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; - final ScaledResolution scaledResolution = new ScaledResolution(mc); - int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; - mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + public static boolean usingBedAura() { + if (ModuleManager.bedAura != null && ModuleManager.bedAura.currentBlock != null && RotationUtils.inRange(ModuleManager.bedAura.currentBlock, ModuleManager.bedAura.range.getInput())) { + return true; + } + return false; } - public static boolean sneakDown() { - return Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode()); - } - - public static double fallDist() { - if (overVoid()) { - return 9999; - } - double fallDistance = -1; - double y = mc.thePlayer.posY; - if (mc.thePlayer.posY % 1 == 0) { - y--; - } - for (int i = (int) Math.floor(y); i > -1; i--) { - if (!isPlaceable(new BlockPos(mc.thePlayer.posX, i, mc.thePlayer.posZ))) { - fallDistance = y - i; - break; - } - } - return fallDistance - 1; - } - - public static double fallDistZ() { + public static double distanceToGround() { if (mc.thePlayer.onGround) { return 0; } - if (overVoid()) { - return 9999; - } double fallDistance = -1; double y = mc.thePlayer.posY; if (mc.thePlayer.posY % 1 == 0) { @@ -1139,7 +1147,6 @@ public class Utils { return fallDistance - 1; } - public static double distanceToGround(Entity entity) { if (entity.onGround) { return 0; @@ -1203,10 +1210,6 @@ public class Utils { return yw; } - public static boolean isMining() { - return tabbedIn() && Mouse.isButtonDown(0) && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.objectMouseOver.getBlockPos() != null; - } - public static float ae(float n, float n2, float n3) { float n4 = 1.0f; if (n2 < 0.0f) { @@ -1340,6 +1343,32 @@ public class Utils { return mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.objectMouseOver.getBlockPos() != null; } + public static class keybinds { + public static int[] getMousePosition() { + return new int[] { Mouse.getX(), Mouse.getY() }; + } + + public static int getKeyCode(String key) { + return Keyboard.getKeyIndex(key); + } + + public static boolean isMouseDown(int mouseButton) { + return Mouse.isButtonDown(mouseButton); + } + + public static boolean isKeyDown(int key) { + return Keyboard.isKeyDown(key); + } + + public static void rightClick() { + ((IAccessorMinecraft) mc).callRightClickMouse(); + } + + public static void leftClick() { + ((IAccessorMinecraft) mc).callClickMouse(); + } + } + public static boolean isDiagonal(boolean strict) { float yaw = ((mc.thePlayer.rotationYaw % 360) + 360) % 360; yaw = yaw > 180 ? yaw - 360 : yaw; @@ -1378,6 +1407,49 @@ public class Utils { } } + public static double fallDist() { + if (overVoid()) { + return 9999; + } + double fallDistance = -1; + double y = mc.thePlayer.posY; + if (mc.thePlayer.posY % 1 == 0) { + y--; + } + for (int i = (int) Math.floor(y); i > -1; i--) { + if (!isPlaceable(new BlockPos(mc.thePlayer.posX, i, mc.thePlayer.posZ))) { + fallDistance = y - i; + break; + } + } + return fallDistance - 1; + } + + public static double fallDistZ() { + if (mc.thePlayer.onGround) { + return 0; + } + if (overVoid()) { + return 9999; + } + double fallDistance = -1; + double y = mc.thePlayer.posY; + if (mc.thePlayer.posY % 1 == 0) { + y--; + } + for (int i = (int) Math.floor(y); i > -1; i--) { + if (!isPlaceable(new BlockPos(mc.thePlayer.posX, i, mc.thePlayer.posZ))) { + fallDistance = y - i; + break; + } + } + return fallDistance - 1; + } + + public static long time() { + return System.currentTimeMillis(); + } + public static boolean isEdgeOfBlock() { BlockPos pos = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - ((mc.thePlayer.posY % 1.0 == 0.0) ? 1 : 0), mc.thePlayer.posZ); return mc.theWorld.isAirBlock(pos); @@ -1391,6 +1463,51 @@ public class Utils { sendRawMessage("&3" + module.getName() + "&7: &r" + s); } + public static int getLobbyStatus() { + if (!Utils.nullCheck()) { + return -1; + } + final Scoreboard scoreboard = mc.theWorld.getScoreboard(); + if (scoreboard == null) { + return -1; + } + final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + if (objective == null) { + return -1; + } + for (String line : getSidebarLines()) { + line = stripString(line); + String[] parts = line.split(" "); + if (parts.length > 1) { + if (parts[1].startsWith("L")) { + return 1; + } + } + } + return -1; + } + + public static int hypixelStatus() { + if (!Utils.nullCheck()) { + return -1; + } + final Scoreboard scoreboard = mc.theWorld.getScoreboard(); + if (scoreboard == null) { + return -2; + } + final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + if (objective == null) { + return -1; + } + for (String line : getSidebarLines()) { + line = stripString(line); + if (line.startsWith("0") || line.startsWith("1")) { + return 1; + } + } + return -1; + } + public static EntityLivingBase raytrace(int range) { Entity entity = null; EntityPlayer self = (Freecam.freeEntity == null) ? mc.thePlayer : Freecam.freeEntity; @@ -1531,12 +1648,11 @@ public class Utils { } } - public static void rsa() { - EntityPlayerSP p = mc.thePlayer; - int armSwingEnd = p.isPotionActive(Potion.digSpeed) ? 6 - (1 + p.getActivePotionEffect(Potion.digSpeed).getAmplifier()) : (p.isPotionActive(Potion.digSlowdown) ? 6 + (1 + p.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6); - if (!p.isSwingInProgress || p.swingProgressInt >= armSwingEnd / 2 || p.swingProgressInt < 0) { - p.swingProgressInt = -1; - p.isSwingInProgress = true; + public static void setSwinging() { + int armSwingEnd = mc.thePlayer.isPotionActive(Potion.digSpeed) ? 6 - (1 + mc.thePlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier()) : (mc.thePlayer.isPotionActive(Potion.digSlowdown) ? 6 + (1 + mc.thePlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6); + if (!mc.thePlayer.isSwingInProgress || mc.thePlayer.swingProgressInt >= armSwingEnd / 2 || mc.thePlayer.swingProgressInt < 0) { + mc.thePlayer.swingProgressInt = -1; + mc.thePlayer.isSwingInProgress = true; } } @@ -1572,6 +1688,13 @@ public class Utils { return mc.thePlayer.getHeldItem().getItem() instanceof ItemSword; } + public static boolean holdingFishingRod() { + if (mc.thePlayer.getHeldItem() == null) { + return false; + } + return mc.thePlayer.getHeldItem().getItem() instanceof ItemFishingRod; + } + public static double getDamageLevel(ItemStack itemStack) { double baseDamage = 0.0; if (itemStack != null) { @@ -1587,32 +1710,6 @@ public class Utils { return baseDamage + sharp_level * 1.25 + (fire_level * 4 - 1); } - public static class keybinds { - public static int[] getMousePosition() { - return new int[] { Mouse.getX(), Mouse.getY() }; - } - - public static int getKeyCode(String key) { - return Keyboard.getKeyIndex(key); - } - - public static boolean isMouseDown(int mouseButton) { - return Mouse.isButtonDown(mouseButton); - } - - public static boolean isKeyDown(int key) { - return Keyboard.isKeyDown(key); - } - - public static void rightClick() { - ((IAccessorMinecraft) mc).callRightClickMouse(); - } - - public static void leftClick() { - ((IAccessorMinecraft) mc).callClickMouse(); - } - } - public static float getDirection() { return getCustomDirection(mc.thePlayer.rotationYaw, mc.thePlayer.movementInput.moveForward, mc.thePlayer.movementInput.moveStrafe); } @@ -1621,6 +1718,28 @@ public class Utils { return mc.thePlayer.movementInput.moveForward != 0.0f || mc.thePlayer.movementInput.moveStrafe != 0.0f; } + public static net.minecraft.util.Timer getTimer() { + return ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "timer", "field_71428_T"); + } + + public static void handleTimer(int color, int ticks) { + color = Theme.getGradient((int) HUD.theme.getInput(), 0); + int widthOffset = (ticks < 10) ? 4 : (ticks >= 10 && ticks < 100) ? 7 : (ticks >= 100 && ticks < 1000) ? 10 : (ticks >= 1000) ? 13 : 16; + String text = ("" + ticks); + int width = mc.fontRendererObj.getStringWidth(text) + Utils.getBoldWidth(text) / 2; + final ScaledResolution scaledResolution = new ScaledResolution(mc); + int[] display = {scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()}; + mc.fontRendererObj.drawString(text, display[0] / 2 - width + widthOffset, display[1] / 2 + 8, color, true); + } + + public static float getLastReportedYaw() { + return ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw(); + } + + public static boolean safeWalkBackwards() { + return ModuleManager.safeWalk.canSafeWalk() && mc.thePlayer.moveForward <= -0.5 && mc.thePlayer.moveStrafing == 0; + } + public static float getCustomDirection(float yaw, final float moveForward, final float moveStrafe) { float forward = 1.0f; if (moveForward < 0.0f) { @@ -1639,69 +1758,6 @@ public class Utils { return yaw * 0.017453292f; } - public static int getLobbyStatus() { - if (!Utils.nullCheck()) { - return -1; - } - final Scoreboard scoreboard = mc.theWorld.getScoreboard(); - if (scoreboard == null) { - return -1; - } - final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - if (objective == null) { - return -1; - } - for (String line : getSidebarLines()) { - line = stripString(line); - String[] parts = line.split(" "); - if (parts.length > 1) { - if (parts[1].startsWith("L")) { - return 1; - } - } - } - return -1; - } - - public static int hypixelStatus() { - if (!Utils.nullCheck()) { - return -1; - } - final Scoreboard scoreboard = mc.theWorld.getScoreboard(); - if (scoreboard == null) { - return -2; - } - final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - if (objective == null) { - return -1; - } - for (String line : getSidebarLines()) { - line = stripString(line); - if (line.startsWith("0") || line.startsWith("1")) { - return 1; - } - } - return -1; - } - - public static boolean isReplay() { - if (Utils.isHypixel()) { - if (!Utils.nullCheck()) { - return false; - } - final Scoreboard scoreboard = mc.theWorld.getScoreboard(); - if (scoreboard == null) { - return false; - } - final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - if (objective == null || !stripString(objective.getDisplayName()).contains("REPLAY")) { - return false; - } - return true; - } - return false; - } - public static boolean canBePlaced(ItemBlock itemBlock) { Block block = itemBlock.getBlock(); if (block == null) { @@ -1733,9 +1789,6 @@ public class Utils { if (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && ModuleManager.scaffold.autoSwap.isToggled() && ModuleManager.autoSwap.spoofItem.isToggled() && mc.thePlayer != null) { return mc.thePlayer.inventory.getStackInSlot(ModuleManager.scaffold.lastSlot.get() == -1 ? mc.thePlayer.inventory.currentItem : ModuleManager.scaffold.lastSlot.get()); } - if (ModuleManager.LongJump != null && ModuleManager.LongJump.isEnabled() && ModuleManager.LongJump.spoofItem.isToggled() && mc.thePlayer != null) { - return mc.thePlayer.inventory.getStackInSlot(ModuleManager.LongJump.spoofSlot == -1 ? mc.thePlayer.inventory.currentItem : ModuleManager.LongJump.lastSlot); - } if (ModuleManager.autoTool != null && ModuleManager.autoTool.isEnabled() && ModuleManager.autoTool.spoofItem.isToggled() && mc.thePlayer != null) { return mc.thePlayer.inventory.getStackInSlot(ModuleManager.autoTool.previousSlot == -1 ? mc.thePlayer.inventory.currentItem : ModuleManager.autoTool.previousSlot); } @@ -1781,24 +1834,6 @@ public class Utils { return false; } - public static boolean isBedwarsPractice() { - if (Utils.isHypixel()) { - if (!Utils.nullCheck()) { - return false; - } - final Scoreboard scoreboard = mc.theWorld.getScoreboard(); - if (scoreboard == null) { - return false; - } - final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - if (objective == null || !stripString(objective.getDisplayName()).contains("BED WARS PRACTICE")) { - return false; - } - return true; - } - return false; - } - public static boolean isBedwarsPracticeOrReplay() { if (Utils.isHypixel()) { if (!Utils.nullCheck()) { @@ -1820,4 +1855,40 @@ public class Utils { } return false; } + + public static boolean isReplay() { + if (Utils.isHypixel()) { + if (!Utils.nullCheck()) { + return false; + } + final Scoreboard scoreboard = mc.theWorld.getScoreboard(); + if (scoreboard == null) { + return false; + } + final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + if (objective == null || !stripString(objective.getDisplayName()).contains("REPLAY")) { + return false; + } + return true; + } + return false; + } + + public static boolean isBedwarsPractice() { + if (Utils.isHypixel()) { + if (!Utils.nullCheck()) { + return false; + } + final Scoreboard scoreboard = mc.theWorld.getScoreboard(); + if (scoreboard == null) { + return false; + } + final ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + if (objective == null || !stripString(objective.getDisplayName()).contains("BED WARS PRACTICE")) { + return false; + } + return true; + } + return false; + } } diff --git a/src/main/java/keystrokesmod/utility/command/Command.java b/src/main/java/keystrokesmod/utility/command/Command.java index 2071f09..499b39e 100644 --- a/src/main/java/keystrokesmod/utility/command/Command.java +++ b/src/main/java/keystrokesmod/utility/command/Command.java @@ -1,42 +1,42 @@ -package keystrokesmod.utility.command; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; - -import java.util.ArrayList; -import java.util.List; - -public abstract class Command { - protected String command; - protected String[] alias; - public Minecraft mc = Minecraft.getMinecraft(); - - public Command(String command, String[] alias) { - this.command = command; - this.alias = alias; - } - - public Command(String command) { - this.command = command; - this.alias = new String[]{command}; - } - - public abstract void onExecute(String[] args); - - public List tabComplete(String[] args) { - return new ArrayList<>(); - } - - protected void chatWithPrefix(String msg) { - Utils.sendMessage("&7[&f" + this.command + "&7] &r" + (ModuleManager.lowercaseChatCommands() ? msg.toLowerCase() : msg)); - } - - protected void chat(String msg) { - Utils.sendMessage(ModuleManager.lowercaseChatCommands() ? msg.toLowerCase() : msg); - } - - protected void syntaxError() { - Utils.sendMessage("§cSyntax error"); - } -} +package keystrokesmod.utility.command; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; + +import java.util.ArrayList; +import java.util.List; + +public abstract class Command { + protected String command; + protected String[] alias; + public Minecraft mc = Minecraft.getMinecraft(); + + public Command(String command, String[] alias) { + this.command = command; + this.alias = alias; + } + + public Command(String command) { + this.command = command; + this.alias = new String[]{command}; + } + + public abstract void onExecute(String[] args); + + public List tabComplete(String[] args) { + return new ArrayList<>(); + } + + protected void chatWithPrefix(String msg) { + Utils.sendMessage("&7[&f" + this.command + "&7] &r" + (ModuleManager.lowercaseChatCommands() ? msg.toLowerCase() : msg)); + } + + protected void chat(String msg) { + Utils.sendMessage(ModuleManager.lowercaseChatCommands() ? msg.toLowerCase() : msg); + } + + protected void syntaxError() { + Utils.sendMessage("§cSyntax error"); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/CommandManager.java b/src/main/java/keystrokesmod/utility/command/CommandManager.java index 4d00225..ec86ca4 100644 --- a/src/main/java/keystrokesmod/utility/command/CommandManager.java +++ b/src/main/java/keystrokesmod/utility/command/CommandManager.java @@ -1,99 +1,99 @@ -package keystrokesmod.utility.command; - -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.impl.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class CommandManager { - private List commands = new ArrayList<>(); - public String[] latestAutoComplete = new String[]{}; - - public static Status status; - - public CommandManager() { - registerCommand(new Help()); - registerCommand(new Ping()); - registerCommand(new Name()); - registerCommand(new Binds()); - registerCommand(new Cname()); - registerCommand(new Debug()); - registerCommand(new Friend()); - registerCommand(new Enemy()); - registerCommand(new Profiles()); - registerCommand(new Q()); - registerCommand(new QList()); - registerCommand(new Status()); - registerCommand(new SpammerUtil()); - registerCommand(new StopSpammer()); - } - - public void executeCommand(String input) { - String[] args = input.split(" "); - for (Command command : commands) { - if (args[0].equalsIgnoreCase("." + command.command)) { - command.onExecute(args); - return; - } - - if (command.alias == null || command.alias.length == 0) { - continue; - } - - for (String alias : command.alias) { - if (args[0].equalsIgnoreCase("." + alias)) { - command.onExecute(args); - return; - } - } - } - - Utils.sendMessage("§cUnknown command. Use .help for a list of commands."); - } - - public boolean autoComplete(String input) { - String[] completions = getCompletions(input); - this.latestAutoComplete = completions != null ? completions : new String[]{}; - return input.startsWith(".") && this.latestAutoComplete.length > 0; - } - - private String[] getCompletions(String input) { - if (!input.isEmpty() && input.charAt(0) == '.') { - String[] args = input.split(" "); - - if (args.length > 1) { - Command command = getCommand(args[0].substring(1)); - if (command != null) { - List tabCompletions = command.tabComplete(Arrays.copyOfRange(args, 1, args.length)); - return tabCompletions.toArray(new String[0]); - } - } else { - String rawInput = input.substring(1); - List completions = new ArrayList<>(); - for (Command command : commands) { - if (command.command.startsWith(rawInput) || Arrays.stream(command.alias).anyMatch(alias -> alias.startsWith(rawInput))) { - String alias = command.command.startsWith(rawInput) ? command.command : Arrays.stream(command.alias).filter(aliaz -> aliaz.startsWith(rawInput)).findFirst().orElse(""); - completions.add("." + alias); - } - } - return completions.toArray(new String[0]); - } - } - return null; - } - - private Command getCommand(String name) { - for (Command cmd : commands) { - if (cmd.command.equalsIgnoreCase(name) || Arrays.stream(cmd.alias).anyMatch(alias -> alias.equalsIgnoreCase(name))) { - return cmd; - } - } - return null; - } - - public void registerCommand(Command command) { - commands.add(command); - } -} +package keystrokesmod.utility.command; + +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.impl.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CommandManager { + private List commands = new ArrayList<>(); + public String[] latestAutoComplete = new String[]{}; + + public static Status status; + + public CommandManager() { + registerCommand(new Help()); + registerCommand(new Ping()); + registerCommand(new Name()); + registerCommand(new Binds()); + registerCommand(new Cname()); + registerCommand(new Debug()); + registerCommand(new Friend()); + registerCommand(new Enemy()); + registerCommand(new Profiles()); + registerCommand(new Q()); + registerCommand(new QList()); + registerCommand(new Status()); + registerCommand(new SpammerUtil()); + registerCommand(new StopSpammer()); + } + + public void executeCommand(String input) { + String[] args = input.split(" "); + for (Command command : commands) { + if (args[0].equalsIgnoreCase("." + command.command)) { + command.onExecute(args); + return; + } + + if (command.alias == null || command.alias.length == 0) { + continue; + } + + for (String alias : command.alias) { + if (args[0].equalsIgnoreCase("." + alias)) { + command.onExecute(args); + return; + } + } + } + + Utils.sendMessage("§cUnknown command. Use .help for a list of commands."); + } + + public boolean autoComplete(String input) { + String[] completions = getCompletions(input); + this.latestAutoComplete = completions != null ? completions : new String[]{}; + return input.startsWith(".") && this.latestAutoComplete.length > 0; + } + + private String[] getCompletions(String input) { + if (!input.isEmpty() && input.charAt(0) == '.') { + String[] args = input.split(" "); + + if (args.length > 1) { + Command command = getCommand(args[0].substring(1)); + if (command != null) { + List tabCompletions = command.tabComplete(Arrays.copyOfRange(args, 1, args.length)); + return tabCompletions.toArray(new String[0]); + } + } else { + String rawInput = input.substring(1); + List completions = new ArrayList<>(); + for (Command command : commands) { + if (command.command.startsWith(rawInput) || Arrays.stream(command.alias).anyMatch(alias -> alias.startsWith(rawInput))) { + String alias = command.command.startsWith(rawInput) ? command.command : Arrays.stream(command.alias).filter(aliaz -> aliaz.startsWith(rawInput)).findFirst().orElse(""); + completions.add("." + alias); + } + } + return completions.toArray(new String[0]); + } + } + return null; + } + + private Command getCommand(String name) { + for (Command cmd : commands) { + if (cmd.command.equalsIgnoreCase(name) || Arrays.stream(cmd.alias).anyMatch(alias -> alias.equalsIgnoreCase(name))) { + return cmd; + } + } + return null; + } + + public void registerCommand(Command command) { + commands.add(command); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Binds.java b/src/main/java/keystrokesmod/utility/command/impl/Binds.java index 7bf9ba5..c749289 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Binds.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Binds.java @@ -1,96 +1,96 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.Raven; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.command.Command; -import keystrokesmod.utility.profile.Profile; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Binds extends Command { - public Binds() { - super("binds"); - } - - @Override - public void onExecute(String[] args) { - if (args.length <= 1) { - Map> binds = getBindsModulesMap(0); - int size = getTotalModules(binds); - chatWithPrefix("&b" + size + " &7module" + (size == 1 ? "" : "s") + " have keybinds."); - for (Map.Entry> entry : binds.entrySet()) { - String key = entry.getKey(); - List moduleNames = entry.getValue(); - for (String moduleName : moduleNames) { - chatWithPrefix(" &b" + key + " &7" + moduleName); - } - } - } - else if (args.length == 2) { - int keycode = Keyboard.getKeyIndex(args[1].toUpperCase()); - if (keycode == 0) { - chatWithPrefix("&7Invalid key."); - return; - } - - Map> binds = getBindsModulesMap(keycode); - int size = getTotalModules(binds); - chatWithPrefix("&b" + size + " &7module" + (size == 1 ? "" : "s") + " has keybind &b" + args[1].toUpperCase() + "&7."); - - for (Map.Entry> entry : binds.entrySet()) { - String key = entry.getKey(); - List moduleNames = entry.getValue(); - for (String moduleName : moduleNames) { - chatWithPrefix(" &b" + key + " &7" + moduleName); - } - } - } - else { - syntaxError(); - } - } - - private Map> getBindsModulesMap(int keycode) { - Map> binds = new HashMap<>(); - for (Module module : ModuleManager.modules) { - addModuleIfMatches(binds, module, keycode); - } - for (Profile profile : Raven.profileManager.profiles) { - Module module = profile.getModule(); - addModuleIfMatches(binds, module, keycode); - } - for (Module scriptModule : Raven.scriptManager.scripts.values()) { - addModuleIfMatches(binds, scriptModule, keycode); - } - return binds; - } - - private void addModuleIfMatches(Map> bindsMap, Module module, int keycode) { - if (module.getKeycode() == 0) { - return; - } - if (keycode != 0 && module.getKeycode() != keycode) { - return; - } - String keyName = (module.getKeycode() >= 1000) ? "M" + (module.getKeycode() - 1000) : Keyboard.getKeyName(module.getKeycode()); - List moduleNames = bindsMap.get(keyName); - if (moduleNames == null) { - moduleNames = new ArrayList<>(); - bindsMap.put(keyName, moduleNames); - } - moduleNames.add(module.getName()); - } - - private int getTotalModules(Map> binds) { - int total = 0; - for (List modules : binds.values()) { - total += modules.size(); - } - return total; - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.Raven; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.command.Command; +import keystrokesmod.utility.profile.Profile; +import org.lwjgl.input.Keyboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Binds extends Command { + public Binds() { + super("binds"); + } + + @Override + public void onExecute(String[] args) { + if (args.length <= 1) { + Map> binds = getBindsModulesMap(0); + int size = getTotalModules(binds); + chatWithPrefix("&b" + size + " &7module" + (size == 1 ? "" : "s") + " have keybinds."); + for (Map.Entry> entry : binds.entrySet()) { + String key = entry.getKey(); + List moduleNames = entry.getValue(); + for (String moduleName : moduleNames) { + chatWithPrefix(" &b" + key + " &7" + moduleName); + } + } + } + else if (args.length == 2) { + int keycode = Keyboard.getKeyIndex(args[1].toUpperCase()); + if (keycode == 0) { + chatWithPrefix("&7Invalid key."); + return; + } + + Map> binds = getBindsModulesMap(keycode); + int size = getTotalModules(binds); + chatWithPrefix("&b" + size + " &7module" + (size == 1 ? "" : "s") + " has keybind &b" + args[1].toUpperCase() + "&7."); + + for (Map.Entry> entry : binds.entrySet()) { + String key = entry.getKey(); + List moduleNames = entry.getValue(); + for (String moduleName : moduleNames) { + chatWithPrefix(" &b" + key + " &7" + moduleName); + } + } + } + else { + syntaxError(); + } + } + + private Map> getBindsModulesMap(int keycode) { + Map> binds = new HashMap<>(); + for (Module module : ModuleManager.modules) { + addModuleIfMatches(binds, module, keycode); + } + for (Profile profile : Raven.profileManager.profiles) { + Module module = profile.getModule(); + addModuleIfMatches(binds, module, keycode); + } + for (Module scriptModule : Raven.scriptManager.scripts.values()) { + addModuleIfMatches(binds, scriptModule, keycode); + } + return binds; + } + + private void addModuleIfMatches(Map> bindsMap, Module module, int keycode) { + if (module.getKeycode() == 0) { + return; + } + if (keycode != 0 && module.getKeycode() != keycode) { + return; + } + String keyName = (module.getKeycode() >= 1000) ? "M" + (module.getKeycode() - 1000) : Keyboard.getKeyName(module.getKeycode()); + List moduleNames = bindsMap.get(keyName); + if (moduleNames == null) { + moduleNames = new ArrayList<>(); + bindsMap.put(keyName, moduleNames); + } + moduleNames.add(module.getName()); + } + + private int getTotalModules(Map> binds) { + int total = 0; + for (List modules : binds.values()) { + total += modules.size(); + } + return total; + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Cname.java b/src/main/java/keystrokesmod/utility/command/impl/Cname.java index 2a3f82e..3580f64 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Cname.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Cname.java @@ -1,21 +1,21 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.module.impl.other.NameHider; -import keystrokesmod.utility.command.Command; - -public class Cname extends Command { - public Cname() { - super("cname"); - } - - @Override - public void onExecute(String[] args) { - if (args.length == 2) { - NameHider.fakeName = args[1]; - chatWithPrefix("&7Name has been set to &b" + NameHider.fakeName + "&7."); - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.module.impl.other.NameHider; +import keystrokesmod.utility.command.Command; + +public class Cname extends Command { + public Cname() { + super("cname"); + } + + @Override + public void onExecute(String[] args) { + if (args.length == 2) { + NameHider.fakeName = args[1]; + chatWithPrefix("&7Name has been set to &b" + NameHider.fakeName + "&7."); + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Debug.java b/src/main/java/keystrokesmod/utility/command/impl/Debug.java index c611a5f..e996f1a 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Debug.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Debug.java @@ -1,35 +1,35 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.Raven; -import keystrokesmod.helper.DebugHelper; -import keystrokesmod.utility.command.Command; - -public class Debug extends Command { - public Debug() { - super("debug"); - } - - @Override - public void onExecute(String[] args) { - if (args.length <= 1) { - Raven.debug = !Raven.debug; - chatWithPrefix("&7Debug " + (Raven.debug ? "&aenabled" : "&cdisabled") + "&7."); - } - else if (args.length == 2) { - if (args[1].equals("mixin")) { - DebugHelper.MIXIN = !DebugHelper.MIXIN; - chatWithPrefix("&dMixin &7debug " + (DebugHelper.MIXIN ? "&aenabled" : "&cdisabled") + "&7."); - } - else if (args[1].equals("bg") || args[1].equals("background")) { - DebugHelper.BACKGROUND = !DebugHelper.BACKGROUND; - chatWithPrefix("&6Background &7debug " + (DebugHelper.BACKGROUND ? "&aenabled" : "&cdisabled") + "&7."); - } - else { - syntaxError(); - } - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.Raven; +import keystrokesmod.helper.DebugHelper; +import keystrokesmod.utility.command.Command; + +public class Debug extends Command { + public Debug() { + super("debug"); + } + + @Override + public void onExecute(String[] args) { + if (args.length <= 1) { + Raven.debug = !Raven.debug; + chatWithPrefix("&7Debug " + (Raven.debug ? "&aenabled" : "&cdisabled") + "&7."); + } + else if (args.length == 2) { + if (args[1].equals("mixin")) { + DebugHelper.MIXIN = !DebugHelper.MIXIN; + chatWithPrefix("&dMixin &7debug " + (DebugHelper.MIXIN ? "&aenabled" : "&cdisabled") + "&7."); + } + else if (args[1].equals("bg") || args[1].equals("background")) { + DebugHelper.BACKGROUND = !DebugHelper.BACKGROUND; + chatWithPrefix("&6Background &7debug " + (DebugHelper.BACKGROUND ? "&aenabled" : "&cdisabled") + "&7."); + } + else { + syntaxError(); + } + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Enemy.java b/src/main/java/keystrokesmod/utility/command/impl/Enemy.java index 79b324a..fa29e59 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Enemy.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Enemy.java @@ -1,35 +1,35 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; - -public class Enemy extends Command { - public Enemy() { - super("enemy", new String[] { "enemy", "e" }); - } - - @Override - public void onExecute(String[] args) { - if (args.length == 2) { - if (args[1].equals("clear")) { - chatWithPrefix("&b" + Utils.enemies.size() + " &7enem" + (Utils.enemies.size() == 1 ? "y" : "ies") + " cleared."); - Utils.enemies.clear(); - return; - } - - boolean added = Utils.addEnemy(args[1]); - if (!added) { - Utils.removeEnemy(args[1]); - } - } - else if (args.length == 1) { - chatWithPrefix("&b" + Utils.enemies.size() + " &7enem" + (Utils.enemies.size() == 1 ? "y" : "ies") + "."); - for (String name : Utils.enemies) { - chatWithPrefix(" &b" + name); - } - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; + +public class Enemy extends Command { + public Enemy() { + super("enemy", new String[] { "enemy", "e" }); + } + + @Override + public void onExecute(String[] args) { + if (args.length == 2) { + if (args[1].equals("clear")) { + chatWithPrefix("&b" + Utils.enemies.size() + " &7enem" + (Utils.enemies.size() == 1 ? "y" : "ies") + " cleared."); + Utils.enemies.clear(); + return; + } + + boolean added = Utils.addEnemy(args[1]); + if (!added) { + Utils.removeEnemy(args[1]); + } + } + else if (args.length == 1) { + chatWithPrefix("&b" + Utils.enemies.size() + " &7enem" + (Utils.enemies.size() == 1 ? "y" : "ies") + "."); + for (String name : Utils.enemies) { + chatWithPrefix(" &b" + name); + } + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Friend.java b/src/main/java/keystrokesmod/utility/command/impl/Friend.java index 599f37e..de9761b 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Friend.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Friend.java @@ -1,35 +1,35 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; - -public class Friend extends Command { - public Friend() { - super("friend", new String[] { "friend", "f" }); - } - - @Override - public void onExecute(String[] args) { - if (args.length == 2) { - if (args[1].equals("clear")) { - chatWithPrefix("&b" + Utils.friends.size() + " &7friend" + (Utils.friends.size() == 1 ? "" : "s") + " cleared."); - Utils.friends.clear(); - return; - } - - boolean added = Utils.addFriend(args[1]); - if (!added) { - Utils.removeFriend(args[1]); - } - } - else if (args.length == 1) { - chatWithPrefix("&b" + Utils.friends.size() + " &7friend" + (Utils.friends.size() == 1 ? "" : "s") + "."); - for (String name : Utils.friends) { - chatWithPrefix(" &b" + name); - } - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; + +public class Friend extends Command { + public Friend() { + super("friend", new String[] { "friend", "f" }); + } + + @Override + public void onExecute(String[] args) { + if (args.length == 2) { + if (args[1].equals("clear")) { + chatWithPrefix("&b" + Utils.friends.size() + " &7friend" + (Utils.friends.size() == 1 ? "" : "s") + " cleared."); + Utils.friends.clear(); + return; + } + + boolean added = Utils.addFriend(args[1]); + if (!added) { + Utils.removeFriend(args[1]); + } + } + else if (args.length == 1) { + chatWithPrefix("&b" + Utils.friends.size() + " &7friend" + (Utils.friends.size() == 1 ? "" : "s") + "."); + for (String name : Utils.friends) { + chatWithPrefix(" &b" + name); + } + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Help.java b/src/main/java/keystrokesmod/utility/command/impl/Help.java index 6a406ee..c3ae78c 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Help.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Help.java @@ -1,31 +1,31 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.command.Command; - -public class Help extends Command { - public Help() { - super("help"); - } - - @Override - public void onExecute(String[] args) { - chatWithPrefix("&7Chat commands - &dGeneral"); - chat(" &b.ign/name &7Copy your username."); - chat(" &b.ping &7Estimate your ping."); - chat(" &b.friend/enemy [name/clear] &7Adds as enemy/friend."); - chat(" &b.q [mode] &7Queues a gamemode."); - chat(" &b.qlist &7Shows the modes you can queue with the \".q\" command"); - chat(" &b.status [player] &7Checks if a player is online or not. (Bypasses filters)"); - chatWithPrefix("&7Chat commands - &dModules"); - chat(" &b.cname [name] &7Set name hider name."); - chat(" &b.binds (key) &7List module binds."); - chat(" &b.spammer &7Set spammer message"); - chat(" &b.stop spammer &7Stops spammer"); - chatWithPrefix("&7Chat commands - &dProfiles"); - chat(" &b.profiles &7List loaded profiles."); - chat(" &b.profiles save (name) &7Save current settings as a profile."); - chat(" &b.profiles load [name] &7Load a profile."); - chat(" &b.profiles delete [name] &7Delete a profile."); - chat(" &b.profiles rename [oldname] [newname] &7Rename a profile."); - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.command.Command; + +public class Help extends Command { + public Help() { + super("help"); + } + + @Override + public void onExecute(String[] args) { + chatWithPrefix("&7Chat commands - &dGeneral"); + chat(" &b.ign/name &7Copy your username."); + chat(" &b.ping &7Estimate your ping."); + chat(" &b.friend/enemy [name/clear] &7Adds as enemy/friend."); + chat(" &b.q [mode] &7Queues a gamemode."); + chat(" &b.qlist &7Shows the modes you can queue with the \".q\" command"); + chat(" &b.status [player] &7Checks if a player is online or not. (Bypasses filters)"); + chatWithPrefix("&7Chat commands - &dModules"); + chat(" &b.cname [name] &7Set name hider name."); + chat(" &b.binds (key) &7List module binds."); + chat(" &b.spammer &7Set spammer message"); + chat(" &b.stop spammer &7Stops spammer"); + chatWithPrefix("&7Chat commands - &dProfiles"); + chat(" &b.profiles &7List loaded profiles."); + chat(" &b.profiles save (name) &7Save current settings as a profile."); + chat(" &b.profiles load [name] &7Load a profile."); + chat(" &b.profiles delete [name] &7Delete a profile."); + chat(" &b.profiles rename [oldname] [newname] &7Rename a profile."); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Name.java b/src/main/java/keystrokesmod/utility/command/impl/Name.java index e6d960d..e59f14e 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Name.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Name.java @@ -1,19 +1,19 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; - -public class Name extends Command { - public Name() { - super("name", new String[] { "ign", "name" }); - } - - @Override - public void onExecute(String[] args) { - if (!Utils.nullCheck()) { - return; - } - Utils.addToClipboard(mc.thePlayer.getName()); - chatWithPrefix("&7Copied &b" + mc.thePlayer.getName() + " &7to clipboard"); - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; + +public class Name extends Command { + public Name() { + super("name", new String[] { "ign", "name" }); + } + + @Override + public void onExecute(String[] args) { + if (!Utils.nullCheck()) { + return; + } + Utils.addToClipboard(mc.thePlayer.getName()); + chatWithPrefix("&7Copied &b" + mc.thePlayer.getName() + " &7to clipboard"); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Ping.java b/src/main/java/keystrokesmod/utility/command/impl/Ping.java index aa6e095..b597c84 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Ping.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Ping.java @@ -1,15 +1,15 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.helper.PingHelper; -import keystrokesmod.utility.command.Command; - -public class Ping extends Command { - public Ping() { - super("ping"); - } - - @Override - public void onExecute(String[] args) { - PingHelper.checkPing(true); - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.helper.PingHelper; +import keystrokesmod.utility.command.Command; + +public class Ping extends Command { + public Ping() { + super("ping"); + } + + @Override + public void onExecute(String[] args) { + PingHelper.checkPing(true); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Profiles.java b/src/main/java/keystrokesmod/utility/command/impl/Profiles.java index 9197473..84de350 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Profiles.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Profiles.java @@ -1,137 +1,137 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.Raven; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; -import keystrokesmod.utility.profile.Profile; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class Profiles extends Command { // credit: https://github.com/BoxDevelopment - public Profiles() { - super("profiles", new String[]{"profile", "p"}); - } - - @Override - public void onExecute(String[] args) { - if (args.length < 2) { - List profiles = Raven.profileManager.profiles; - if (profiles.isEmpty()) { - chatWithPrefix("&7No profiles found"); - return; - } - chatWithPrefix("&b" + profiles.size() + " &7profile" + (profiles.size() == 1 ? "" : "s") + " loaded."); - for (Profile profile : profiles) { - chatWithPrefix(" &7" + profile.getName() + - (profile == Raven.currentProfile ? " &7(&bcurrent&7)" : "")); - } - return; - } - - String subCommand = args[1].toLowerCase(); - - switch(subCommand) { - case "save": - case "s": - if (args.length < 3) { - if (Raven.currentProfile != null) { - Utils.sendMessage("&7Saved profile: &b" + Raven.currentProfile); - Raven.profileManager.saveProfile(Raven.currentProfile); - } - else { - syntaxError(); - } - return; - } - String saveName = args[2]; - Profile newProfile = new Profile(saveName, 0); - Raven.profileManager.saveProfile(newProfile); - chatWithPrefix("&7Saved profile: &b" + saveName); - Raven.profileManager.loadProfiles(); - break; - case "load": - case "l": - if (args.length < 3) { - syntaxError(); - return; - } - String loadName = args[2]; - if (Raven.profileManager.getProfile(loadName) == null) { - chatWithPrefix("&b" + loadName + " &7does not exist"); - return; - } - Raven.profileManager.loadProfile(loadName); - chatWithPrefix("&7Enabled profile: &b" + loadName); - break; - case "delete": - case "remove": - case "r": - if (args.length < 3) { - syntaxError(); - return; - } - String deleteName = args[2]; - if (Raven.profileManager.getProfile(deleteName) == null) { - chatWithPrefix("&cProfile &b" + deleteName + " &7does not exist"); - return; - } - Raven.profileManager.deleteProfile(deleteName); - chatWithPrefix("&7Removed profile: &b" + deleteName); - Raven.profileManager.loadProfiles(); - break; - case "rename": - if (args.length < 4) { - syntaxError(); - return; - } - String oldName = args[2]; - String newName = args[3]; - Profile oldProfile = Raven.profileManager.getProfile(oldName); - if (oldProfile == null) { - chatWithPrefix("&b" + oldName + " &7does not exist"); - return; - } - if (Raven.profileManager.getProfile(newName) != null) { - chatWithPrefix("&b" + newName + " &7already exists"); - return; - } - Profile renamedProfile = new Profile(newName, oldProfile.getBind()); // save this to that pls - Raven.profileManager.saveProfile(renamedProfile); - Raven.profileManager.deleteProfile(oldName); // delete old shit (i think thats needed) - chatWithPrefix("&b" + oldName + " &7renamed to &b" + newName); - Raven.profileManager.loadProfiles(); // ok so fun fact!! you need to load them again (i think??) - Raven.profileManager.loadProfile(newName); - break; - default: - syntaxError(); - break; - } - } - - @Override - public List tabComplete(String[] args) { - if (args.length == 2) { - return filterStartingWith(args[1], Arrays.asList("save", "s", "load", "l", "delete", "remove", "r", "rename")); - } - else if (args.length == 3 && !args[1].equalsIgnoreCase("save") && !args[1].equalsIgnoreCase("s")) { - List profileNames = new ArrayList<>(); - for (Profile profile : Raven.profileManager.profiles) { - profileNames.add(profile.getName()); - } - return filterStartingWith(args[2], profileNames); - } - return new ArrayList<>(); - } - - private List filterStartingWith(String prefix, List options) { - List filtered = new ArrayList<>(); - for (String option : options) { - if (option.toLowerCase().startsWith(prefix.toLowerCase())) { - filtered.add(option); - } - } - return filtered; - } +package keystrokesmod.utility.command.impl; + +import keystrokesmod.Raven; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; +import keystrokesmod.utility.profile.Profile; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Profiles extends Command { // credit: https://github.com/BoxDevelopment + public Profiles() { + super("profiles", new String[]{"profile", "p"}); + } + + @Override + public void onExecute(String[] args) { + if (args.length < 2) { + List profiles = Raven.profileManager.profiles; + if (profiles.isEmpty()) { + chatWithPrefix("&7No profiles found"); + return; + } + chatWithPrefix("&b" + profiles.size() + " &7profile" + (profiles.size() == 1 ? "" : "s") + " loaded."); + for (Profile profile : profiles) { + chatWithPrefix(" &7" + profile.getName() + + (profile == Raven.currentProfile ? " &7(&bcurrent&7)" : "")); + } + return; + } + + String subCommand = args[1].toLowerCase(); + + switch(subCommand) { + case "save": + case "s": + if (args.length < 3) { + if (Raven.currentProfile != null) { + Utils.sendMessage("&7Saved profile: &b" + Raven.currentProfile); + Raven.profileManager.saveProfile(Raven.currentProfile); + } + else { + syntaxError(); + } + return; + } + String saveName = args[2]; + Profile newProfile = new Profile(saveName, 0); + Raven.profileManager.saveProfile(newProfile); + chatWithPrefix("&7Saved profile: &b" + saveName); + Raven.profileManager.loadProfiles(); + break; + case "load": + case "l": + if (args.length < 3) { + syntaxError(); + return; + } + String loadName = args[2]; + if (Raven.profileManager.getProfile(loadName) == null) { + chatWithPrefix("&b" + loadName + " &7does not exist"); + return; + } + Raven.profileManager.loadProfile(loadName); + chatWithPrefix("&7Enabled profile: &b" + loadName); + break; + case "delete": + case "remove": + case "r": + if (args.length < 3) { + syntaxError(); + return; + } + String deleteName = args[2]; + if (Raven.profileManager.getProfile(deleteName) == null) { + chatWithPrefix("&cProfile &b" + deleteName + " &7does not exist"); + return; + } + Raven.profileManager.deleteProfile(deleteName); + chatWithPrefix("&7Removed profile: &b" + deleteName); + Raven.profileManager.loadProfiles(); + break; + case "rename": + if (args.length < 4) { + syntaxError(); + return; + } + String oldName = args[2]; + String newName = args[3]; + Profile oldProfile = Raven.profileManager.getProfile(oldName); + if (oldProfile == null) { + chatWithPrefix("&b" + oldName + " &7does not exist"); + return; + } + if (Raven.profileManager.getProfile(newName) != null) { + chatWithPrefix("&b" + newName + " &7already exists"); + return; + } + Profile renamedProfile = new Profile(newName, oldProfile.getBind()); // save this to that pls + Raven.profileManager.saveProfile(renamedProfile); + Raven.profileManager.deleteProfile(oldName); // delete old shit (i think thats needed) + chatWithPrefix("&b" + oldName + " &7renamed to &b" + newName); + Raven.profileManager.loadProfiles(); // ok so fun fact!! you need to load them again (i think??) + Raven.profileManager.loadProfile(newName); + break; + default: + syntaxError(); + break; + } + } + + @Override + public List tabComplete(String[] args) { + if (args.length == 2) { + return filterStartingWith(args[1], Arrays.asList("save", "s", "load", "l", "delete", "remove", "r", "rename")); + } + else if (args.length == 3 && !args[1].equalsIgnoreCase("save") && !args[1].equalsIgnoreCase("s")) { + List profileNames = new ArrayList<>(); + for (Profile profile : Raven.profileManager.profiles) { + profileNames.add(profile.getName()); + } + return filterStartingWith(args[2], profileNames); + } + return new ArrayList<>(); + } + + private List filterStartingWith(String prefix, List options) { + List filtered = new ArrayList<>(); + for (String option : options) { + if (option.toLowerCase().startsWith(prefix.toLowerCase())) { + filtered.add(option); + } + } + return filtered; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/command/impl/Q.java b/src/main/java/keystrokesmod/utility/command/impl/Q.java index 4c99d00..b666d92 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Q.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Q.java @@ -1,60 +1,60 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; - -import java.util.HashMap; -import java.util.Map; - -public class Q extends Command { - public Q() { - super("Q"); - } - - @Override - public void onExecute(String[] args) { - if (args.length > 1) { - playCommand = hypixelPlayCommands.get(args[1].trim()); - if (playCommand != null) { - mc.thePlayer.sendChatMessage("/play " + playCommand); - } else { - Utils.print("&cQueue failed. Invalid gamemode."); - } - } - } - - Map hypixelPlayCommands = new HashMap<>(); - {hypixelPlayCommands.put("p", "bedwars_practice"); - hypixelPlayCommands.put("1", "bedwars_eight_one"); - hypixelPlayCommands.put("2", "bedwars_eight_two"); - hypixelPlayCommands.put("3", "bedwars_four_three"); - hypixelPlayCommands.put("4", "bedwars_four_four"); - hypixelPlayCommands.put("4v4", "bedwars_two_four"); - hypixelPlayCommands.put("2t", "bedwars_eight_two_tourney"); - hypixelPlayCommands.put("2un", "bedwars_eight_two_towerUnderworld"); - hypixelPlayCommands.put("4un", "bedwars_four_four_towerUnderworld"); - hypixelPlayCommands.put("2r", "bedwars_eight_two_rush"); - hypixelPlayCommands.put("4r", "bedwars_four_four_rush"); - hypixelPlayCommands.put("pit", "pit"); - hypixelPlayCommands.put("swsn", "solo_normal"); - hypixelPlayCommands.put("swsi", "solo_insane"); - hypixelPlayCommands.put("swtn", "teams_normal"); - hypixelPlayCommands.put("swti", "teams_insane"); - hypixelPlayCommands.put("bowduel", "duels_bow_duel"); - hypixelPlayCommands.put("classicduel", "duels_classic_duel"); - hypixelPlayCommands.put("opduel", "duels_op_duel"); - hypixelPlayCommands.put("uhcduel", "duels_uhc_duel"); - hypixelPlayCommands.put("bridgeduel", "duels_bridge_duel"); - hypixelPlayCommands.put("uhc", "uhc_solo"); - hypixelPlayCommands.put("uhcteams", "uhc_teams"); - hypixelPlayCommands.put("grinch", "arcade_grinch_simulator_v2"); - hypixelPlayCommands.put("grinchtourney", "arcade_grinch_simulator_v2_tourney"); - hypixelPlayCommands.put("mm", "murder_classic"); - hypixelPlayCommands.put("castle", "bedwars_castle"); - // wool games - hypixelPlayCommands.put("ww", "wool_wool_wars_two_four"); - hypixelPlayCommands.put("ctw", "wool_capture_the_wool_two_twenty"); - } - String playCommand = "", gameMode = ""; - -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; + +import java.util.HashMap; +import java.util.Map; + +public class Q extends Command { + public Q() { + super("Q"); + } + + @Override + public void onExecute(String[] args) { + if (args.length > 1) { + playCommand = hypixelPlayCommands.get(args[1].trim()); + if (playCommand != null) { + mc.thePlayer.sendChatMessage("/play " + playCommand); + } else { + Utils.modulePrint("&cQueue failed. Invalid gamemode."); + } + } + } + + Map hypixelPlayCommands = new HashMap<>(); + {hypixelPlayCommands.put("p", "bedwars_practice"); + hypixelPlayCommands.put("1", "bedwars_eight_one"); + hypixelPlayCommands.put("2", "bedwars_eight_two"); + hypixelPlayCommands.put("3", "bedwars_four_three"); + hypixelPlayCommands.put("4", "bedwars_four_four"); + hypixelPlayCommands.put("4v4", "bedwars_two_four"); + hypixelPlayCommands.put("2t", "bedwars_eight_two_tourney"); + hypixelPlayCommands.put("2un", "bedwars_eight_two_towerUnderworld"); + hypixelPlayCommands.put("4un", "bedwars_four_four_towerUnderworld"); + hypixelPlayCommands.put("2r", "bedwars_eight_two_rush"); + hypixelPlayCommands.put("4r", "bedwars_four_four_rush"); + hypixelPlayCommands.put("pit", "pit"); + hypixelPlayCommands.put("swsn", "solo_normal"); + hypixelPlayCommands.put("swsi", "solo_insane"); + hypixelPlayCommands.put("swtn", "teams_normal"); + hypixelPlayCommands.put("swti", "teams_insane"); + hypixelPlayCommands.put("bowduel", "duels_bow_duel"); + hypixelPlayCommands.put("classicduel", "duels_classic_duel"); + hypixelPlayCommands.put("opduel", "duels_op_duel"); + hypixelPlayCommands.put("uhcduel", "duels_uhc_duel"); + hypixelPlayCommands.put("bridgeduel", "duels_bridge_duel"); + hypixelPlayCommands.put("uhc", "uhc_solo"); + hypixelPlayCommands.put("uhcteams", "uhc_teams"); + hypixelPlayCommands.put("grinch", "arcade_grinch_simulator_v2"); + hypixelPlayCommands.put("grinchtourney", "arcade_grinch_simulator_v2_tourney"); + hypixelPlayCommands.put("mm", "murder_classic"); + hypixelPlayCommands.put("castle", "bedwars_castle"); + // wool games + hypixelPlayCommands.put("ww", "wool_wool_wars_two_four"); + hypixelPlayCommands.put("ctw", "wool_capture_the_wool_two_twenty"); + } + String playCommand = "", gameMode = ""; + +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/QList.java b/src/main/java/keystrokesmod/utility/command/impl/QList.java index 1276f48..64546f1 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/QList.java +++ b/src/main/java/keystrokesmod/utility/command/impl/QList.java @@ -1,46 +1,46 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.utility.command.Command; - -public class QList extends Command { - public QList() { - super("QList"); - } - - @Override - public void onExecute(String[] args) { - chat(" &7-------------------------------------&r"); - chat(" &7Q List:"); - chat(" &7 "); - chat(" &7p - Bedwars Practice"); - chat(" &71 - Bedwars Solos"); - chat(" &72 - Bedwars Doubles"); - chat(" &73 - Bedwars Threes"); - chat(" &74 - Bedwars Fours"); - chat(" &74v4 - Bedwars 4v4"); - chat(" &72t - Bedwars Doubles Tourney"); - chat(" &72un - Bedwars Doubles Tower Underworld"); - chat(" &74un - Bedwars Fours Tower Underworld"); - chat(" &72r - Bedwars Doubles Rush"); - chat(" &74r - Bedwars Fours Rush"); - chat(" &7pit - The Pit"); - chat(" &7swsn - Skywars Solo Normal"); - chat(" &7swsi - Skywars Solo Insane"); - chat(" &7swtn - Skywars Teams Normal"); - chat(" &7swti - Skywars Teams Insane"); - chat(" &7bowduel - Bow Duel"); - chat(" &7classicduel - Classic Duel"); - chat(" &7opduel - OP Duel"); - chat(" &7uhcduel - UHC Duel"); - chat(" &7bridgeduel - Bridge Duel"); - chat(" &7uhc - UHC Solos"); - chat(" &7uhcteams - UHC Teams"); - chat(" &7grinch - Grinch Simulator"); - chat(" &7grinchtourney - Grinch Simulator Tournament"); - chat(" &7mm - Murder Mystery Classic"); - chat(" &7castle - Bedwars Castle"); - chat(" &7ww - Wool Wars"); - chat(" &7ctw - Capture The Wool"); - chat(" &7-------------------------------------"); - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.utility.command.Command; + +public class QList extends Command { + public QList() { + super("QList"); + } + + @Override + public void onExecute(String[] args) { + chat(" &7-------------------------------------&r"); + chat(" &7Q List:"); + chat(" &7 "); + chat(" &7p - Bedwars Practice"); + chat(" &71 - Bedwars Solos"); + chat(" &72 - Bedwars Doubles"); + chat(" &73 - Bedwars Threes"); + chat(" &74 - Bedwars Fours"); + chat(" &74v4 - Bedwars 4v4"); + chat(" &72t - Bedwars Doubles Tourney"); + chat(" &72un - Bedwars Doubles Tower Underworld"); + chat(" &74un - Bedwars Fours Tower Underworld"); + chat(" &72r - Bedwars Doubles Rush"); + chat(" &74r - Bedwars Fours Rush"); + chat(" &7pit - The Pit"); + chat(" &7swsn - Skywars Solo Normal"); + chat(" &7swsi - Skywars Solo Insane"); + chat(" &7swtn - Skywars Teams Normal"); + chat(" &7swti - Skywars Teams Insane"); + chat(" &7bowduel - Bow Duel"); + chat(" &7classicduel - Classic Duel"); + chat(" &7opduel - OP Duel"); + chat(" &7uhcduel - UHC Duel"); + chat(" &7bridgeduel - Bridge Duel"); + chat(" &7uhc - UHC Solos"); + chat(" &7uhcteams - UHC Teams"); + chat(" &7grinch - Grinch Simulator"); + chat(" &7grinchtourney - Grinch Simulator Tournament"); + chat(" &7mm - Murder Mystery Classic"); + chat(" &7castle - Bedwars Castle"); + chat(" &7ww - Wool Wars"); + chat(" &7ctw - Capture The Wool"); + chat(" &7-------------------------------------"); + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/SpammerUtil.java b/src/main/java/keystrokesmod/utility/command/impl/SpammerUtil.java index f10596f..a96a50e 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/SpammerUtil.java +++ b/src/main/java/keystrokesmod/utility/command/impl/SpammerUtil.java @@ -1,31 +1,27 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; - -import java.util.Arrays; - -public class SpammerUtil extends Command { - public SpammerUtil() { super("Spammer"); } - - @Override - public void onExecute(String[] args) { - if (args.length >= 2) { - - String message = Arrays.toString(args); - //String[] spl = message.split("spammer, "); - - ModuleManager.spammer.message = message; - - if (args.length > 50) { - Utils.print("§cToo many args"); - return; - } - Utils.print("§dSet spammer message as: " + ModuleManager.spammer.message); - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; + +import java.util.Arrays; + +public class SpammerUtil extends Command { + public SpammerUtil() { super("Spammer"); } + + @Override + public void onExecute(String[] args) { + if (args.length >= 2) { + + String message = Arrays.toString(args); + String[] spl = message.split("spammer, "); + + ModuleManager.spammer.message = spl[1]; + + Utils.modulePrint("§dSet spammer message as: " + ModuleManager.spammer.message); + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/Status.java b/src/main/java/keystrokesmod/utility/command/impl/Status.java index 0e3076e..e37a484 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/Status.java +++ b/src/main/java/keystrokesmod/utility/command/impl/Status.java @@ -1,89 +1,89 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.Raven; -import keystrokesmod.event.PreUpdateEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; -import keystrokesmod.utility.profile.Profile; -import net.minecraft.network.play.client.C01PacketChatMessage; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Status extends Command { - public Status() { - super("status"); - } - - public static String ign, modeString; - - public static int currentMode, lastMode, cooldown, displayNumber; - public static boolean start; - - @Override - public void onExecute(String[] args) { - if (args.length == 2) { - ign = args[1]; - - if (cooldown != 0) { - Utils.print("§dcurrently on cooldown for " + cooldown + "s"); - } - else { - ++currentMode; - getModeString(); - String msg = "/tip " + ign + modeString; - mc.thePlayer.sendChatMessage(msg); - lastMode = currentMode; - displayNumber = lastMode + 1; - start = true; - - cooldown = 7; - } - } - } - - private void getModeString() { - if (currentMode > 9) currentMode = 0; - if (currentMode == 0) { - modeString = " skywars"; - } - else if (currentMode == 1) { - modeString = " tnt"; - } - else if (currentMode == 2) { - modeString = " classic"; - } - else if (currentMode == 3) { - modeString = " blitz"; - } - else if (currentMode == 4) { - modeString = " mega"; - } - else if (currentMode == 5) { - modeString = " uhc"; - } - else if (currentMode == 6) { - modeString = " arcade"; - } - else if (currentMode == 7) { - modeString = " warlords"; - } - else if (currentMode == 8) { - modeString = " smash"; - } - else if (currentMode == 9) { - modeString = " cops"; - } - } - - -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.Raven; +import keystrokesmod.event.PreUpdateEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.ModuleUtils; +import keystrokesmod.utility.PacketUtils; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; +import keystrokesmod.utility.profile.Profile; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Status extends Command { + public Status() { + super("status"); + } + + public static String ign, modeString; + + public static int currentMode, lastMode, cooldown, displayNumber; + public static boolean start; + + @Override + public void onExecute(String[] args) { + if (args.length == 2) { + ign = args[1]; + + if (cooldown != 0) { + Utils.modulePrint("§dcurrently on cooldown for " + cooldown + "s"); + } + else { + ++currentMode; + getModeString(); + String msg = "/tip " + ign + modeString; + mc.thePlayer.sendChatMessage(msg); + lastMode = currentMode; + displayNumber = lastMode + 1; + start = true; + + cooldown = 7; + } + } + } + + private void getModeString() { + if (currentMode > 9) currentMode = 0; + if (currentMode == 0) { + modeString = " skywars"; + } + else if (currentMode == 1) { + modeString = " tnt"; + } + else if (currentMode == 2) { + modeString = " classic"; + } + else if (currentMode == 3) { + modeString = " blitz"; + } + else if (currentMode == 4) { + modeString = " mega"; + } + else if (currentMode == 5) { + modeString = " uhc"; + } + else if (currentMode == 6) { + modeString = " arcade"; + } + else if (currentMode == 7) { + modeString = " warlords"; + } + else if (currentMode == 8) { + modeString = " smash"; + } + else if (currentMode == 9) { + modeString = " cops"; + } + } + + +} diff --git a/src/main/java/keystrokesmod/utility/command/impl/StopSpammer.java b/src/main/java/keystrokesmod/utility/command/impl/StopSpammer.java index 1217269..4b355a0 100644 --- a/src/main/java/keystrokesmod/utility/command/impl/StopSpammer.java +++ b/src/main/java/keystrokesmod/utility/command/impl/StopSpammer.java @@ -1,23 +1,23 @@ -package keystrokesmod.utility.command.impl; - -import keystrokesmod.module.ModuleManager; -import keystrokesmod.utility.Utils; -import keystrokesmod.utility.command.Command; -import keystrokesmod.utility.command.CommandManager; - -import java.util.Arrays; - -public class StopSpammer extends Command { - public StopSpammer() { super("Stop Spammer"); } - - @Override - public void onExecute(String[] args) { - if (args.length >= 1) { - ModuleManager.spammer.reset(); - Utils.print("§cPaused spammer"); - } - else { - syntaxError(); - } - } -} +package keystrokesmod.utility.command.impl; + +import keystrokesmod.module.ModuleManager; +import keystrokesmod.utility.Utils; +import keystrokesmod.utility.command.Command; +import keystrokesmod.utility.command.CommandManager; + +import java.util.Arrays; + +public class StopSpammer extends Command { + public StopSpammer() { super("Stop Spammer"); } + + @Override + public void onExecute(String[] args) { + if (args.length >= 1) { + ModuleManager.spammer.reset(); + Utils.modulePrint("§cPaused spammer"); + } + else { + syntaxError(); + } + } +} diff --git a/src/main/java/keystrokesmod/utility/profile/Manager.java b/src/main/java/keystrokesmod/utility/profile/Manager.java index 6429faa..242691b 100644 --- a/src/main/java/keystrokesmod/utility/profile/Manager.java +++ b/src/main/java/keystrokesmod/utility/profile/Manager.java @@ -1,48 +1,48 @@ -package keystrokesmod.utility.profile; - -import keystrokesmod.Raven; -import keystrokesmod.module.Module; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.Utils; - -import java.awt.*; -import java.io.IOException; - -public class Manager extends Module { - private ButtonSetting loadProfiles, openFolder, createProfile; - - public Manager() { - super("Manager", category.profiles); - this.registerSetting(createProfile = new ButtonSetting("Create profile", () -> { - if (Utils.nullCheck() && Raven.profileManager != null) { - String name = "profile-"; - for (int i = 1; i <= 100; i++) { - if (Raven.profileManager.getProfile(name + i) != null) { - continue; - } - name += i; - Raven.profileManager.saveProfile(new Profile(name, 0)); - Utils.sendMessage("&7Created profile: &b" + name); - Raven.profileManager.loadProfiles(); - break; - } - } - })); - this.registerSetting(loadProfiles = new ButtonSetting("Load profiles", () -> { - if (Utils.nullCheck() && Raven.profileManager != null) { - Raven.profileManager.loadProfiles(); - } - })); - this.registerSetting(openFolder = new ButtonSetting("Open folder", () -> { - try { - Desktop.getDesktop().open(Raven.profileManager.directory); - } - catch (IOException ex) { - Raven.profileManager.directory.mkdirs(); - Utils.sendMessage("&cError locating folder, recreated."); - } - })); - ignoreOnSave = true; - canBeEnabled = false; - } +package keystrokesmod.utility.profile; + +import keystrokesmod.Raven; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.Utils; + +import java.awt.*; +import java.io.IOException; + +public class Manager extends Module { + private ButtonSetting loadProfiles, openFolder, createProfile; + + public Manager() { + super("Manager", category.profiles); + this.registerSetting(createProfile = new ButtonSetting("Create profile", () -> { + if (Utils.nullCheck() && Raven.profileManager != null) { + String name = "profile-"; + for (int i = 1; i <= 100; i++) { + if (Raven.profileManager.getProfile(name + i) != null) { + continue; + } + name += i; + Raven.profileManager.saveProfile(new Profile(name, 0)); + Utils.sendMessage("&7Created profile: &b" + name); + Raven.profileManager.loadProfiles(); + break; + } + } + })); + this.registerSetting(loadProfiles = new ButtonSetting("Load profiles", () -> { + if (Utils.nullCheck() && Raven.profileManager != null) { + Raven.profileManager.loadProfiles(); + } + })); + this.registerSetting(openFolder = new ButtonSetting("Open folder", () -> { + try { + Desktop.getDesktop().open(Raven.profileManager.directory); + } + catch (IOException ex) { + Raven.profileManager.directory.mkdirs(); + Utils.sendMessage("&cError locating folder, recreated."); + } + })); + ignoreOnSave = true; + canBeEnabled = false; + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/profile/Profile.java b/src/main/java/keystrokesmod/utility/profile/Profile.java index 83533cc..2b4633a 100644 --- a/src/main/java/keystrokesmod/utility/profile/Profile.java +++ b/src/main/java/keystrokesmod/utility/profile/Profile.java @@ -1,28 +1,28 @@ -package keystrokesmod.utility.profile; - -import keystrokesmod.module.Module; - -public class Profile { - private Module module; - private int bind = 0; - private String profileName; - - public Profile(String profileName, int bind) { - this.profileName = profileName; - this.bind = bind; - this.module = new ProfileModule(this, profileName, bind); - this.module.ignoreOnSave = true; - } - - public Module getModule() { - return module; - } - - public int getBind() { - return bind; - } - - public String getName() { - return profileName; - } -} +package keystrokesmod.utility.profile; + +import keystrokesmod.module.Module; + +public class Profile { + private Module module; + private int bind = 0; + private String profileName; + + public Profile(String profileName, int bind) { + this.profileName = profileName; + this.bind = bind; + this.module = new ProfileModule(this, profileName, bind); + this.module.ignoreOnSave = true; + } + + public Module getModule() { + return module; + } + + public int getBind() { + return bind; + } + + public String getName() { + return profileName; + } +} diff --git a/src/main/java/keystrokesmod/utility/profile/ProfileManager.java b/src/main/java/keystrokesmod/utility/profile/ProfileManager.java index c84cdb5..3c728b6 100644 --- a/src/main/java/keystrokesmod/utility/profile/ProfileManager.java +++ b/src/main/java/keystrokesmod/utility/profile/ProfileManager.java @@ -1,352 +1,352 @@ -package keystrokesmod.utility.profile; - -import com.google.gson.*; -import keystrokesmod.Raven; -import keystrokesmod.clickgui.ClickGui; -import keystrokesmod.clickgui.components.impl.CategoryComponent; -import keystrokesmod.event.PostProfileLoadEvent; -import keystrokesmod.module.Module; -import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.client.Gui; -import keystrokesmod.module.impl.client.Settings; -import keystrokesmod.module.impl.movement.Sprint; -import keystrokesmod.module.impl.render.HUD; -import keystrokesmod.module.impl.render.TargetHUD; -import keystrokesmod.module.setting.Setting; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.module.setting.impl.KeySetting; -import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.script.Manager; -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraftforge.common.MinecraftForge; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.util.*; - -public class ProfileManager { - public static Minecraft mc = Minecraft.getMinecraft(); - public File directory; - public List profiles = new ArrayList<>(); - - public ProfileManager() { - directory = new File(mc.mcDataDir + File.separator + "keystrokes", "profiles"); - if (!directory.exists()) { - boolean success = directory.mkdirs(); - if (!success) { - System.out.println("There was an issue creating profiles directory."); - return; - } - } - if (directory.listFiles().length == 0) { // if theres no profile in the folder upon launch, create new default profile - saveProfile(new Profile("default", 0)); - } - } - - public void saveProfile(Profile profile) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("keybind", profile.getModule().getKeycode()); - JsonArray jsonArray = new JsonArray(); - for (Module module : Raven.moduleManager.getModules()) { - if (module.ignoreOnSave) { - continue; - } - JsonObject moduleInformation = getJsonObject(module); - jsonArray.add(moduleInformation); - } - if (Raven.scriptManager != null && Raven.scriptManager.scripts != null) { - for (Module module : Raven.scriptManager.scripts.values()) { - if (module.ignoreOnSave) { - continue; - } - JsonObject moduleInformation = getJsonObject(module); - jsonArray.add(moduleInformation); - } - } - jsonObject.add("modules", jsonArray); - try (FileWriter fileWriter = new FileWriter(new File(directory, profile.getName() + ".json"))) { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - gson.toJson(jsonObject, fileWriter); - } catch (Exception e) { - failedMessage("save", profile.getName()); - e.printStackTrace(); - } - } - - private static JsonObject getJsonObject(Module module) { - JsonObject moduleInformation = new JsonObject(); - moduleInformation.addProperty("name", (module.moduleCategory() == Module.category.scripts && !(module instanceof Manager)) ? "sc-" + module.getName() : module.getName()); - if (module.canBeEnabled) { - moduleInformation.addProperty("enabled", module.isEnabled()); - moduleInformation.addProperty("hidden", module.isHidden()); - moduleInformation.addProperty("keybind", module.getKeycode()); - } - if (module instanceof HUD) { - moduleInformation.addProperty("posX", HUD.posX); - moduleInformation.addProperty("posY", HUD.posY); - } - else if (module instanceof TargetHUD) { - moduleInformation.addProperty("posX", ModuleManager.targetHUD.posX); - moduleInformation.addProperty("posY", ModuleManager.targetHUD.posY); - } - else if (module instanceof Sprint) { - moduleInformation.addProperty("posX", ModuleManager.sprint.posX); - moduleInformation.addProperty("posY", ModuleManager.sprint.posY); - moduleInformation.addProperty("text", ModuleManager.sprint.text); - } - else if (module instanceof Gui) { - for (CategoryComponent c : ClickGui.categories) { - moduleInformation.addProperty(c.category.name(), c.x + "," + c.y + "," + c.opened); - } - } - for (Setting setting : module.getSettings()) { - if (setting instanceof ButtonSetting && !((ButtonSetting) setting).isMethodButton) { - moduleInformation.addProperty(setting.getName(), ((ButtonSetting) setting).isToggled()); - } - else if (setting instanceof SliderSetting) { - moduleInformation.addProperty(setting.getName(), ((SliderSetting) setting).getInput()); - } - else if (setting instanceof KeySetting) { - moduleInformation.addProperty(setting.getName(), ((KeySetting) setting).getKey()); - } - } - return moduleInformation; - } - - public void loadProfile(String name) { - for (File file : getProfileFiles()) { - if (!file.exists()) { - failedMessage("load", name); - System.out.println("Failed to load " + name); - return; - } - if (!file.getName().equals(name + ".json")) { - continue; - } - if (Raven.scriptManager != null) { - for (Module module : Raven.scriptManager.scripts.values()) { - if (module.canBeEnabled()) { - module.disable(); - module.setBind(0); - } - } - } - for (Module module : Raven.getModuleManager().getModules()) { - if (module.canBeEnabled()) { - module.disable(); - module.setBind(0); - } - } - try (FileReader fileReader = new FileReader(file)) { - JsonParser jsonParser = new JsonParser(); - JsonObject profileJson = jsonParser.parse(fileReader).getAsJsonObject(); - if (profileJson == null) { - failedMessage("load", name); - return; - } - JsonArray modules = profileJson.getAsJsonArray("modules"); - if (modules == null) { - failedMessage("load", name); - return; - } - boolean currentProfileGuiSave = Settings.loadGuiPositions.isToggled(); - for (JsonElement moduleJson : modules) { - JsonObject moduleInformation = moduleJson.getAsJsonObject(); - String moduleName = moduleInformation.get("name").getAsString(); - - if (moduleName == null || moduleName.isEmpty()) { - continue; - } - - Module module = Raven.moduleManager.getModule(moduleName); - if (module == null && moduleName.startsWith("sc-") && Raven.scriptManager != null) { - for (Module module1 : Raven.scriptManager.scripts.values()) { - if (module1.getName().equals(moduleName.substring(3))) { - module = module1; - } - } - } - - if (module == null) { - continue; - } - - if (module.canBeEnabled()) { - if (moduleInformation.has("enabled")) { - boolean enabled = moduleInformation.get("enabled").getAsBoolean(); - if (enabled) { - module.enable(); - } else { - module.disable(); - } - } - if (moduleInformation.has("hidden")) { - boolean hidden = moduleInformation.get("hidden").getAsBoolean(); - module.setHidden(hidden); - } - if (moduleInformation.has("keybind")) { - int keybind = moduleInformation.get("keybind").getAsInt(); - module.setBind(keybind); - } - } - - if (module.getName().equals("HUD")) { - if (moduleInformation.has("posX")) { - int hudX = moduleInformation.get("posX").getAsInt(); - HUD.posX = hudX; - } - if (moduleInformation.has("posY")) { - int hudY = moduleInformation.get("posY").getAsInt(); - HUD.posY = hudY; - } - } - else if (module.getName().equals("TargetHUD")) { - if (moduleInformation.has("posX")) { - int posX = moduleInformation.get("posX").getAsInt(); - ModuleManager.targetHUD.posX = posX; - } - if (moduleInformation.has("posY")) { - int posY = moduleInformation.get("posY").getAsInt(); - ModuleManager.targetHUD.posY = posY; - } - } - else if (module.getName().equals("Sprint")) { - if (moduleInformation.has("posX")) { - float posX = moduleInformation.get("posX").getAsFloat(); - ModuleManager.sprint.posX = posX; - } - if (moduleInformation.has("posY")) { - float posY = moduleInformation.get("posY").getAsFloat(); - ModuleManager.sprint.posY = posY; - } - if (moduleInformation.has("text")) { - String text = moduleInformation.get("text").getAsString(); - ModuleManager.sprint.text = text; - } - } - else if (currentProfileGuiSave && module.getName().equals("Gui")) { - for (Map.Entry setting : moduleInformation.entrySet()) { - String settingName = setting.getKey(); - if (!Module.categoriesString.contains(settingName)) { - continue; - } - String element = setting.getValue().getAsString(); - String[] statesStr = element.split(","); - - float posX = Float.parseFloat(statesStr[0]); - float posY = Float.parseFloat(statesStr[1]); - - for (CategoryComponent c : ClickGui.categories) { - if (c.category.name().equals(settingName)) { - c.setX(posX, true); - c.setY(posY, true); - if (statesStr.length > 2) { - boolean opened = Boolean.parseBoolean(statesStr[2]); - c.opened = opened; - } - break; - } - } - } - } - - for (Setting setting : module.getSettings()) { - setting.loadProfile(moduleInformation); - } - - Raven.currentProfile = getProfile(name); - } - MinecraftForge.EVENT_BUS.post(new PostProfileLoadEvent(Raven.currentProfile.getName())); - } - catch (Exception e) { - failedMessage("load", name); - e.printStackTrace(); - } - } - } - - public void deleteProfile(String name) { - Iterator iterator = profiles.iterator(); - while (iterator.hasNext()) { - Profile profile = iterator.next(); - if (profile.getName().equals(name)) { - iterator.remove(); - } - } - if (directory.exists()) { - File[] files = directory.listFiles(); - for (File file : files) { - if (file.getName().equals(name + ".json")) { - file.delete(); - } - } - } - } - - public void loadProfiles() { - profiles.clear(); - if (directory.exists()) { - File[] files = directory.listFiles(); - for (File file : files) { - try (FileReader fileReader = new FileReader(file)) { - JsonParser jsonParser = new JsonParser(); - JsonObject profileJson = jsonParser.parse(fileReader).getAsJsonObject(); - String profileName = file.getName().replace(".json", ""); - - if (profileJson == null) { - failedMessage("load", profileName); - return; - } - - int keybind = 0; - - if (profileJson.has("keybind")) { - keybind = profileJson.get("keybind").getAsInt(); - } - - Profile profile = new Profile(profileName, keybind); - profiles.add(profile); - } catch (Exception e) { - Utils.sendMessage("&cFailed to load profiles."); - e.printStackTrace(); - } - } - - for (CategoryComponent categoryComponent : Raven.clickGui.categories) { - if (categoryComponent.category == Module.category.profiles) { - categoryComponent.reloadModules(true); - } - } - Utils.sendMessage("&b" + Raven.profileManager.getProfileFiles().size() + " &7profiles loaded."); - } - } - - public List getProfileFiles() { - List profileFiles = new ArrayList<>(); - if (directory.exists()) { - File[] files = directory.listFiles(); - for (File file : files) { - if (!file.getName().endsWith(".json")) { - continue; - } - profileFiles.add(file); - } - } - return profileFiles; - } - - public Profile getProfile(String name) { - for (Profile profile : profiles) { - if (profile.getName().equals(name)) { - return profile; - } - } - return null; - } - - public void failedMessage(String reason, String name) { - Utils.sendMessage("&cFailed to " + reason + ": &b" + name); - } -} +package keystrokesmod.utility.profile; + +import com.google.gson.*; +import keystrokesmod.Raven; +import keystrokesmod.clickgui.ClickGui; +import keystrokesmod.clickgui.components.impl.CategoryComponent; +import keystrokesmod.event.PostProfileLoadEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.ModuleManager; +import keystrokesmod.module.impl.client.Gui; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.module.impl.movement.Sprint; +import keystrokesmod.module.impl.render.HUD; +import keystrokesmod.module.impl.render.TargetInfo; +import keystrokesmod.module.setting.Setting; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.KeySetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import keystrokesmod.script.Manager; +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraftforge.common.MinecraftForge; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.*; + +public class ProfileManager { + public static Minecraft mc = Minecraft.getMinecraft(); + public File directory; + public List profiles = new ArrayList<>(); + + public ProfileManager() { + directory = new File(mc.mcDataDir + File.separator + "keystrokes", "profiles"); + if (!directory.exists()) { + boolean success = directory.mkdirs(); + if (!success) { + System.out.println("There was an issue creating profiles directory."); + return; + } + } + if (directory.listFiles().length == 0) { // if theres no profile in the folder upon launch, create new default profile + saveProfile(new Profile("default", 0)); + } + } + + public void saveProfile(Profile profile) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("keybind", profile.getModule().getKeycode()); + JsonArray jsonArray = new JsonArray(); + for (Module module : Raven.moduleManager.getModules()) { + if (module.ignoreOnSave) { + continue; + } + JsonObject moduleInformation = getJsonObject(module); + jsonArray.add(moduleInformation); + } + if (Raven.scriptManager != null && Raven.scriptManager.scripts != null) { + for (Module module : Raven.scriptManager.scripts.values()) { + if (module.ignoreOnSave) { + continue; + } + JsonObject moduleInformation = getJsonObject(module); + jsonArray.add(moduleInformation); + } + } + jsonObject.add("modules", jsonArray); + try (FileWriter fileWriter = new FileWriter(new File(directory, profile.getName() + ".json"))) { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + gson.toJson(jsonObject, fileWriter); + } catch (Exception e) { + failedMessage("save", profile.getName()); + e.printStackTrace(); + } + } + + private static JsonObject getJsonObject(Module module) { + JsonObject moduleInformation = new JsonObject(); + moduleInformation.addProperty("name", (module.moduleCategory() == Module.category.scripts && !(module instanceof Manager)) ? "sc-" + module.getName() : module.getName()); + if (module.canBeEnabled) { + moduleInformation.addProperty("enabled", module.isEnabled()); + moduleInformation.addProperty("hidden", module.isHidden()); + moduleInformation.addProperty("keybind", module.getKeycode()); + } + if (module instanceof HUD) { + moduleInformation.addProperty("posX", HUD.posX); + moduleInformation.addProperty("posY", HUD.posY); + } + else if (module instanceof TargetInfo) { + moduleInformation.addProperty("posX", ModuleManager.targetInfo.posX); + moduleInformation.addProperty("posY", ModuleManager.targetInfo.posY); + } + else if (module instanceof Sprint) { + moduleInformation.addProperty("posX", ModuleManager.sprint.posX); + moduleInformation.addProperty("posY", ModuleManager.sprint.posY); + moduleInformation.addProperty("text", ModuleManager.sprint.text); + } + else if (module instanceof Gui) { + for (CategoryComponent c : ClickGui.categories) { + moduleInformation.addProperty(c.category.name(), c.x + "," + c.y + "," + c.opened); + } + } + for (Setting setting : module.getSettings()) { + if (setting instanceof ButtonSetting && !((ButtonSetting) setting).isMethodButton) { + moduleInformation.addProperty(setting.getName(), ((ButtonSetting) setting).isToggled()); + } + else if (setting instanceof SliderSetting) { + moduleInformation.addProperty(setting.getName(), ((SliderSetting) setting).getInput()); + } + else if (setting instanceof KeySetting) { + moduleInformation.addProperty(setting.getName(), ((KeySetting) setting).getKey()); + } + } + return moduleInformation; + } + + public void loadProfile(String name) { + for (File file : getProfileFiles()) { + if (!file.exists()) { + failedMessage("load", name); + System.out.println("Failed to load " + name); + return; + } + if (!file.getName().equals(name + ".json")) { + continue; + } + if (Raven.scriptManager != null) { + for (Module module : Raven.scriptManager.scripts.values()) { + if (module.canBeEnabled()) { + module.disable(); + module.setBind(0); + } + } + } + for (Module module : Raven.getModuleManager().getModules()) { + if (module.canBeEnabled()) { + module.disable(); + module.setBind(0); + } + } + try (FileReader fileReader = new FileReader(file)) { + JsonParser jsonParser = new JsonParser(); + JsonObject profileJson = jsonParser.parse(fileReader).getAsJsonObject(); + if (profileJson == null) { + failedMessage("load", name); + return; + } + JsonArray modules = profileJson.getAsJsonArray("modules"); + if (modules == null) { + failedMessage("load", name); + return; + } + boolean currentProfileGuiSave = Settings.loadGuiPositions.isToggled(); + for (JsonElement moduleJson : modules) { + JsonObject moduleInformation = moduleJson.getAsJsonObject(); + String moduleName = moduleInformation.get("name").getAsString(); + + if (moduleName == null || moduleName.isEmpty()) { + continue; + } + + Module module = Raven.moduleManager.getModule(moduleName); + if (module == null && moduleName.startsWith("sc-") && Raven.scriptManager != null) { + for (Module module1 : Raven.scriptManager.scripts.values()) { + if (module1.getName().equals(moduleName.substring(3))) { + module = module1; + } + } + } + + if (module == null) { + continue; + } + + if (module.canBeEnabled()) { + if (moduleInformation.has("enabled")) { + boolean enabled = moduleInformation.get("enabled").getAsBoolean(); + if (enabled) { + module.enable(); + } else { + module.disable(); + } + } + if (moduleInformation.has("hidden")) { + boolean hidden = moduleInformation.get("hidden").getAsBoolean(); + module.setHidden(hidden); + } + if (moduleInformation.has("keybind")) { + int keybind = moduleInformation.get("keybind").getAsInt(); + module.setBind(keybind); + } + } + + if (module.getName().equals("HUD")) { + if (moduleInformation.has("posX")) { + int hudX = moduleInformation.get("posX").getAsInt(); + HUD.posX = hudX; + } + if (moduleInformation.has("posY")) { + int hudY = moduleInformation.get("posY").getAsInt(); + HUD.posY = hudY; + } + } + else if (module.getName().equals("TargetInfo")) { + if (moduleInformation.has("posX")) { + int posX = moduleInformation.get("posX").getAsInt(); + ModuleManager.targetInfo.posX = posX; + } + if (moduleInformation.has("posY")) { + int posY = moduleInformation.get("posY").getAsInt(); + ModuleManager.targetInfo.posY = posY; + } + } + else if (module.getName().equals("Sprint")) { + if (moduleInformation.has("posX")) { + float posX = moduleInformation.get("posX").getAsFloat(); + ModuleManager.sprint.posX = posX; + } + if (moduleInformation.has("posY")) { + float posY = moduleInformation.get("posY").getAsFloat(); + ModuleManager.sprint.posY = posY; + } + if (moduleInformation.has("text")) { + String text = moduleInformation.get("text").getAsString(); + ModuleManager.sprint.text = text; + } + } + else if (currentProfileGuiSave && module.getName().equals("Gui")) { + for (Map.Entry setting : moduleInformation.entrySet()) { + String settingName = setting.getKey(); + if (!Module.categoriesString.contains(settingName)) { + continue; + } + String element = setting.getValue().getAsString(); + String[] statesStr = element.split(","); + + float posX = Float.parseFloat(statesStr[0]); + float posY = Float.parseFloat(statesStr[1]); + + for (CategoryComponent c : ClickGui.categories) { + if (c.category.name().equals(settingName)) { + c.setX(posX, true); + c.setY(posY, true); + if (statesStr.length > 2) { + boolean opened = Boolean.parseBoolean(statesStr[2]); + c.opened = opened; + } + break; + } + } + } + } + + for (Setting setting : module.getSettings()) { + setting.loadProfile(moduleInformation); + } + + Raven.currentProfile = getProfile(name); + } + MinecraftForge.EVENT_BUS.post(new PostProfileLoadEvent(Raven.currentProfile.getName())); + } + catch (Exception e) { + failedMessage("load", name); + e.printStackTrace(); + } + } + } + + public void deleteProfile(String name) { + Iterator iterator = profiles.iterator(); + while (iterator.hasNext()) { + Profile profile = iterator.next(); + if (profile.getName().equals(name)) { + iterator.remove(); + } + } + if (directory.exists()) { + File[] files = directory.listFiles(); + for (File file : files) { + if (file.getName().equals(name + ".json")) { + file.delete(); + } + } + } + } + + public void loadProfiles() { + profiles.clear(); + if (directory.exists()) { + File[] files = directory.listFiles(); + for (File file : files) { + try (FileReader fileReader = new FileReader(file)) { + JsonParser jsonParser = new JsonParser(); + JsonObject profileJson = jsonParser.parse(fileReader).getAsJsonObject(); + String profileName = file.getName().replace(".json", ""); + + if (profileJson == null) { + failedMessage("load", profileName); + return; + } + + int keybind = 0; + + if (profileJson.has("keybind")) { + keybind = profileJson.get("keybind").getAsInt(); + } + + Profile profile = new Profile(profileName, keybind); + profiles.add(profile); + } catch (Exception e) { + Utils.sendMessage("&cFailed to load profiles."); + e.printStackTrace(); + } + } + + for (CategoryComponent categoryComponent : Raven.clickGui.categories) { + if (categoryComponent.category == Module.category.profiles) { + categoryComponent.reloadModules(true); + } + } + Utils.sendMessage("&b" + Raven.profileManager.getProfileFiles().size() + " &7profiles loaded."); + } + } + + public List getProfileFiles() { + List profileFiles = new ArrayList<>(); + if (directory.exists()) { + File[] files = directory.listFiles(); + for (File file : files) { + if (!file.getName().endsWith(".json")) { + continue; + } + profileFiles.add(file); + } + } + return profileFiles; + } + + public Profile getProfile(String name) { + for (Profile profile : profiles) { + if (profile.getName().equals(name)) { + return profile; + } + } + return null; + } + + public void failedMessage(String reason, String name) { + Utils.sendMessage("&cFailed to " + reason + ": &b" + name); + } +} diff --git a/src/main/java/keystrokesmod/utility/profile/ProfileModule.java b/src/main/java/keystrokesmod/utility/profile/ProfileModule.java index d812221..00bb4d0 100644 --- a/src/main/java/keystrokesmod/utility/profile/ProfileModule.java +++ b/src/main/java/keystrokesmod/utility/profile/ProfileModule.java @@ -1,52 +1,52 @@ -package keystrokesmod.utility.profile; - -import keystrokesmod.Raven; -import keystrokesmod.clickgui.ClickGui; -import keystrokesmod.module.Module; -import keystrokesmod.module.impl.client.Settings; -import keystrokesmod.module.setting.impl.ButtonSetting; -import keystrokesmod.utility.Utils; - -public class ProfileModule extends Module { - private Profile profile; - public boolean saved = true; - - public ProfileModule(Profile profile, String name, int bind) { - super(name, category.profiles, bind); - this.profile = profile; - this.registerSetting(new ButtonSetting("Save profile", () -> { - Utils.sendMessage("&7Saved profile: &b" + getName()); - Raven.profileManager.saveProfile(this.profile); - saved = true; - })); - this.registerSetting(new ButtonSetting("Remove profile", () -> { - Utils.sendMessage("&7Removed profile: &b" + getName()); - Raven.profileManager.deleteProfile(getName()); - })); - } - - @Override - public void toggle() { - if (mc.currentScreen instanceof ClickGui || mc.currentScreen == null) { - if (this.profile == Raven.currentProfile && saved) { - return; - } - Raven.profileManager.loadProfile(this.getName()); - - Raven.currentProfile = profile; - - if (Settings.sendMessage.isToggled()) { - Utils.sendMessage("&7Enabled profile: &b" + this.getName()); - } - saved = true; - } - } - - @Override - public boolean isEnabled() { - if (Raven.currentProfile == null) { - return false; - } - return Raven.currentProfile.getModule() == this; - } -} +package keystrokesmod.utility.profile; + +import keystrokesmod.Raven; +import keystrokesmod.clickgui.ClickGui; +import keystrokesmod.module.Module; +import keystrokesmod.module.impl.client.Settings; +import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.utility.Utils; + +public class ProfileModule extends Module { + private Profile profile; + public boolean saved = true; + + public ProfileModule(Profile profile, String name, int bind) { + super(name, category.profiles, bind); + this.profile = profile; + this.registerSetting(new ButtonSetting("Save profile", () -> { + Utils.sendMessage("&7Saved profile: &b" + getName()); + Raven.profileManager.saveProfile(this.profile); + saved = true; + })); + this.registerSetting(new ButtonSetting("Remove profile", () -> { + Utils.sendMessage("&7Removed profile: &b" + getName()); + Raven.profileManager.deleteProfile(getName()); + })); + } + + @Override + public void toggle() { + if (mc.currentScreen instanceof ClickGui || mc.currentScreen == null) { + if (this.profile == Raven.currentProfile && saved) { + return; + } + Raven.profileManager.loadProfile(this.getName()); + + Raven.currentProfile = profile; + + if (Settings.sendMessage.isToggled()) { + Utils.sendMessage("&7Enabled profile: &b" + this.getName()); + } + saved = true; + } + } + + @Override + public boolean isEnabled() { + if (Raven.currentProfile == null) { + return false; + } + return Raven.currentProfile.getModule() == this; + } +} diff --git a/src/main/java/keystrokesmod/utility/shader/BlurUtils.java b/src/main/java/keystrokesmod/utility/shader/BlurUtils.java index 85a3d00..bee6834 100644 --- a/src/main/java/keystrokesmod/utility/shader/BlurUtils.java +++ b/src/main/java/keystrokesmod/utility/shader/BlurUtils.java @@ -1,29 +1,29 @@ -package keystrokesmod.utility.shader; - -import keystrokesmod.utility.RenderUtils; -import net.minecraft.client.shader.Framebuffer; - -public class BlurUtils { - private static Framebuffer stencilFrameBufferBlur = new Framebuffer(1, 1, false); - private static Framebuffer stencilFrameBufferBloom = new Framebuffer(1, 1, false); - public static void prepareBlur() { - stencilFrameBufferBlur = RenderUtils.createFrameBuffer(stencilFrameBufferBlur); - stencilFrameBufferBlur.framebufferClear(); - stencilFrameBufferBlur.bindFramebuffer(false); - } - public static void prepareBloom() { - stencilFrameBufferBloom = RenderUtils.createFrameBuffer(stencilFrameBufferBloom); - stencilFrameBufferBloom.framebufferClear(); - stencilFrameBufferBloom.bindFramebuffer(false); - } - - public static void blurEnd(int passes, float radius) { - stencilFrameBufferBlur.unbindFramebuffer(); - KawaseBlur.renderBlur(stencilFrameBufferBlur.framebufferTexture, passes, radius); - } - - public static void bloomEnd(int passes, float radius) { - stencilFrameBufferBloom.unbindFramebuffer(); - KawaseBloom.renderBlur(stencilFrameBufferBloom.framebufferTexture, passes, radius); - } +package keystrokesmod.utility.shader; + +import keystrokesmod.utility.RenderUtils; +import net.minecraft.client.shader.Framebuffer; + +public class BlurUtils { + private static Framebuffer stencilFrameBufferBlur = new Framebuffer(1, 1, false); + private static Framebuffer stencilFrameBufferBloom = new Framebuffer(1, 1, false); + public static void prepareBlur() { + stencilFrameBufferBlur = RenderUtils.createFrameBuffer(stencilFrameBufferBlur); + stencilFrameBufferBlur.framebufferClear(); + stencilFrameBufferBlur.bindFramebuffer(false); + } + public static void prepareBloom() { + stencilFrameBufferBloom = RenderUtils.createFrameBuffer(stencilFrameBufferBloom); + stencilFrameBufferBloom.framebufferClear(); + stencilFrameBufferBloom.bindFramebuffer(false); + } + + public static void blurEnd(int passes, float radius) { + stencilFrameBufferBlur.unbindFramebuffer(); + KawaseBlur.renderBlur(stencilFrameBufferBlur.framebufferTexture, passes, radius); + } + + public static void bloomEnd(int passes, float radius) { + stencilFrameBufferBloom.unbindFramebuffer(); + KawaseBloom.renderBlur(stencilFrameBufferBloom.framebufferTexture, passes, radius); + } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/shader/KawaseBloom.java b/src/main/java/keystrokesmod/utility/shader/KawaseBloom.java index 1751ddf..d28f71c 100644 --- a/src/main/java/keystrokesmod/utility/shader/KawaseBloom.java +++ b/src/main/java/keystrokesmod/utility/shader/KawaseBloom.java @@ -1,118 +1,118 @@ -package keystrokesmod.utility.shader; - -import keystrokesmod.utility.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.shader.Framebuffer; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL13; -import org.lwjgl.opengl.GL14; - -import java.util.ArrayList; -import java.util.List; - -import static org.lwjgl.opengl.GL11.*; - -public class KawaseBloom { - private static final Minecraft mc = Minecraft.getMinecraft(); - public static ShaderUtils kawaseDown = new ShaderUtils("kawaseDownBloom"); - public static ShaderUtils kawaseUp = new ShaderUtils("kawaseUpBloom"); - public static Framebuffer framebuffer = new Framebuffer(1, 1, false); - private static int currentIterations; - - private static final List framebufferList = new ArrayList<>(); - - private static void initFramebuffers(float iterations) { - for (Framebuffer framebuffer : framebufferList) { - framebuffer.deleteFramebuffer(); - } - framebufferList.clear(); - - framebufferList.add(framebuffer = RenderUtils.createFrameBuffer(null, false)); - - for (int i = 1; i <= iterations; i++) { - Framebuffer currentBuffer = new Framebuffer((int) (mc.displayWidth / Math.pow(2, i)), (int) (mc.displayHeight / Math.pow(2, i)), false); - currentBuffer.setFramebufferFilter(GL_LINEAR); - - GlStateManager.bindTexture(currentBuffer.framebufferTexture); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL14.GL_MIRRORED_REPEAT); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL14.GL_MIRRORED_REPEAT); - GlStateManager.bindTexture(0); - - framebufferList.add(currentBuffer); - } - } - - - public static void renderBlur(int framebufferTexture, int iterations, float offset) { - if (currentIterations != iterations || (framebuffer.framebufferWidth != mc.displayWidth || framebuffer.framebufferHeight != mc.displayHeight)) { - initFramebuffers(iterations); - currentIterations = iterations; - } - - RenderUtils.setAlphaLimit(0); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_ONE, GL_ONE); - - GL11.glClearColor(0, 0, 0, 0); - - float currentOffset = offset; - renderFBO(framebufferList.get(1), framebufferTexture, kawaseDown, currentOffset); - - for (int i = 1; i < iterations; i++) { - currentOffset = offset / (float) Math.pow(1.5, i); - renderFBO(framebufferList.get(i + 1), framebufferList.get(i).framebufferTexture, kawaseDown, currentOffset); - } - - for (int i = iterations; i > 1; i--) { - currentOffset = offset / (float) Math.pow(1.5, i - 1); - renderFBO(framebufferList.get(i - 1), framebufferList.get(i).framebufferTexture, kawaseUp, currentOffset); - } - - Framebuffer lastBuffer = framebufferList.get(0); - lastBuffer.framebufferClear(); - lastBuffer.bindFramebuffer(false); - kawaseUp.init(); - kawaseUp.setUniformf("offset", offset, offset); - kawaseUp.setUniformi("inTexture", 0); - kawaseUp.setUniformi("check", 1); - kawaseUp.setUniformi("textureToCheck", 16); - kawaseUp.setUniformf("halfpixel", 1.0f / lastBuffer.framebufferWidth, 1.0f / lastBuffer.framebufferHeight); - kawaseUp.setUniformf("iResolution", lastBuffer.framebufferWidth, lastBuffer.framebufferHeight); - GlStateManager.setActiveTexture(GL13.GL_TEXTURE16); - RenderUtils.bindTexture(framebufferTexture); - GlStateManager.setActiveTexture(GL13.GL_TEXTURE0); - RenderUtils.bindTexture(framebufferList.get(1).framebufferTexture); - ShaderUtils.drawQuads(); - kawaseUp.unload(); - - - GlStateManager.clearColor(0, 0, 0, 0); - mc.getFramebuffer().bindFramebuffer(false); - RenderUtils.bindTexture(framebufferList.get(0).framebufferTexture); - RenderUtils.setAlphaLimit(0); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - ShaderUtils.drawQuads(); - GlStateManager.bindTexture(0); - RenderUtils.setAlphaLimit(0); - - // start blend - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - private static void renderFBO(Framebuffer framebuffer, int framebufferTexture, ShaderUtils shader, float offset) { - framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(false); - shader.init(); - RenderUtils.bindTexture(framebufferTexture); - shader.setUniformf("offset", offset, offset); - shader.setUniformi("inTexture", 0); - shader.setUniformi("check", 0); - shader.setUniformf("halfpixel", 1.0f / framebuffer.framebufferWidth, 1.0f / framebuffer.framebufferHeight); - shader.setUniformf("iResolution", framebuffer.framebufferWidth, framebuffer.framebufferHeight); - ShaderUtils.drawQuads(); - shader.unload(); - } -} +package keystrokesmod.utility.shader; + +import keystrokesmod.utility.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.shader.Framebuffer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL14; + +import java.util.ArrayList; +import java.util.List; + +import static org.lwjgl.opengl.GL11.*; + +public class KawaseBloom { + private static final Minecraft mc = Minecraft.getMinecraft(); + public static ShaderUtils kawaseDown = new ShaderUtils("kawaseDownBloom"); + public static ShaderUtils kawaseUp = new ShaderUtils("kawaseUpBloom"); + public static Framebuffer framebuffer = new Framebuffer(1, 1, false); + private static int currentIterations; + + private static final List framebufferList = new ArrayList<>(); + + private static void initFramebuffers(float iterations) { + for (Framebuffer framebuffer : framebufferList) { + framebuffer.deleteFramebuffer(); + } + framebufferList.clear(); + + framebufferList.add(framebuffer = RenderUtils.createFrameBuffer(null, false)); + + for (int i = 1; i <= iterations; i++) { + Framebuffer currentBuffer = new Framebuffer((int) (mc.displayWidth / Math.pow(2, i)), (int) (mc.displayHeight / Math.pow(2, i)), false); + currentBuffer.setFramebufferFilter(GL_LINEAR); + + GlStateManager.bindTexture(currentBuffer.framebufferTexture); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL14.GL_MIRRORED_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL14.GL_MIRRORED_REPEAT); + GlStateManager.bindTexture(0); + + framebufferList.add(currentBuffer); + } + } + + + public static void renderBlur(int framebufferTexture, int iterations, float offset) { + if (currentIterations != iterations || (framebuffer.framebufferWidth != mc.displayWidth || framebuffer.framebufferHeight != mc.displayHeight)) { + initFramebuffers(iterations); + currentIterations = iterations; + } + + RenderUtils.setAlphaLimit(0); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_ONE, GL_ONE); + + GL11.glClearColor(0, 0, 0, 0); + + float currentOffset = offset; + renderFBO(framebufferList.get(1), framebufferTexture, kawaseDown, currentOffset); + + for (int i = 1; i < iterations; i++) { + currentOffset = offset / (float) Math.pow(1.5, i); + renderFBO(framebufferList.get(i + 1), framebufferList.get(i).framebufferTexture, kawaseDown, currentOffset); + } + + for (int i = iterations; i > 1; i--) { + currentOffset = offset / (float) Math.pow(1.5, i - 1); + renderFBO(framebufferList.get(i - 1), framebufferList.get(i).framebufferTexture, kawaseUp, currentOffset); + } + + Framebuffer lastBuffer = framebufferList.get(0); + lastBuffer.framebufferClear(); + lastBuffer.bindFramebuffer(false); + kawaseUp.init(); + kawaseUp.setUniformf("offset", offset, offset); + kawaseUp.setUniformi("inTexture", 0); + kawaseUp.setUniformi("check", 1); + kawaseUp.setUniformi("textureToCheck", 16); + kawaseUp.setUniformf("halfpixel", 1.0f / lastBuffer.framebufferWidth, 1.0f / lastBuffer.framebufferHeight); + kawaseUp.setUniformf("iResolution", lastBuffer.framebufferWidth, lastBuffer.framebufferHeight); + GlStateManager.setActiveTexture(GL13.GL_TEXTURE16); + RenderUtils.bindTexture(framebufferTexture); + GlStateManager.setActiveTexture(GL13.GL_TEXTURE0); + RenderUtils.bindTexture(framebufferList.get(1).framebufferTexture); + ShaderUtils.drawQuads(); + kawaseUp.unload(); + + + GlStateManager.clearColor(0, 0, 0, 0); + mc.getFramebuffer().bindFramebuffer(false); + RenderUtils.bindTexture(framebufferList.get(0).framebufferTexture); + RenderUtils.setAlphaLimit(0); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + ShaderUtils.drawQuads(); + GlStateManager.bindTexture(0); + RenderUtils.setAlphaLimit(0); + + // start blend + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + private static void renderFBO(Framebuffer framebuffer, int framebufferTexture, ShaderUtils shader, float offset) { + framebuffer.framebufferClear(); + framebuffer.bindFramebuffer(false); + shader.init(); + RenderUtils.bindTexture(framebufferTexture); + shader.setUniformf("offset", offset, offset); + shader.setUniformi("inTexture", 0); + shader.setUniformi("check", 0); + shader.setUniformf("halfpixel", 1.0f / framebuffer.framebufferWidth, 1.0f / framebuffer.framebufferHeight); + shader.setUniformf("iResolution", framebuffer.framebufferWidth, framebuffer.framebufferHeight); + ShaderUtils.drawQuads(); + shader.unload(); + } +} diff --git a/src/main/java/keystrokesmod/utility/shader/KawaseBlur.java b/src/main/java/keystrokesmod/utility/shader/KawaseBlur.java index 2823084..8ce2129 100644 --- a/src/main/java/keystrokesmod/utility/shader/KawaseBlur.java +++ b/src/main/java/keystrokesmod/utility/shader/KawaseBlur.java @@ -1,103 +1,103 @@ -package keystrokesmod.utility.shader; - -import keystrokesmod.utility.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.shader.Framebuffer; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL13; -import org.lwjgl.opengl.GL14; - -import java.util.ArrayList; -import java.util.List; - -import static org.lwjgl.opengl.GL11.*; - -public class KawaseBlur { - private static final Minecraft mc = Minecraft.getMinecraft(); - public static ShaderUtils kawaseDown = new ShaderUtils("kawaseDown"); - public static ShaderUtils kawaseUp = new ShaderUtils("kawaseUp"); - public static Framebuffer framebuffer = new Framebuffer(1, 1, false); - private static int currentIterations; - - private static final List framebufferList = new ArrayList<>(); - - private static void initFrameBuffers(float iterations) { - for (Framebuffer framebuffer : framebufferList) { - framebuffer.deleteFramebuffer(); - } - framebufferList.clear(); - - framebufferList.add(framebuffer = RenderUtils.createFrameBuffer(null)); - - for (int i = 1; i <= iterations; i++) { - Framebuffer currentBuffer = new Framebuffer((int) (mc.displayWidth / Math.pow(3, i)), (int) (mc.displayHeight / Math.pow(3, i)), false); - currentBuffer.setFramebufferFilter(GL_LINEAR); - GlStateManager.bindTexture(currentBuffer.framebufferTexture); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL14.GL_MIRRORED_REPEAT); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL14.GL_MIRRORED_REPEAT); - GlStateManager.bindTexture(0); - - framebufferList.add(currentBuffer); - } - } - - public static void renderBlur(int stencilFrameBufferTexture, int iterations, float offset) { - if (currentIterations != iterations || framebuffer.framebufferWidth != mc.displayWidth || framebuffer.framebufferHeight != mc.displayHeight) { - initFrameBuffers(iterations); - currentIterations = iterations; - } - - renderFBO(framebufferList.get(1), mc.getFramebuffer().framebufferTexture, kawaseDown, offset); - - for (int i = 1; i < iterations; i++) { - renderFBO(framebufferList.get(i + 1), framebufferList.get(i).framebufferTexture, kawaseDown, offset); - } - - for (int i = iterations; i > 1; i--) { - renderFBO(framebufferList.get(i - 1), framebufferList.get(i).framebufferTexture, kawaseUp, offset); - } - - - Framebuffer lastBuffer = framebufferList.get(0); - lastBuffer.framebufferClear(); - lastBuffer.bindFramebuffer(false); - - kawaseUp.init(); - kawaseUp.setUniformf("offset", offset, offset); - kawaseUp.setUniformi("inTexture", 0); - kawaseUp.setUniformi("check", 1); - kawaseUp.setUniformi("textureToCheck", 16); - kawaseUp.setUniformf("halfpixel", 1.0f / lastBuffer.framebufferWidth, 1.0f / lastBuffer.framebufferHeight); - kawaseUp.setUniformf("iResolution", lastBuffer.framebufferWidth, lastBuffer.framebufferHeight); - GL13.glActiveTexture(GL13.GL_TEXTURE16); - RenderUtils.bindTexture(stencilFrameBufferTexture); - GL13.glActiveTexture(GL13.GL_TEXTURE0); - RenderUtils.bindTexture(framebufferList.get(1).framebufferTexture); - ShaderUtils.drawQuads(); - kawaseUp.unload(); - - mc.getFramebuffer().bindFramebuffer(true); - RenderUtils.bindTexture(framebufferList.get(0).framebufferTexture); - RenderUtils.setAlphaLimit(0); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - ShaderUtils.drawQuads(); - GlStateManager.bindTexture(0); - GlStateManager.disableBlend(); - } - - private static void renderFBO(Framebuffer framebuffer, int framebufferTexture, ShaderUtils shader, float offset) { - framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(false); - shader.init(); - RenderUtils.bindTexture(framebufferTexture); - shader.setUniformf("offset", offset, offset); - shader.setUniformi("inTexture", 0); - shader.setUniformi("check", 0); - shader.setUniformf("halfpixel", 1.0f / framebuffer.framebufferWidth, 1.0f / framebuffer.framebufferHeight); - shader.setUniformf("iResolution", framebuffer.framebufferWidth, framebuffer.framebufferHeight); - ShaderUtils.drawQuads(); - shader.unload(); - } -} +package keystrokesmod.utility.shader; + +import keystrokesmod.utility.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.shader.Framebuffer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL14; + +import java.util.ArrayList; +import java.util.List; + +import static org.lwjgl.opengl.GL11.*; + +public class KawaseBlur { + private static final Minecraft mc = Minecraft.getMinecraft(); + public static ShaderUtils kawaseDown = new ShaderUtils("kawaseDown"); + public static ShaderUtils kawaseUp = new ShaderUtils("kawaseUp"); + public static Framebuffer framebuffer = new Framebuffer(1, 1, false); + private static int currentIterations; + + private static final List framebufferList = new ArrayList<>(); + + private static void initFrameBuffers(float iterations) { + for (Framebuffer framebuffer : framebufferList) { + framebuffer.deleteFramebuffer(); + } + framebufferList.clear(); + + framebufferList.add(framebuffer = RenderUtils.createFrameBuffer(null)); + + for (int i = 1; i <= iterations; i++) { + Framebuffer currentBuffer = new Framebuffer((int) (mc.displayWidth / Math.pow(3, i)), (int) (mc.displayHeight / Math.pow(3, i)), false); + currentBuffer.setFramebufferFilter(GL_LINEAR); + GlStateManager.bindTexture(currentBuffer.framebufferTexture); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL14.GL_MIRRORED_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL14.GL_MIRRORED_REPEAT); + GlStateManager.bindTexture(0); + + framebufferList.add(currentBuffer); + } + } + + public static void renderBlur(int stencilFrameBufferTexture, int iterations, float offset) { + if (currentIterations != iterations || framebuffer.framebufferWidth != mc.displayWidth || framebuffer.framebufferHeight != mc.displayHeight) { + initFrameBuffers(iterations); + currentIterations = iterations; + } + + renderFBO(framebufferList.get(1), mc.getFramebuffer().framebufferTexture, kawaseDown, offset); + + for (int i = 1; i < iterations; i++) { + renderFBO(framebufferList.get(i + 1), framebufferList.get(i).framebufferTexture, kawaseDown, offset); + } + + for (int i = iterations; i > 1; i--) { + renderFBO(framebufferList.get(i - 1), framebufferList.get(i).framebufferTexture, kawaseUp, offset); + } + + + Framebuffer lastBuffer = framebufferList.get(0); + lastBuffer.framebufferClear(); + lastBuffer.bindFramebuffer(false); + + kawaseUp.init(); + kawaseUp.setUniformf("offset", offset, offset); + kawaseUp.setUniformi("inTexture", 0); + kawaseUp.setUniformi("check", 1); + kawaseUp.setUniformi("textureToCheck", 16); + kawaseUp.setUniformf("halfpixel", 1.0f / lastBuffer.framebufferWidth, 1.0f / lastBuffer.framebufferHeight); + kawaseUp.setUniformf("iResolution", lastBuffer.framebufferWidth, lastBuffer.framebufferHeight); + GL13.glActiveTexture(GL13.GL_TEXTURE16); + RenderUtils.bindTexture(stencilFrameBufferTexture); + GL13.glActiveTexture(GL13.GL_TEXTURE0); + RenderUtils.bindTexture(framebufferList.get(1).framebufferTexture); + ShaderUtils.drawQuads(); + kawaseUp.unload(); + + mc.getFramebuffer().bindFramebuffer(true); + RenderUtils.bindTexture(framebufferList.get(0).framebufferTexture); + RenderUtils.setAlphaLimit(0); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + ShaderUtils.drawQuads(); + GlStateManager.bindTexture(0); + GlStateManager.disableBlend(); + } + + private static void renderFBO(Framebuffer framebuffer, int framebufferTexture, ShaderUtils shader, float offset) { + framebuffer.framebufferClear(); + framebuffer.bindFramebuffer(false); + shader.init(); + RenderUtils.bindTexture(framebufferTexture); + shader.setUniformf("offset", offset, offset); + shader.setUniformi("inTexture", 0); + shader.setUniformi("check", 0); + shader.setUniformf("halfpixel", 1.0f / framebuffer.framebufferWidth, 1.0f / framebuffer.framebufferHeight); + shader.setUniformf("iResolution", framebuffer.framebufferWidth, framebuffer.framebufferHeight); + ShaderUtils.drawQuads(); + shader.unload(); + } +} diff --git a/src/main/java/keystrokesmod/utility/shader/RoundedUtils.java b/src/main/java/keystrokesmod/utility/shader/RoundedUtils.java index 234dba4..7dc1119 100644 --- a/src/main/java/keystrokesmod/utility/shader/RoundedUtils.java +++ b/src/main/java/keystrokesmod/utility/shader/RoundedUtils.java @@ -1,198 +1,198 @@ -package keystrokesmod.utility.shader; - -import keystrokesmod.utility.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL20; - -import java.awt.*; - -import static org.lwjgl.opengl.GL11.*; - -public class RoundedUtils { - public static ShaderUtils roundedShader = new ShaderUtils("roundedRect"); - public static ShaderUtils roundedOutlineShader = new ShaderUtils("roundRectOutline"); - private static final ShaderUtils roundedTexturedShader = new ShaderUtils("roundRectTexture"); - private static final ShaderUtils roundedGradientShader = new ShaderUtils("roundedRectGradient"); - private static final ShaderUtils roundedRectRiseShader = new ShaderUtils("roundedRectRise"); - - - public static void drawRound(float x, float y, float width, float height, float radius, Color color) { - drawRound(x, y, width, height, radius, false, color); - } - - public static void drawGradientHorizontal(float x, float y, float width, float height, float radius, Color left, Color right) { - drawGradientRound(x, y, width, height, radius, left, left, right, right); - } - - public static void drawGradientVertical(float x, float y, float width, float height, float radius, Color top, Color bottom) { - drawGradientRound(x, y, width, height, radius, bottom, top, bottom, top); - } - - public static void drawGradientCornerLR(float x, float y, float width, float height, float radius, Color topLeft, Color bottomRight) { - Color mixedColor = RenderUtils.interpolateColorC(topLeft, bottomRight, .5f); - drawGradientRound(x, y, width, height, radius, mixedColor, topLeft, bottomRight, mixedColor); - } - - public static void drawGradientCornerRL(float x, float y, float width, float height, float radius, Color bottomLeft, Color topRight) { - Color mixedColor = RenderUtils.interpolateColorC(topRight, bottomLeft, .5f); - drawGradientRound(x, y, width, height, radius, bottomLeft, mixedColor, mixedColor, topRight); - } - - public static void drawRound(float x, float y, float width, float height, float radius, int color) { - drawRound(x, y, width, height, radius, false, color); - } - - public static void drawRound(float x, float y, float width, float height, float radius, boolean blur, int color) { - RenderUtils.resetColor(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - RenderUtils.setAlphaLimit(0); - - roundedShader.init(); - setupRoundedRectUniforms(x, y, width, height, radius, roundedShader); - roundedShader.setUniformi("blur", blur ? 1 : 0); - roundedShader.setUniformf("color", getRed(color), getGreen(color), getBlue(color), getAlpha(color)); - - ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); - roundedShader.unload(); - GlStateManager.disableBlend(); - } - - public static void drawGradientRound(float x, float y, float width, float height, float radius, Color bottomLeft, Color topLeft, Color bottomRight, Color topRight) { - RenderUtils.setAlphaLimit(0); - RenderUtils.resetColor(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - roundedGradientShader.init(); - setupRoundedRectUniforms(x, y, width, height, radius, roundedGradientShader); - roundedGradientShader.setUniformf("color1", topLeft.getRed() / 255f, topLeft.getGreen() / 255f, topLeft.getBlue() / 255f, topLeft.getAlpha() / 255f); - roundedGradientShader.setUniformf("color2", bottomLeft.getRed() / 255f, bottomLeft.getGreen() / 255f, bottomLeft.getBlue() / 255f, bottomLeft.getAlpha() / 255f); - roundedGradientShader.setUniformf("color3", topRight.getRed() / 255f, topRight.getGreen() / 255f, topRight.getBlue() / 255f, topRight.getAlpha() / 255f); - roundedGradientShader.setUniformf("color4", bottomRight.getRed() / 255f, bottomRight.getGreen() / 255f, bottomRight.getBlue() / 255f, bottomRight.getAlpha() / 255f); - ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); - roundedGradientShader.unload(); - GlStateManager.disableBlend(); - } - - public static void drawGradientRound(float x, float y, float width, float height, float radius, int bottomLeft, int topLeft, int bottomRight, int topRight) { - RenderUtils.setAlphaLimit(0); - RenderUtils.resetColor(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - roundedGradientShader.init(); - setupRoundedRectUniforms(x, y, width, height, radius, roundedGradientShader); - - roundedGradientShader.setUniformf("color1", getRed(topLeft), getGreen(topLeft), getBlue(topLeft), getAlpha(topLeft)); - roundedGradientShader.setUniformf("color2", getRed(bottomLeft), getGreen(bottomLeft), getBlue(bottomLeft), getAlpha(bottomLeft)); - roundedGradientShader.setUniformf("color3", getRed(topRight), getGreen(topRight), getBlue(topRight), getAlpha(topRight)); - roundedGradientShader.setUniformf("color4", getRed(bottomRight), getGreen(bottomRight), getBlue(bottomRight), getAlpha(bottomRight)); - - ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); - roundedGradientShader.unload(); - GlStateManager.disableBlend(); - } - - public static void drawRound(float x, float y, float width, float height, float radius, boolean blur, Color color) { - RenderUtils.resetColor(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - RenderUtils.setAlphaLimit(0); - roundedShader.init(); - - setupRoundedRectUniforms(x, y, width, height, radius, roundedShader); - roundedShader.setUniformi("blur", blur ? 1 : 0); - roundedShader.setUniformf("color", color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); - - ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); - roundedShader.unload(); - GlStateManager.disableBlend(); - } - - - public static void drawRoundOutline(float x, float y, float width, float height, float radius, float outlineThickness, Color color, Color outlineColor) { - RenderUtils.resetColor(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - RenderUtils.setAlphaLimit(0); - roundedOutlineShader.init(); - - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - setupRoundedRectUniforms(x, y, width, height, radius, roundedOutlineShader); - roundedOutlineShader.setUniformf("outlineThickness", outlineThickness * sr.getScaleFactor()); - roundedOutlineShader.setUniformf("color", color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); - roundedOutlineShader.setUniformf("outlineColor", outlineColor.getRed() / 255f, outlineColor.getGreen() / 255f, outlineColor.getBlue() / 255f, outlineColor.getAlpha() / 255f); - - - ShaderUtils.drawQuads(x - (2 + outlineThickness), y - (2 + outlineThickness), width + (4 + outlineThickness * 2), height + (4 + outlineThickness * 2)); - roundedOutlineShader.unload(); - GlStateManager.disableBlend(); - } - - - public static void drawRoundTextured(float x, float y, float width, float height, float radius, float alpha) { - RenderUtils.resetColor(); - RenderUtils.setAlphaLimit(0); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - roundedTexturedShader.init(); - roundedTexturedShader.setUniformi("textureIn", 0); - setupRoundedRectUniforms(x, y, width, height, radius, roundedTexturedShader); - roundedTexturedShader.setUniformf("alpha", alpha); - ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); - roundedTexturedShader.unload(); - GlStateManager.disableBlend(); - } - - private static void setupRoundedRectUniforms(float x, float y, float width, float height, float radius, ShaderUtils roundedTexturedShader) { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - roundedTexturedShader.setUniformf("location", x * sr.getScaleFactor(), - (Minecraft.getMinecraft().displayHeight - (height * sr.getScaleFactor())) - (y * sr.getScaleFactor())); - roundedTexturedShader.setUniformf("rectSize", width * sr.getScaleFactor(), height * sr.getScaleFactor()); - roundedTexturedShader.setUniformf("radius", radius * sr.getScaleFactor()); - } - - public static void drawRoundedRectRise(final float x, final float y, final float width, final float height, final float radius, final int color, boolean leftTop, boolean rightTop, boolean rightBottom, boolean leftBottom) { - GL11.glPushMatrix(); - GlStateManager.pushAttrib(); - final int programId = roundedRectRiseShader.programID; - GL20.glUseProgram(programId); - roundedRectRiseShader.setUniformf("u_size", width, height); - roundedRectRiseShader.setUniformf("u_radius", radius); - roundedRectRiseShader.setUniformf("u_color", getRed(color), getGreen(color), getBlue(color), getAlpha(color)); - roundedRectRiseShader.setUniformf("u_edges", leftTop ? 1.0F : 0.0F, rightTop ? 1.0F : 0.0F, rightBottom ? 1.0F : 0.0F, leftBottom ? 1.0F : 0.0F); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - ShaderUtils.drawQuads(x, y, width, height); - GlStateManager.disableBlend(); - GL20.glUseProgram(0); - GlStateManager.popAttrib(); - GL11.glPopMatrix(); - } - - public static void drawRoundedRectRise(final double x, final double y, final double width, final double height, final double radius, final int color) { - drawRoundedRectRise((float) x, (float) y, (float) width, (float) height, (float) radius, color, true, true, true, true); - } - - private static float getRed(int color) { - return (color >> 16 & 0xFF) / 255.0F; - } - - private static float getGreen(int color) { - return (color >> 8 & 0xFF) / 255.0F; - } - - private static float getBlue(int color) { - return (color & 0xFF) / 255.0F; - } - - private static float getAlpha(int color) { - return (color >> 24 & 0xFF) / 255.0F; - } -} +package keystrokesmod.utility.shader; + +import keystrokesmod.utility.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; + +import java.awt.*; + +import static org.lwjgl.opengl.GL11.*; + +public class RoundedUtils { + public static ShaderUtils roundedShader = new ShaderUtils("roundedRect"); + public static ShaderUtils roundedOutlineShader = new ShaderUtils("roundRectOutline"); + private static final ShaderUtils roundedTexturedShader = new ShaderUtils("roundRectTexture"); + private static final ShaderUtils roundedGradientShader = new ShaderUtils("roundedRectGradient"); + private static final ShaderUtils roundedRectRiseShader = new ShaderUtils("roundedRectRise"); + + + public static void drawRound(float x, float y, float width, float height, float radius, Color color) { + drawRound(x, y, width, height, radius, false, color); + } + + public static void drawGradientHorizontal(float x, float y, float width, float height, float radius, Color left, Color right) { + drawGradientRound(x, y, width, height, radius, left, left, right, right); + } + + public static void drawGradientVertical(float x, float y, float width, float height, float radius, Color top, Color bottom) { + drawGradientRound(x, y, width, height, radius, bottom, top, bottom, top); + } + + public static void drawGradientCornerLR(float x, float y, float width, float height, float radius, Color topLeft, Color bottomRight) { + Color mixedColor = RenderUtils.interpolateColorC(topLeft, bottomRight, .5f); + drawGradientRound(x, y, width, height, radius, mixedColor, topLeft, bottomRight, mixedColor); + } + + public static void drawGradientCornerRL(float x, float y, float width, float height, float radius, Color bottomLeft, Color topRight) { + Color mixedColor = RenderUtils.interpolateColorC(topRight, bottomLeft, .5f); + drawGradientRound(x, y, width, height, radius, bottomLeft, mixedColor, mixedColor, topRight); + } + + public static void drawRound(float x, float y, float width, float height, float radius, int color) { + drawRound(x, y, width, height, radius, false, color); + } + + public static void drawRound(float x, float y, float width, float height, float radius, boolean blur, int color) { + RenderUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + RenderUtils.setAlphaLimit(0); + + roundedShader.init(); + setupRoundedRectUniforms(x, y, width, height, radius, roundedShader); + roundedShader.setUniformi("blur", blur ? 1 : 0); + roundedShader.setUniformf("color", getRed(color), getGreen(color), getBlue(color), getAlpha(color)); + + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedShader.unload(); + GlStateManager.disableBlend(); + } + + public static void drawGradientRound(float x, float y, float width, float height, float radius, Color bottomLeft, Color topLeft, Color bottomRight, Color topRight) { + RenderUtils.setAlphaLimit(0); + RenderUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + roundedGradientShader.init(); + setupRoundedRectUniforms(x, y, width, height, radius, roundedGradientShader); + roundedGradientShader.setUniformf("color1", topLeft.getRed() / 255f, topLeft.getGreen() / 255f, topLeft.getBlue() / 255f, topLeft.getAlpha() / 255f); + roundedGradientShader.setUniformf("color2", bottomLeft.getRed() / 255f, bottomLeft.getGreen() / 255f, bottomLeft.getBlue() / 255f, bottomLeft.getAlpha() / 255f); + roundedGradientShader.setUniformf("color3", topRight.getRed() / 255f, topRight.getGreen() / 255f, topRight.getBlue() / 255f, topRight.getAlpha() / 255f); + roundedGradientShader.setUniformf("color4", bottomRight.getRed() / 255f, bottomRight.getGreen() / 255f, bottomRight.getBlue() / 255f, bottomRight.getAlpha() / 255f); + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedGradientShader.unload(); + GlStateManager.disableBlend(); + } + + public static void drawGradientRound(float x, float y, float width, float height, float radius, int bottomLeft, int topLeft, int bottomRight, int topRight) { + RenderUtils.setAlphaLimit(0); + RenderUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + roundedGradientShader.init(); + setupRoundedRectUniforms(x, y, width, height, radius, roundedGradientShader); + + roundedGradientShader.setUniformf("color1", getRed(topLeft), getGreen(topLeft), getBlue(topLeft), getAlpha(topLeft)); + roundedGradientShader.setUniformf("color2", getRed(bottomLeft), getGreen(bottomLeft), getBlue(bottomLeft), getAlpha(bottomLeft)); + roundedGradientShader.setUniformf("color3", getRed(topRight), getGreen(topRight), getBlue(topRight), getAlpha(topRight)); + roundedGradientShader.setUniformf("color4", getRed(bottomRight), getGreen(bottomRight), getBlue(bottomRight), getAlpha(bottomRight)); + + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedGradientShader.unload(); + GlStateManager.disableBlend(); + } + + public static void drawRound(float x, float y, float width, float height, float radius, boolean blur, Color color) { + RenderUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + RenderUtils.setAlphaLimit(0); + roundedShader.init(); + + setupRoundedRectUniforms(x, y, width, height, radius, roundedShader); + roundedShader.setUniformi("blur", blur ? 1 : 0); + roundedShader.setUniformf("color", color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedShader.unload(); + GlStateManager.disableBlend(); + } + + + public static void drawRoundOutline(float x, float y, float width, float height, float radius, float outlineThickness, Color color, Color outlineColor) { + RenderUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + RenderUtils.setAlphaLimit(0); + roundedOutlineShader.init(); + + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + setupRoundedRectUniforms(x, y, width, height, radius, roundedOutlineShader); + roundedOutlineShader.setUniformf("outlineThickness", outlineThickness * sr.getScaleFactor()); + roundedOutlineShader.setUniformf("color", color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + roundedOutlineShader.setUniformf("outlineColor", outlineColor.getRed() / 255f, outlineColor.getGreen() / 255f, outlineColor.getBlue() / 255f, outlineColor.getAlpha() / 255f); + + + ShaderUtils.drawQuads(x - (2 + outlineThickness), y - (2 + outlineThickness), width + (4 + outlineThickness * 2), height + (4 + outlineThickness * 2)); + roundedOutlineShader.unload(); + GlStateManager.disableBlend(); + } + + + public static void drawRoundTextured(float x, float y, float width, float height, float radius, float alpha) { + RenderUtils.resetColor(); + RenderUtils.setAlphaLimit(0); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + roundedTexturedShader.init(); + roundedTexturedShader.setUniformi("textureIn", 0); + setupRoundedRectUniforms(x, y, width, height, radius, roundedTexturedShader); + roundedTexturedShader.setUniformf("alpha", alpha); + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedTexturedShader.unload(); + GlStateManager.disableBlend(); + } + + private static void setupRoundedRectUniforms(float x, float y, float width, float height, float radius, ShaderUtils roundedTexturedShader) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + roundedTexturedShader.setUniformf("location", x * sr.getScaleFactor(), + (Minecraft.getMinecraft().displayHeight - (height * sr.getScaleFactor())) - (y * sr.getScaleFactor())); + roundedTexturedShader.setUniformf("rectSize", width * sr.getScaleFactor(), height * sr.getScaleFactor()); + roundedTexturedShader.setUniformf("radius", radius * sr.getScaleFactor()); + } + + public static void drawRoundedRectRise(final float x, final float y, final float width, final float height, final float radius, final int color, boolean leftTop, boolean rightTop, boolean rightBottom, boolean leftBottom) { + GL11.glPushMatrix(); + GlStateManager.pushAttrib(); + final int programId = roundedRectRiseShader.programID; + GL20.glUseProgram(programId); + roundedRectRiseShader.setUniformf("u_size", width, height); + roundedRectRiseShader.setUniformf("u_radius", radius); + roundedRectRiseShader.setUniformf("u_color", getRed(color), getGreen(color), getBlue(color), getAlpha(color)); + roundedRectRiseShader.setUniformf("u_edges", leftTop ? 1.0F : 0.0F, rightTop ? 1.0F : 0.0F, rightBottom ? 1.0F : 0.0F, leftBottom ? 1.0F : 0.0F); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + ShaderUtils.drawQuads(x, y, width, height); + GlStateManager.disableBlend(); + GL20.glUseProgram(0); + GlStateManager.popAttrib(); + GL11.glPopMatrix(); + } + + public static void drawRoundedRectRise(final double x, final double y, final double width, final double height, final double radius, final int color) { + drawRoundedRectRise((float) x, (float) y, (float) width, (float) height, (float) radius, color, true, true, true, true); + } + + private static float getRed(int color) { + return (color >> 16 & 0xFF) / 255.0F; + } + + private static float getGreen(int color) { + return (color >> 8 & 0xFF) / 255.0F; + } + + private static float getBlue(int color) { + return (color & 0xFF) / 255.0F; + } + + private static float getAlpha(int color) { + return (color >> 24 & 0xFF) / 255.0F; + } +} diff --git a/src/main/java/keystrokesmod/utility/shader/ShaderUtils.java b/src/main/java/keystrokesmod/utility/shader/ShaderUtils.java index 94f20a7..b2a070c 100644 --- a/src/main/java/keystrokesmod/utility/shader/ShaderUtils.java +++ b/src/main/java/keystrokesmod/utility/shader/ShaderUtils.java @@ -1,501 +1,501 @@ -package keystrokesmod.utility.shader; - -import keystrokesmod.utility.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL20; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL20.*; - -public class ShaderUtils { - - private Minecraft mc = Minecraft.getMinecraft(); - public final int programID; - private final String kawaseUpGlow = "#version 120\n" + - "\n" + - "uniform sampler2D inTexture, textureToCheck;\n" + - "uniform vec2 halfpixel, offset, iResolution;\n" + - "uniform bool check;\n" + - "uniform float lastPass;\n" + - "uniform float exposure;\n" + - "\n" + - "void main() {\n" + - " if(check && texture2D(textureToCheck, gl_TexCoord[0].st).a != 0.0) discard;\n" + - " vec2 uv = vec2(gl_FragCoord.xy / iResolution);\n" + - "\n" + - " vec4 sum = texture2D(inTexture, uv + vec2(-halfpixel.x * 2.0, 0.0) * offset);\n" + - " sum.rgb *= sum.a;\n" + - " vec4 smpl1 = texture2D(inTexture, uv + vec2(-halfpixel.x, halfpixel.y) * offset);\n" + - " smpl1.rgb *= smpl1.a;\n" + - " sum += smpl1 * 2.0;\n" + - " vec4 smp2 = texture2D(inTexture, uv + vec2(0.0, halfpixel.y * 2.0) * offset);\n" + - " smp2.rgb *= smp2.a;\n" + - " sum += smp2;\n" + - " vec4 smp3 = texture2D(inTexture, uv + vec2(halfpixel.x, halfpixel.y) * offset);\n" + - " smp3.rgb *= smp3.a;\n" + - " sum += smp3 * 2.0;\n" + - " vec4 smp4 = texture2D(inTexture, uv + vec2(halfpixel.x * 2.0, 0.0) * offset);\n" + - " smp4.rgb *= smp4.a;\n" + - " sum += smp4;\n" + - " vec4 smp5 = texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + - " smp5.rgb *= smp5.a;\n" + - " sum += smp5 * 2.0;\n" + - " vec4 smp6 = texture2D(inTexture, uv + vec2(0.0, -halfpixel.y * 2.0) * offset);\n" + - " smp6.rgb *= smp6.a;\n" + - " sum += smp6;\n" + - " vec4 smp7 = texture2D(inTexture, uv + vec2(-halfpixel.x, -halfpixel.y) * offset);\n" + - " smp7.rgb *= smp7.a;\n" + - " sum += smp7 * 2.0;\n" + - " vec4 result = sum / 12.0;\n" + - " gl_FragColor = vec4(result.rgb / result.a, mix(result.a, 1.0 - exp(-result.a * exposure), step(0.0, lastPass)));\n" + - "}"; - private final String glowShader = "#version 120\n" + - "\n" + - "uniform sampler2D textureIn, textureToCheck;\n" + - "uniform vec2 texelSize, direction;\n" + - "uniform vec3 color;\n" + - "uniform bool avoidTexture;\n" + - "uniform float exposure, radius;\n" + - "uniform float weights[256];\n" + - "\n" + - "#define offset direction * texelSize\n" + - "\n" + - "void main() {\n" + - " if (direction.y == 1 && avoidTexture) {\n" + - " if (texture2D(textureToCheck, gl_TexCoord[0].st).a != 0.0) discard;\n" + - " }\n" + - " vec4 innerColor = texture2D(textureIn, gl_TexCoord[0].st);\n" + - " innerColor.rgb *= innerColor.a;\n" + - " innerColor *= weights[0];\n" + - " for (float r = 1.0; r <= radius; r++) {\n" + - " vec4 colorCurrent1 = texture2D(textureIn, gl_TexCoord[0].st + offset * r);\n" + - " vec4 colorCurrent2 = texture2D(textureIn, gl_TexCoord[0].st - offset * r);\n" + - "\n" + - " colorCurrent1.rgb *= colorCurrent1.a;\n" + - " colorCurrent2.rgb *= colorCurrent2.a;\n" + - "\n" + - " innerColor += (colorCurrent1 + colorCurrent2) * weights[int(r)];\n" + - " }\n" + - "\n" + - " gl_FragColor = vec4(innerColor.rgb / innerColor.a, mix(innerColor.a, 1.0 - exp(-innerColor.a * exposure), step(0.0, direction.y)));\n" + - "}\n"; - private final String roundRectTexture = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform sampler2D textureIn;\n" + - "uniform float radius, alpha;\n" + - "\n" + - "float roundedBoxSDF(vec2 centerPos, vec2 size, float radius) {\n" + - " return length(max(abs(centerPos) -size, 0.)) - radius;\n" + - "}\n" + - "\n" + - "\n" + - "void main() {\n" + - " float distance = roundedBoxSDF((rectSize * .5) - (gl_TexCoord[0].st * rectSize), (rectSize * .5) - radius - 1., radius);\n" + - " float smoothedAlpha = (1.0-smoothstep(0.0, 2.0, distance)) * alpha;\n" + - " gl_FragColor = vec4(texture2D(textureIn, gl_TexCoord[0].st).rgb, smoothedAlpha);\n" + - "}"; - private final String roundRectOutline = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform vec4 color, outlineColor;\n" + - "uniform float radius, outlineThickness;\n" + - "\n" + - "float roundedSDF(vec2 centerPos, vec2 size, float radius) {\n" + - " return length(max(abs(centerPos) - size + radius, 0.0)) - radius;\n" + - "}\n" + - "\n" + - "void main() {\n" + - " float distance = roundedSDF(gl_FragCoord.xy - location - (rectSize * .5), (rectSize * .5) + (outlineThickness *.5) - 1.0, radius);\n" + - "\n" + - " float blendAmount = smoothstep(0., 2., abs(distance) - (outlineThickness * .5));\n" + - "\n" + - " vec4 insideColor = (distance < 0.) ? color : vec4(outlineColor.rgb, 0.0);\n" + - " gl_FragColor = mix(outlineColor, insideColor, blendAmount);\n" + - "\n" + - "}"; - private final String kawaseUpBloom = "#version 120\n" + - "\n" + - "uniform sampler2D inTexture, textureToCheck;\n" + - "uniform vec2 halfpixel, offset, iResolution;\n" + - "uniform int check;\n" + - "\n" + - "void main() {\n" + - " vec2 uv = gl_FragCoord.xy / iResolution;\n" + - "\n" + - " vec2 offset1 = vec2(-halfpixel.x, 0.0) * offset;\n" + - " vec2 offset2 = vec2(-halfpixel.x, halfpixel.y) * offset;\n" + - " vec2 offset3 = vec2(0.0, halfpixel.y * 2.0) * offset;\n" + - " vec2 offset4 = vec2(halfpixel.x, halfpixel.y) * offset;\n" + - " vec2 offset5 = vec2(halfpixel.x * 2.0, 0.0) * offset;\n" + - " vec2 offset6 = vec2(halfpixel.x, -halfpixel.y) * offset;\n" + - " vec2 offset7 = vec2(0.0, -halfpixel.y * 2.0) * offset;\n" + - " vec2 offset8 = vec2(-halfpixel.x, -halfpixel.y) * offset;\n" + - "\n" + - " vec4 sum = texture2D(inTexture, uv + offset1);\n" + - " sum.rgb *= sum.a;\n" + - " vec4 smpl1 = texture2D(inTexture, uv + offset2);\n" + - " smpl1.rgb *= smpl1.a;\n" + - " sum += smpl1 * 2.0;\n" + - " vec4 smp2 = texture2D(inTexture, uv + offset3);\n" + - " smp2.rgb *= smp2.a;\n" + - " sum += smp2;\n" + - " vec4 smp3 = texture2D(inTexture, uv + offset4);\n" + - " smp3.rgb *= smp3.a;\n" + - " sum += smp3 * 2.0;\n" + - " vec4 smp4 = texture2D(inTexture, uv + offset5);\n" + - " smp4.rgb *= smp4.a;\n" + - " sum += smp4;\n" + - " vec4 smp5 = texture2D(inTexture, uv + offset6);\n" + - " smp5.rgb *= smp5.a;\n" + - " sum += smp5 * 2.0;\n" + - " vec4 smp6 = texture2D(inTexture, uv + offset7);\n" + - " smp6.rgb *= smp6.a;\n" + - " sum += smp6;\n" + - " vec4 smp7 = texture2D(inTexture, uv + offset8);\n" + - " smp7.rgb *= smp7.a;\n" + - " sum += smp7 * 2.0;\n" + - "\n" + - " vec4 result = sum / 12.0;\n" + - " float checkAlpha = texture2D(textureToCheck, gl_TexCoord[0].st).a;\n" + - " gl_FragColor = vec4(result.rgb / result.a, mix(result.a, result.a * (1.0 - checkAlpha), float(check)));\n" + - "}\n"; - private final String kawaseDownBloom = "#version 120\n" + - "\n" + - "uniform sampler2D inTexture;\n" + - "uniform vec2 offset, halfpixel, iResolution;\n" + - "\n" + - "void main() {\n" + - " vec2 uv = gl_FragCoord.xy / iResolution;\n" + - "\n" + - " vec4 sum = texture2D(inTexture, uv);\n" + - " sum.rgb *= sum.a;\n" + - " sum *= 4.0;\n" + - " vec4 smp1 = texture2D(inTexture, uv - halfpixel.xy * offset);\n" + - " smp1.rgb *= smp1.a;\n" + - " sum += smp1;\n" + - " vec4 smp2 = texture2D(inTexture, uv + halfpixel.xy * offset);\n" + - " smp2.rgb *= smp2.a;\n" + - " sum += smp2;\n" + - " vec4 smp3 = texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + - " smp3.rgb *= smp3.a;\n" + - " sum += smp3;\n" + - " vec4 smp4 = texture2D(inTexture, uv - vec2(halfpixel.x, -halfpixel.y) * offset);\n" + - " smp4.rgb *= smp4.a;\n" + - " sum += smp4;\n" + - " vec4 result = sum / 8.0;\n" + - " gl_FragColor = vec4(result.rgb / result.a, result.a);\n" + - "}\n"; - private final String kawaseUp = "#version 120\n" + - "\n" + - "uniform sampler2D inTexture, textureToCheck;\n" + - "uniform vec2 halfpixel, offset, iResolution;\n" + - "uniform int check;\n" + - "\n" + - "void main() {\n" + - " vec2 uv = gl_FragCoord.xy / iResolution;\n" + - "\n" + - " vec4 sum = texture2D(inTexture, uv + vec2(-halfpixel.x * 2.0, 0.0) * offset);\n" + - " sum += texture2D(inTexture, uv + vec2(-halfpixel.x, halfpixel.y) * offset) * 2.0;\n" + - " sum += texture2D(inTexture, uv + vec2(0.0, halfpixel.y * 2.0) * offset);\n" + - " sum += texture2D(inTexture, uv + vec2(halfpixel.x, halfpixel.y) * offset) * 2.0;\n" + - " sum += texture2D(inTexture, uv + vec2(halfpixel.x * 2.0, 0.0) * offset);\n" + - " sum += texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset) * 2.0;\n" + - " sum += texture2D(inTexture, uv + vec2(0.0, -halfpixel.y * 2.0) * offset);\n" + - " sum += texture2D(inTexture, uv + vec2(-halfpixel.x, -halfpixel.y) * offset) * 2.0;\n" + - "\n" + - " vec4 average = sum / 12.0;\n" + - " gl_FragColor = vec4(average.rgb, mix(1.0, texture2D(textureToCheck, gl_TexCoord[0].st).a, check));\n" + - "}"; - private final String kawaseDown = "#version 120\n" + - "\n" + - "uniform sampler2D inTexture;\n" + - "uniform vec2 offset, halfpixel, iResolution;\n" + - "\n" + - "void main() {\n" + - " vec2 uv = gl_FragCoord.xy / iResolution;\n" + - "\n" + - " vec4 sum = texture2D(inTexture, uv) * 4.0;\n" + - " sum += texture2D(inTexture, uv - halfpixel.xy * offset);\n" + - " sum += texture2D(inTexture, uv + halfpixel.xy * offset);\n" + - " sum += texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + - " sum += texture2D(inTexture, uv - vec2(halfpixel.x, -halfpixel.y) * offset);\n" + - "\n" + - " gl_FragColor = vec4(sum.rgb * 0.125, 1.0);\n" + - "}"; - private final String gradientMask = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform sampler2D tex;\n" + - "uniform vec3 color1, color2, color3, color4;\n" + - "uniform float alpha;\n" + - "\n" + - "#define NOISE .5/255.0\n" + - "\n" + - "vec3 createGradient(vec2 coords, vec3 color1, vec3 color2, vec3 color3, vec3 color4){\n" + - " vec3 color = mix(mix(color1.rgb, color2.rgb, coords.y), mix(color3.rgb, color4.rgb, coords.y), coords.x);\n" + - " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898,78.233))) * 43758.5453));\n" + - " return color;\n" + - "}\n" + - "\n" + - "void main() {\n" + - " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + - " float texColorAlpha = texture2D(tex, gl_TexCoord[0].st).a;\n" + - " gl_FragColor = vec4(createGradient(coords, color1, color2, color3, color4), texColorAlpha * alpha);\n" + - "}"; - private final String mask = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform sampler2D u_texture, u_texture2;\n" + - "void main() {\n" + - " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + - " float texColorAlpha = texture2D(u_texture, gl_TexCoord[0].st).a;\n" + - " vec3 tex2Color = texture2D(u_texture2, gl_TexCoord[0].st).rgb;\n" + - " gl_FragColor = vec4(tex2Color, texColorAlpha);\n" + - "}"; - private final String gradient = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform sampler2D tex;\n" + - "uniform vec4 color1, color2, color3, color4;\n" + - "#define NOISE .5/255.0\n" + - "\n" + - "vec4 createGradient(vec2 coords, vec4 color1, vec4 color2, vec4 color3, vec4 color4){\n" + - " vec4 color = mix(mix(color1, color2, coords.y), mix(color3, color4, coords.y), coords.x);\n" + - " //Dithering the color\n" + - " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898, 78.233))) * 43758.5453));\n" + - " return color;\n" + - "}\n" + - "\n" + - "void main() {\n" + - " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + - " gl_FragColor = createGradient(coords, color1, color2, color3, color4);\n" + - "}"; - private final String roundedRectGradient = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform vec4 color1, color2, color3, color4;\n" + - "uniform float radius;\n" + - "\n" + - "#define NOISE .5/255.0\n" + - "\n" + - "float roundSDF(vec2 p, vec2 b, float r) {\n" + - " return length(max(abs(p) - b , 0.0)) - r;\n" + - "}\n" + - "\n" + - "vec4 createGradient(vec2 coords, vec4 color1, vec4 color2, vec4 color3, vec4 color4){\n" + - " vec4 color = mix(mix(color1, color2, coords.y), mix(color3, color4, coords.y), coords.x);\n" + - " //Dithering the color\n" + - " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898, 78.233))) * 43758.5453));\n" + - " return color;\n" + - "}\n" + - "\n" + - "void main() {\n" + - " vec2 st = gl_TexCoord[0].st;\n" + - " vec2 halfSize = rectSize * .5;\n" + - " \n" + - " // use the bottom leftColor as the alpha\n" + - " float smoothedAlpha = (1.0-smoothstep(0.0, 2., roundSDF(halfSize - (gl_TexCoord[0].st * rectSize), halfSize - radius - 1., radius)));\n" + - " vec4 gradient = createGradient(st, color1, color2, color3, color4); gl_FragColor = vec4(gradient.rgb, gradient.a * smoothedAlpha);\n" + - "}"; - private final String roundedRect = "#version 120\n" + - "\n" + - "uniform vec2 location, rectSize;\n" + - "uniform vec4 color;\n" + - "uniform float radius;\n" + - "uniform bool blur;\n" + - "\n" + - "float roundSDF(vec2 p, vec2 b, float r) {\n" + - " return length(max(abs(p) - b, 0.0)) - r;\n" + - "}\n" + - "\n" + - "\n" + - "void main() {\n" + - " vec2 rectHalf = rectSize * .5;\n" + - " // Smooth the result (free antialiasing).\n" + - " float smoothedAlpha = (1.0-smoothstep(0.0, 1.0, roundSDF(rectHalf - (gl_TexCoord[0].st * rectSize), rectHalf - radius - 1., radius))) * color.a;\n" + - " gl_FragColor = vec4(color.rgb, smoothedAlpha);// mix(quadColor, shadowColor, 0.0);\n" + - "\n" + - "}"; - private final String roundedRectRise = "#version 120\n" + - "\n" + - "uniform vec2 u_size;\n" + - "uniform float u_radius;\n" + - "uniform vec4 u_color;\n" + - "uniform vec4 u_edges;\n" + - "\n" + - "void main(void)\n" + - "{\n" + - " vec2 tex_coord = gl_TexCoord[0].st;\n" + - "\n" + - " // fast implementation of custom corners\n" + - " // can probably be better, but this is good enough for now\n" + - " if (tex_coord.x < 0.5 && tex_coord.y > 0.5 && u_edges.x == 0.0 ||\n" + - " tex_coord.x > 0.5 && tex_coord.y > 0.5 && u_edges.y == 0.0 ||\n" + - " tex_coord.x > 0.5 && tex_coord.y < 0.5 && u_edges.z == 0.0 ||\n" + - " tex_coord.x < 0.5 && tex_coord.y < 0.5 && u_edges.w == 0.0) {\n" + - " gl_FragColor = u_color;\n" + - " } else {\n" + - " gl_FragColor = vec4(u_color.rgb, u_color.a * smoothstep(1.0, 0.0, length(max((abs(tex_coord - 0.5) + 0.5) * u_size - u_size + u_radius, 0.0)) - u_radius + 0.5));\n" + - " }\n" + - "}"; - - public ShaderUtils(String fragmentShaderLoc, String vertexShaderLoc) { - int program = glCreateProgram(); - try { - int fragmentShaderID; - switch (fragmentShaderLoc) { - case "kawaseUpGlow": - fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUpGlow.getBytes()), GL_FRAGMENT_SHADER); - break; - case "glow": - fragmentShaderID = createShader(new ByteArrayInputStream(glowShader.getBytes()), GL_FRAGMENT_SHADER); - break; - case "roundRectTexture": - fragmentShaderID = createShader(new ByteArrayInputStream(roundRectTexture.getBytes()), GL_FRAGMENT_SHADER); - break; - case "roundRectOutline": - fragmentShaderID = createShader(new ByteArrayInputStream(roundRectOutline.getBytes()), GL_FRAGMENT_SHADER); - break; - case "kawaseUpBloom": - fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUpBloom.getBytes()), GL_FRAGMENT_SHADER); - break; - case "kawaseDownBloom": - fragmentShaderID = createShader(new ByteArrayInputStream(kawaseDownBloom.getBytes()), GL_FRAGMENT_SHADER); - break; - case "kawaseUp": - fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUp.getBytes()), GL_FRAGMENT_SHADER); - break; - case "kawaseDown": - fragmentShaderID = createShader(new ByteArrayInputStream(kawaseDown.getBytes()), GL_FRAGMENT_SHADER); - break; - case "gradientMask": - fragmentShaderID = createShader(new ByteArrayInputStream(gradientMask.getBytes()), GL_FRAGMENT_SHADER); - break; - case "mask": - fragmentShaderID = createShader(new ByteArrayInputStream(mask.getBytes()), GL_FRAGMENT_SHADER); - break; - case "gradient": - fragmentShaderID = createShader(new ByteArrayInputStream(gradient.getBytes()), GL_FRAGMENT_SHADER); - break; - case "roundedRect": - fragmentShaderID = createShader(new ByteArrayInputStream(roundedRect.getBytes()), GL_FRAGMENT_SHADER); - break; - case "roundedRectGradient": - fragmentShaderID = createShader(new ByteArrayInputStream(roundedRectGradient.getBytes()), GL_FRAGMENT_SHADER); - break; - case "roundedRectRise": - fragmentShaderID = createShader(new ByteArrayInputStream(roundedRectRise.getBytes()), GL_FRAGMENT_SHADER); - break; - default: - fragmentShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(fragmentShaderLoc)).getInputStream(), GL_FRAGMENT_SHADER); - break; - } - glAttachShader(program, fragmentShaderID); - - int vertexShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(vertexShaderLoc)).getInputStream(), GL_VERTEX_SHADER); - glAttachShader(program, vertexShaderID); - } - catch (IOException e) { - e.printStackTrace(); - } - - glLinkProgram(program); - int status = glGetProgrami(program, GL_LINK_STATUS); - - if (status == 0) { - throw new IllegalStateException("Shader failed to link!"); - } - this.programID = program; - } - - public ShaderUtils(String fragmentShaderLoc) { - this(fragmentShaderLoc, "minecraft:shaders/vertex.vsh"); - } - - public static void drawQuads() { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - float width = (float) sr.getScaledWidth_double(); - float height = (float) sr.getScaledHeight_double(); - glBegin(GL_QUADS); - glTexCoord2f(0, 1); - glVertex2f(0, 0); - glTexCoord2f(0, 0); - glVertex2f(0, height); - glTexCoord2f(1, 0); - glVertex2f(width, height); - glTexCoord2f(1, 1); - glVertex2f(width, 0); - glEnd(); - } - - public static void drawQuads(float x, float y, float width, float height) { - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2f(x, y); - glTexCoord2f(0, 1); - glVertex2f(x, y + height); - glTexCoord2f(1, 1); - glVertex2f(x + width, y + height); - glTexCoord2f(1, 0); - glVertex2f(x + width, y); - glEnd(); - } - - public void init() { - glUseProgram(programID); - } - - public void unload() { - glUseProgram(0); - } - - public void setUniformf(String name, float... args) { - int loc = glGetUniformLocation(programID, name); - if (loc == -1) { - return; - } - switch (args.length) { - case 1: - glUniform1f(loc, args[0]); - break; - case 2: - glUniform2f(loc, args[0], args[1]); - break; - case 3: - glUniform3f(loc, args[0], args[1], args[2]); - break; - case 4: - glUniform4f(loc, args[0], args[1], args[2], args[3]); - break; - } - } - - public void setUniformi(String name, int... args) { - int loc = glGetUniformLocation(programID, name); - if (loc == -1) { - return; - } - if (args.length > 1) glUniform2i(loc, args[0], args[1]); - else glUniform1i(loc, args[0]); - } - - private int createShader(InputStream inputStream, int shaderType) { - int shader = glCreateShader(shaderType); - GL20.glShaderSource(shader, Utils.readInputStream(inputStream)); - glCompileShader(shader); - - if (glGetShaderi(shader, GL_COMPILE_STATUS) == 0) { - System.out.println(glGetShaderInfoLog(shader, 4096)); - throw new IllegalStateException(String.format("Shader (%s) failed to compile!", shaderType)); - } - - return shader; - } +package keystrokesmod.utility.shader; + +import keystrokesmod.utility.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL20; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL20.*; + +public class ShaderUtils { + + private Minecraft mc = Minecraft.getMinecraft(); + public final int programID; + private final String kawaseUpGlow = "#version 120\n" + + "\n" + + "uniform sampler2D inTexture, textureToCheck;\n" + + "uniform vec2 halfpixel, offset, iResolution;\n" + + "uniform bool check;\n" + + "uniform float lastPass;\n" + + "uniform float exposure;\n" + + "\n" + + "void main() {\n" + + " if(check && texture2D(textureToCheck, gl_TexCoord[0].st).a != 0.0) discard;\n" + + " vec2 uv = vec2(gl_FragCoord.xy / iResolution);\n" + + "\n" + + " vec4 sum = texture2D(inTexture, uv + vec2(-halfpixel.x * 2.0, 0.0) * offset);\n" + + " sum.rgb *= sum.a;\n" + + " vec4 smpl1 = texture2D(inTexture, uv + vec2(-halfpixel.x, halfpixel.y) * offset);\n" + + " smpl1.rgb *= smpl1.a;\n" + + " sum += smpl1 * 2.0;\n" + + " vec4 smp2 = texture2D(inTexture, uv + vec2(0.0, halfpixel.y * 2.0) * offset);\n" + + " smp2.rgb *= smp2.a;\n" + + " sum += smp2;\n" + + " vec4 smp3 = texture2D(inTexture, uv + vec2(halfpixel.x, halfpixel.y) * offset);\n" + + " smp3.rgb *= smp3.a;\n" + + " sum += smp3 * 2.0;\n" + + " vec4 smp4 = texture2D(inTexture, uv + vec2(halfpixel.x * 2.0, 0.0) * offset);\n" + + " smp4.rgb *= smp4.a;\n" + + " sum += smp4;\n" + + " vec4 smp5 = texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + + " smp5.rgb *= smp5.a;\n" + + " sum += smp5 * 2.0;\n" + + " vec4 smp6 = texture2D(inTexture, uv + vec2(0.0, -halfpixel.y * 2.0) * offset);\n" + + " smp6.rgb *= smp6.a;\n" + + " sum += smp6;\n" + + " vec4 smp7 = texture2D(inTexture, uv + vec2(-halfpixel.x, -halfpixel.y) * offset);\n" + + " smp7.rgb *= smp7.a;\n" + + " sum += smp7 * 2.0;\n" + + " vec4 result = sum / 12.0;\n" + + " gl_FragColor = vec4(result.rgb / result.a, mix(result.a, 1.0 - exp(-result.a * exposure), step(0.0, lastPass)));\n" + + "}"; + private final String glowShader = "#version 120\n" + + "\n" + + "uniform sampler2D textureIn, textureToCheck;\n" + + "uniform vec2 texelSize, direction;\n" + + "uniform vec3 color;\n" + + "uniform bool avoidTexture;\n" + + "uniform float exposure, radius;\n" + + "uniform float weights[256];\n" + + "\n" + + "#define offset direction * texelSize\n" + + "\n" + + "void main() {\n" + + " if (direction.y == 1 && avoidTexture) {\n" + + " if (texture2D(textureToCheck, gl_TexCoord[0].st).a != 0.0) discard;\n" + + " }\n" + + " vec4 innerColor = texture2D(textureIn, gl_TexCoord[0].st);\n" + + " innerColor.rgb *= innerColor.a;\n" + + " innerColor *= weights[0];\n" + + " for (float r = 1.0; r <= radius; r++) {\n" + + " vec4 colorCurrent1 = texture2D(textureIn, gl_TexCoord[0].st + offset * r);\n" + + " vec4 colorCurrent2 = texture2D(textureIn, gl_TexCoord[0].st - offset * r);\n" + + "\n" + + " colorCurrent1.rgb *= colorCurrent1.a;\n" + + " colorCurrent2.rgb *= colorCurrent2.a;\n" + + "\n" + + " innerColor += (colorCurrent1 + colorCurrent2) * weights[int(r)];\n" + + " }\n" + + "\n" + + " gl_FragColor = vec4(innerColor.rgb / innerColor.a, mix(innerColor.a, 1.0 - exp(-innerColor.a * exposure), step(0.0, direction.y)));\n" + + "}\n"; + private final String roundRectTexture = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform sampler2D textureIn;\n" + + "uniform float radius, alpha;\n" + + "\n" + + "float roundedBoxSDF(vec2 centerPos, vec2 size, float radius) {\n" + + " return length(max(abs(centerPos) -size, 0.)) - radius;\n" + + "}\n" + + "\n" + + "\n" + + "void main() {\n" + + " float distance = roundedBoxSDF((rectSize * .5) - (gl_TexCoord[0].st * rectSize), (rectSize * .5) - radius - 1., radius);\n" + + " float smoothedAlpha = (1.0-smoothstep(0.0, 2.0, distance)) * alpha;\n" + + " gl_FragColor = vec4(texture2D(textureIn, gl_TexCoord[0].st).rgb, smoothedAlpha);\n" + + "}"; + private final String roundRectOutline = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform vec4 color, outlineColor;\n" + + "uniform float radius, outlineThickness;\n" + + "\n" + + "float roundedSDF(vec2 centerPos, vec2 size, float radius) {\n" + + " return length(max(abs(centerPos) - size + radius, 0.0)) - radius;\n" + + "}\n" + + "\n" + + "void main() {\n" + + " float distance = roundedSDF(gl_FragCoord.xy - location - (rectSize * .5), (rectSize * .5) + (outlineThickness *.5) - 1.0, radius);\n" + + "\n" + + " float blendAmount = smoothstep(0., 2., abs(distance) - (outlineThickness * .5));\n" + + "\n" + + " vec4 insideColor = (distance < 0.) ? color : vec4(outlineColor.rgb, 0.0);\n" + + " gl_FragColor = mix(outlineColor, insideColor, blendAmount);\n" + + "\n" + + "}"; + private final String kawaseUpBloom = "#version 120\n" + + "\n" + + "uniform sampler2D inTexture, textureToCheck;\n" + + "uniform vec2 halfpixel, offset, iResolution;\n" + + "uniform int check;\n" + + "\n" + + "void main() {\n" + + " vec2 uv = gl_FragCoord.xy / iResolution;\n" + + "\n" + + " vec2 offset1 = vec2(-halfpixel.x, 0.0) * offset;\n" + + " vec2 offset2 = vec2(-halfpixel.x, halfpixel.y) * offset;\n" + + " vec2 offset3 = vec2(0.0, halfpixel.y * 2.0) * offset;\n" + + " vec2 offset4 = vec2(halfpixel.x, halfpixel.y) * offset;\n" + + " vec2 offset5 = vec2(halfpixel.x * 2.0, 0.0) * offset;\n" + + " vec2 offset6 = vec2(halfpixel.x, -halfpixel.y) * offset;\n" + + " vec2 offset7 = vec2(0.0, -halfpixel.y * 2.0) * offset;\n" + + " vec2 offset8 = vec2(-halfpixel.x, -halfpixel.y) * offset;\n" + + "\n" + + " vec4 sum = texture2D(inTexture, uv + offset1);\n" + + " sum.rgb *= sum.a;\n" + + " vec4 smpl1 = texture2D(inTexture, uv + offset2);\n" + + " smpl1.rgb *= smpl1.a;\n" + + " sum += smpl1 * 2.0;\n" + + " vec4 smp2 = texture2D(inTexture, uv + offset3);\n" + + " smp2.rgb *= smp2.a;\n" + + " sum += smp2;\n" + + " vec4 smp3 = texture2D(inTexture, uv + offset4);\n" + + " smp3.rgb *= smp3.a;\n" + + " sum += smp3 * 2.0;\n" + + " vec4 smp4 = texture2D(inTexture, uv + offset5);\n" + + " smp4.rgb *= smp4.a;\n" + + " sum += smp4;\n" + + " vec4 smp5 = texture2D(inTexture, uv + offset6);\n" + + " smp5.rgb *= smp5.a;\n" + + " sum += smp5 * 2.0;\n" + + " vec4 smp6 = texture2D(inTexture, uv + offset7);\n" + + " smp6.rgb *= smp6.a;\n" + + " sum += smp6;\n" + + " vec4 smp7 = texture2D(inTexture, uv + offset8);\n" + + " smp7.rgb *= smp7.a;\n" + + " sum += smp7 * 2.0;\n" + + "\n" + + " vec4 result = sum / 12.0;\n" + + " float checkAlpha = texture2D(textureToCheck, gl_TexCoord[0].st).a;\n" + + " gl_FragColor = vec4(result.rgb / result.a, mix(result.a, result.a * (1.0 - checkAlpha), float(check)));\n" + + "}\n"; + private final String kawaseDownBloom = "#version 120\n" + + "\n" + + "uniform sampler2D inTexture;\n" + + "uniform vec2 offset, halfpixel, iResolution;\n" + + "\n" + + "void main() {\n" + + " vec2 uv = gl_FragCoord.xy / iResolution;\n" + + "\n" + + " vec4 sum = texture2D(inTexture, uv);\n" + + " sum.rgb *= sum.a;\n" + + " sum *= 4.0;\n" + + " vec4 smp1 = texture2D(inTexture, uv - halfpixel.xy * offset);\n" + + " smp1.rgb *= smp1.a;\n" + + " sum += smp1;\n" + + " vec4 smp2 = texture2D(inTexture, uv + halfpixel.xy * offset);\n" + + " smp2.rgb *= smp2.a;\n" + + " sum += smp2;\n" + + " vec4 smp3 = texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + + " smp3.rgb *= smp3.a;\n" + + " sum += smp3;\n" + + " vec4 smp4 = texture2D(inTexture, uv - vec2(halfpixel.x, -halfpixel.y) * offset);\n" + + " smp4.rgb *= smp4.a;\n" + + " sum += smp4;\n" + + " vec4 result = sum / 8.0;\n" + + " gl_FragColor = vec4(result.rgb / result.a, result.a);\n" + + "}\n"; + private final String kawaseUp = "#version 120\n" + + "\n" + + "uniform sampler2D inTexture, textureToCheck;\n" + + "uniform vec2 halfpixel, offset, iResolution;\n" + + "uniform int check;\n" + + "\n" + + "void main() {\n" + + " vec2 uv = gl_FragCoord.xy / iResolution;\n" + + "\n" + + " vec4 sum = texture2D(inTexture, uv + vec2(-halfpixel.x * 2.0, 0.0) * offset);\n" + + " sum += texture2D(inTexture, uv + vec2(-halfpixel.x, halfpixel.y) * offset) * 2.0;\n" + + " sum += texture2D(inTexture, uv + vec2(0.0, halfpixel.y * 2.0) * offset);\n" + + " sum += texture2D(inTexture, uv + vec2(halfpixel.x, halfpixel.y) * offset) * 2.0;\n" + + " sum += texture2D(inTexture, uv + vec2(halfpixel.x * 2.0, 0.0) * offset);\n" + + " sum += texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset) * 2.0;\n" + + " sum += texture2D(inTexture, uv + vec2(0.0, -halfpixel.y * 2.0) * offset);\n" + + " sum += texture2D(inTexture, uv + vec2(-halfpixel.x, -halfpixel.y) * offset) * 2.0;\n" + + "\n" + + " vec4 average = sum / 12.0;\n" + + " gl_FragColor = vec4(average.rgb, mix(1.0, texture2D(textureToCheck, gl_TexCoord[0].st).a, check));\n" + + "}"; + private final String kawaseDown = "#version 120\n" + + "\n" + + "uniform sampler2D inTexture;\n" + + "uniform vec2 offset, halfpixel, iResolution;\n" + + "\n" + + "void main() {\n" + + " vec2 uv = gl_FragCoord.xy / iResolution;\n" + + "\n" + + " vec4 sum = texture2D(inTexture, uv) * 4.0;\n" + + " sum += texture2D(inTexture, uv - halfpixel.xy * offset);\n" + + " sum += texture2D(inTexture, uv + halfpixel.xy * offset);\n" + + " sum += texture2D(inTexture, uv + vec2(halfpixel.x, -halfpixel.y) * offset);\n" + + " sum += texture2D(inTexture, uv - vec2(halfpixel.x, -halfpixel.y) * offset);\n" + + "\n" + + " gl_FragColor = vec4(sum.rgb * 0.125, 1.0);\n" + + "}"; + private final String gradientMask = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform sampler2D tex;\n" + + "uniform vec3 color1, color2, color3, color4;\n" + + "uniform float alpha;\n" + + "\n" + + "#define NOISE .5/255.0\n" + + "\n" + + "vec3 createGradient(vec2 coords, vec3 color1, vec3 color2, vec3 color3, vec3 color4){\n" + + " vec3 color = mix(mix(color1.rgb, color2.rgb, coords.y), mix(color3.rgb, color4.rgb, coords.y), coords.x);\n" + + " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898,78.233))) * 43758.5453));\n" + + " return color;\n" + + "}\n" + + "\n" + + "void main() {\n" + + " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + + " float texColorAlpha = texture2D(tex, gl_TexCoord[0].st).a;\n" + + " gl_FragColor = vec4(createGradient(coords, color1, color2, color3, color4), texColorAlpha * alpha);\n" + + "}"; + private final String mask = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform sampler2D u_texture, u_texture2;\n" + + "void main() {\n" + + " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + + " float texColorAlpha = texture2D(u_texture, gl_TexCoord[0].st).a;\n" + + " vec3 tex2Color = texture2D(u_texture2, gl_TexCoord[0].st).rgb;\n" + + " gl_FragColor = vec4(tex2Color, texColorAlpha);\n" + + "}"; + private final String gradient = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform sampler2D tex;\n" + + "uniform vec4 color1, color2, color3, color4;\n" + + "#define NOISE .5/255.0\n" + + "\n" + + "vec4 createGradient(vec2 coords, vec4 color1, vec4 color2, vec4 color3, vec4 color4){\n" + + " vec4 color = mix(mix(color1, color2, coords.y), mix(color3, color4, coords.y), coords.x);\n" + + " //Dithering the color\n" + + " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898, 78.233))) * 43758.5453));\n" + + " return color;\n" + + "}\n" + + "\n" + + "void main() {\n" + + " vec2 coords = (gl_FragCoord.xy - location) / rectSize;\n" + + " gl_FragColor = createGradient(coords, color1, color2, color3, color4);\n" + + "}"; + private final String roundedRectGradient = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform vec4 color1, color2, color3, color4;\n" + + "uniform float radius;\n" + + "\n" + + "#define NOISE .5/255.0\n" + + "\n" + + "float roundSDF(vec2 p, vec2 b, float r) {\n" + + " return length(max(abs(p) - b , 0.0)) - r;\n" + + "}\n" + + "\n" + + "vec4 createGradient(vec2 coords, vec4 color1, vec4 color2, vec4 color3, vec4 color4){\n" + + " vec4 color = mix(mix(color1, color2, coords.y), mix(color3, color4, coords.y), coords.x);\n" + + " //Dithering the color\n" + + " color += mix(NOISE, -NOISE, fract(sin(dot(coords.xy, vec2(12.9898, 78.233))) * 43758.5453));\n" + + " return color;\n" + + "}\n" + + "\n" + + "void main() {\n" + + " vec2 st = gl_TexCoord[0].st;\n" + + " vec2 halfSize = rectSize * .5;\n" + + " \n" + + " // use the bottom leftColor as the alpha\n" + + " float smoothedAlpha = (1.0-smoothstep(0.0, 2., roundSDF(halfSize - (gl_TexCoord[0].st * rectSize), halfSize - radius - 1., radius)));\n" + + " vec4 gradient = createGradient(st, color1, color2, color3, color4); gl_FragColor = vec4(gradient.rgb, gradient.a * smoothedAlpha);\n" + + "}"; + private final String roundedRect = "#version 120\n" + + "\n" + + "uniform vec2 location, rectSize;\n" + + "uniform vec4 color;\n" + + "uniform float radius;\n" + + "uniform bool blur;\n" + + "\n" + + "float roundSDF(vec2 p, vec2 b, float r) {\n" + + " return length(max(abs(p) - b, 0.0)) - r;\n" + + "}\n" + + "\n" + + "\n" + + "void main() {\n" + + " vec2 rectHalf = rectSize * .5;\n" + + " // Smooth the result (free antialiasing).\n" + + " float smoothedAlpha = (1.0-smoothstep(0.0, 1.0, roundSDF(rectHalf - (gl_TexCoord[0].st * rectSize), rectHalf - radius - 1., radius))) * color.a;\n" + + " gl_FragColor = vec4(color.rgb, smoothedAlpha);// mix(quadColor, shadowColor, 0.0);\n" + + "\n" + + "}"; + private final String roundedRectRise = "#version 120\n" + + "\n" + + "uniform vec2 u_size;\n" + + "uniform float u_radius;\n" + + "uniform vec4 u_color;\n" + + "uniform vec4 u_edges;\n" + + "\n" + + "void main(void)\n" + + "{\n" + + " vec2 tex_coord = gl_TexCoord[0].st;\n" + + "\n" + + " // fast implementation of custom corners\n" + + " // can probably be better, but this is good enough for now\n" + + " if (tex_coord.x < 0.5 && tex_coord.y > 0.5 && u_edges.x == 0.0 ||\n" + + " tex_coord.x > 0.5 && tex_coord.y > 0.5 && u_edges.y == 0.0 ||\n" + + " tex_coord.x > 0.5 && tex_coord.y < 0.5 && u_edges.z == 0.0 ||\n" + + " tex_coord.x < 0.5 && tex_coord.y < 0.5 && u_edges.w == 0.0) {\n" + + " gl_FragColor = u_color;\n" + + " } else {\n" + + " gl_FragColor = vec4(u_color.rgb, u_color.a * smoothstep(1.0, 0.0, length(max((abs(tex_coord - 0.5) + 0.5) * u_size - u_size + u_radius, 0.0)) - u_radius + 0.5));\n" + + " }\n" + + "}"; + + public ShaderUtils(String fragmentShaderLoc, String vertexShaderLoc) { + int program = glCreateProgram(); + try { + int fragmentShaderID; + switch (fragmentShaderLoc) { + case "kawaseUpGlow": + fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUpGlow.getBytes()), GL_FRAGMENT_SHADER); + break; + case "glow": + fragmentShaderID = createShader(new ByteArrayInputStream(glowShader.getBytes()), GL_FRAGMENT_SHADER); + break; + case "roundRectTexture": + fragmentShaderID = createShader(new ByteArrayInputStream(roundRectTexture.getBytes()), GL_FRAGMENT_SHADER); + break; + case "roundRectOutline": + fragmentShaderID = createShader(new ByteArrayInputStream(roundRectOutline.getBytes()), GL_FRAGMENT_SHADER); + break; + case "kawaseUpBloom": + fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUpBloom.getBytes()), GL_FRAGMENT_SHADER); + break; + case "kawaseDownBloom": + fragmentShaderID = createShader(new ByteArrayInputStream(kawaseDownBloom.getBytes()), GL_FRAGMENT_SHADER); + break; + case "kawaseUp": + fragmentShaderID = createShader(new ByteArrayInputStream(kawaseUp.getBytes()), GL_FRAGMENT_SHADER); + break; + case "kawaseDown": + fragmentShaderID = createShader(new ByteArrayInputStream(kawaseDown.getBytes()), GL_FRAGMENT_SHADER); + break; + case "gradientMask": + fragmentShaderID = createShader(new ByteArrayInputStream(gradientMask.getBytes()), GL_FRAGMENT_SHADER); + break; + case "mask": + fragmentShaderID = createShader(new ByteArrayInputStream(mask.getBytes()), GL_FRAGMENT_SHADER); + break; + case "gradient": + fragmentShaderID = createShader(new ByteArrayInputStream(gradient.getBytes()), GL_FRAGMENT_SHADER); + break; + case "roundedRect": + fragmentShaderID = createShader(new ByteArrayInputStream(roundedRect.getBytes()), GL_FRAGMENT_SHADER); + break; + case "roundedRectGradient": + fragmentShaderID = createShader(new ByteArrayInputStream(roundedRectGradient.getBytes()), GL_FRAGMENT_SHADER); + break; + case "roundedRectRise": + fragmentShaderID = createShader(new ByteArrayInputStream(roundedRectRise.getBytes()), GL_FRAGMENT_SHADER); + break; + default: + fragmentShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(fragmentShaderLoc)).getInputStream(), GL_FRAGMENT_SHADER); + break; + } + glAttachShader(program, fragmentShaderID); + + int vertexShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(vertexShaderLoc)).getInputStream(), GL_VERTEX_SHADER); + glAttachShader(program, vertexShaderID); + } + catch (IOException e) { + e.printStackTrace(); + } + + glLinkProgram(program); + int status = glGetProgrami(program, GL_LINK_STATUS); + + if (status == 0) { + throw new IllegalStateException("Shader failed to link!"); + } + this.programID = program; + } + + public ShaderUtils(String fragmentShaderLoc) { + this(fragmentShaderLoc, "minecraft:shaders/vertex.vsh"); + } + + public static void drawQuads() { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + float width = (float) sr.getScaledWidth_double(); + float height = (float) sr.getScaledHeight_double(); + glBegin(GL_QUADS); + glTexCoord2f(0, 1); + glVertex2f(0, 0); + glTexCoord2f(0, 0); + glVertex2f(0, height); + glTexCoord2f(1, 0); + glVertex2f(width, height); + glTexCoord2f(1, 1); + glVertex2f(width, 0); + glEnd(); + } + + public static void drawQuads(float x, float y, float width, float height) { + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(x, y); + glTexCoord2f(0, 1); + glVertex2f(x, y + height); + glTexCoord2f(1, 1); + glVertex2f(x + width, y + height); + glTexCoord2f(1, 0); + glVertex2f(x + width, y); + glEnd(); + } + + public void init() { + glUseProgram(programID); + } + + public void unload() { + glUseProgram(0); + } + + public void setUniformf(String name, float... args) { + int loc = glGetUniformLocation(programID, name); + if (loc == -1) { + return; + } + switch (args.length) { + case 1: + glUniform1f(loc, args[0]); + break; + case 2: + glUniform2f(loc, args[0], args[1]); + break; + case 3: + glUniform3f(loc, args[0], args[1], args[2]); + break; + case 4: + glUniform4f(loc, args[0], args[1], args[2], args[3]); + break; + } + } + + public void setUniformi(String name, int... args) { + int loc = glGetUniformLocation(programID, name); + if (loc == -1) { + return; + } + if (args.length > 1) glUniform2i(loc, args[0], args[1]); + else glUniform1i(loc, args[0]); + } + + private int createShader(InputStream inputStream, int shaderType) { + int shader = glCreateShader(shaderType); + GL20.glShaderSource(shader, Utils.readInputStream(inputStream)); + glCompileShader(shader); + + if (glGetShaderi(shader, GL_COMPILE_STATUS) == 0) { + System.out.println(glGetShaderInfoLog(shader, 4096)); + throw new IllegalStateException(String.format("Shader (%s) failed to compile!", shaderType)); + } + + return shader; + } } \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/shaders/vertex.vsh b/src/main/resources/assets/minecraft/shaders/vertex.vsh index 1eb5182..ec33951 100644 --- a/src/main/resources/assets/minecraft/shaders/vertex.vsh +++ b/src/main/resources/assets/minecraft/shaders/vertex.vsh @@ -1,6 +1,6 @@ -#version 120 - -void main() { - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +#version 120 + +void main() { + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } \ No newline at end of file diff --git a/src/main/resources/mixins.raven.json b/src/main/resources/mixins.raven.json index 1b6b046..0b96e96 100644 --- a/src/main/resources/mixins.raven.json +++ b/src/main/resources/mixins.raven.json @@ -1,49 +1,50 @@ -{ - "required": true, - "package": "keystrokesmod.mixin.impl", - "refmap": "mixins.raven.refmap.json", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "entity.MixinEntity", - "render.MixinFontRenderer", - "entity.MixinEntityPlayerSP", - "render.MixinLayerCape", - "entity.MixinEntityLivingBase", - "network.MixinNetworkManager", - "entity.MixinEntityPlayer", - "render.MixinRendererLivingEntity", - "render.MixinEntityRenderer", - "network.MixinModList", - "client.MixinMovementInputFromOptions", - "client.MixinMinecraft", - "render.MixinItemRenderer", - "render.MixinRenderGlobal", - "world.MixinWorldInfo", - "world.MixinWorld", - "render.MixinGuiChat", - "render.MixinGuiScreen", - "network.MixinNetHandlerPlayClient", - "render.MixinRenderManager", - "render.MixinCustomSky", - "client.MixinPlayerControllerMP", - "world.MixinBlock", - "render.MixinRenderPlayer", - "client.MixinGameSettings", - - "accessor.IAccessorEntityPlayerSP", - "accessor.IAccessorEntityArrow", - "accessor.IAccessorEntityLivingBase", - "accessor.IAccessorMinecraft", - "accessor.IAccessorPlayerControllerMP", - "accessor.IAccessorGuiPlayerTabOverlay", - "accessor.IAccessorGuiIngame", - "accessor.IAccessorEntityRenderer", - "accessor.IAccessorItemFood", - "accessor.IAccessorGuiScreenBook", - "accessor.IAccessorEntityPlayer", - "accessor.IAccessorGuiScreen", - "accessor.IAccessorS14PacketEntity", - "accessor.IAccessorRenderManager", - "accessor.IAccessorNetworkManager" - ] +{ + "required": true, + "package": "keystrokesmod.mixin.impl", + "refmap": "mixins.raven.refmap.json", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "entity.MixinEntity", + "render.MixinFontRenderer", + "entity.MixinEntityPlayerSP", + "render.MixinLayerCape", + "entity.MixinEntityLivingBase", + "network.MixinNetworkManager", + "entity.MixinEntityPlayer", + "render.MixinRendererLivingEntity", + "render.MixinEntityRenderer", + "network.MixinModList", + "client.MixinMovementInputFromOptions", + "client.MixinMinecraft", + "render.MixinItemRenderer", + "render.MixinRenderGlobal", + "world.MixinWorldInfo", + "world.MixinWorld", + "render.MixinGuiChat", + "render.MixinGuiScreen", + "network.MixinNetHandlerPlayClient", + "render.MixinRenderManager", + "render.MixinCustomSky", + "client.MixinPlayerControllerMP", + "world.MixinBlock", + "render.MixinRenderPlayer", + "client.MixinGameSettings", + + "accessor.IAccessorEntityPlayerSP", + "accessor.IAccessorEntityArrow", + "accessor.IAccessorEntityLivingBase", + "accessor.IAccessorMinecraft", + "accessor.IAccessorPlayerControllerMP", + "accessor.IAccessorGuiPlayerTabOverlay", + "accessor.IAccessorGuiIngame", + "accessor.IAccessorEntityRenderer", + "accessor.IAccessorItemFood", + "accessor.IAccessorGuiScreenBook", + "accessor.IAccessorEntityPlayer", + "accessor.IAccessorGuiScreen", + "accessor.IAccessorS14PacketEntity", + "accessor.IAccessorRenderManager", + "accessor.IAccessorNetworkManager", + "accessor.IAccessorEntity" + ] } \ No newline at end of file