From d66be53fb891e8321dd1a690f1e0bf8a4e083d0a Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Sun, 5 Mar 2023 03:04:46 -0600 Subject: [PATCH] Key input --- build.gradle | 168 +++++++++++------- settings.gradle | 27 ++- .../montoyo/wd/client/gui/GuiKeyboard.java | 17 +- 3 files changed, 115 insertions(+), 97 deletions(-) diff --git a/build.gradle b/build.gradle index 7145fe2..d937bd2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,66 @@ plugins { - id 'dev.architectury.loom' version '0.12.0-SNAPSHOT' - id 'io.github.juuxel.loom-quiltflower' version '1.6.0' + id 'eclipse' id 'maven-publish' + id 'net.minecraftforge.gradle' version '5.1.+' + id 'org.spongepowered.mixin' version '0.7.+' } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +version = mod_version +group = maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = archives_base_name +java.toolchain.languageVersion = JavaLanguageVersion.of(17) -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group +println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) +minecraft { + mappings channel: 'official', version: '1.19' + //accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + runs { + client { + properties 'mixin.env.remapRefMap': 'true' + property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" + workingDirectory project.file('run') + arg "-mixin.config=forgecef.mixins.json" + property 'forge.logging.console.level', 'debug' -repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. + mods { + citadel { + source sourceSets.main + } + } + } + + server { + properties 'mixin.env.remapRefMap': 'true' + property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" + workingDirectory project.file('run') + arg "-mixin.config=forgecef.mixins.json" + + + property 'forge.logging.console.level', 'debug' + + mods { + citadel { + source sourceSets.main + } + } + } + + data { + workingDirectory project.file('run') + properties 'mixin.env.remapRefMap': 'true' + property 'mixin.env.refMapRemappingFile', "${project.projectDir}/build/createSrgToMcp/output.srg" + property 'forge.logging.console.level', 'debug' + args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', sourceSets.main.resources.srcDirs[0] + mods { + citadel { + source sourceSets.main + } + } + } + } +} + +repositories{ maven { url "https://maven.shedaniel.me/" } maven { url 'https://jitpack.io' } maven { @@ -25,75 +69,65 @@ repositories { } } -loom { - accessWidenerPath = file("src/main/resources/webdisplays.accesswidener") -} - dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.layered() { - officialMojangMappings() - } - forge "net.minecraftforge:forge:${project.forge_version}" + minecraft 'net.minecraftforge:forge:1.19.2-43.2.6' + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' - modImplementation "com.github.Mysticpasta1:mcef-forge:a9bf168a92" - modImplementation "curse.maven:cloth_config_forge-348521:3972423" - modImplementation "curse.maven:SU-370704:4410614" - modImplementation "curse.maven:spark-361579:4381167" - // Uncomment the following line to enable the deprecated Fabric API modules. - // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. - - // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" + implementation "com.github.Mysticpasta1:mcef-forge:76b4b8bfcb" + implementation "curse.maven:cloth_config_forge-348521:3972423" + implementation "curse.maven:SU-370704:4410614" + implementation "curse.maven:spark-361579:4381167" } -loom { - forge { - mixinConfigs = [ - "webdisplays.mixin.json" - ] - } -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} - -tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 -} - -java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() +sourceSets { + main.resources.srcDirs += 'src/generated/resources' } +// Example for how to get properties into the manifest for reading by the runtime.. jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} + manifest { + attributes([ + "Specification-Title": "mcef", + "Specification-Vendor": "forgecef", + "Specification-Version": "1", // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version}", + "Implementation-Vendor" :"forgecef", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs": "forgecef.mixins.json" + ]) } } -// configure the maven publication +// Example configuration to allow publishing using the maven-publish task +// we define a custom artifact that is sourced from the reobfJar output task +// and then declare that to be published +// Note you'll need to add a repository here +def reobfFile = file("$buildDir/reobfJar/output.jar") +def reobfArtifact = artifacts.add('default', reobfFile) { + type 'jar' + builtBy 'reobfJar' +} publishing { publications { mavenJava(MavenPublication) { - from components.java + artifact reobfArtifact } } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. + maven { + url "file:///${project.projectDir}/mcmodsrepo" + } } +} + +apply plugin: 'org.spongepowered.mixin' + +mixin { + add sourceSets.main, "webdisplays.refmap.json" +} + +task deobfJar(type: Jar) { + from sourceSets.main.output + classifier = 'deobf' } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 18010b4..914d1ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,23 +1,20 @@ pluginManagement { repositories { - pluginManagement { - repositories { - //jcenter() // jcenter will be stopped in 2022 - mavenCentral() - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' + gradlePluginPortal() + maven { url = 'https://maven.minecraftforge.net/' } + } + resolutionStrategy { + eachPlugin { + switch (requested.id.toString()) { + case "net.minecraftforge.gradle": { + useModule("${requested.id}:ForgeGradle:${requested.version}") + break } - maven { url "https://maven.architectury.dev/" } - maven { url "https://files.minecraftforge.net/maven/" } - maven { - name = 'Cotton' - url = 'https://server.bbkr.space/artifactory/libs-release/' + case "org.spongepowered.mixin": { + useModule("org.spongepowered:mixingradle:${requested.version}") + break; } - gradlePluginPortal() } } - mavenCentral() - gradlePluginPortal() } } \ No newline at end of file diff --git a/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java b/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java index 04fdac8..7c273b6 100644 --- a/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java +++ b/src/main/java/net/montoyo/wd/client/gui/GuiKeyboard.java @@ -4,19 +4,12 @@ package net.montoyo.wd.client.gui; -import com.mojang.blaze3d.platform.InputConstants; -import com.sun.jna.platform.unix.X11; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.EditBox; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.loading.FMLPaths; import net.montoyo.wd.WebDisplays; import net.montoyo.wd.client.gui.controls.Button; @@ -30,20 +23,14 @@ import net.montoyo.wd.utilities.BlockSide; import net.montoyo.wd.utilities.Log; import net.montoyo.wd.utilities.TypeData; import net.montoyo.wd.utilities.Util; -import org.apache.commons.lang3.CharUtils; -import org.cef.browser.CefBrowserOsr; -import org.jline.utils.Display; import org.lwjgl.glfw.GLFW; +import org.cef.browser.CefBrowserOsr; -import java.awt.event.KeyEvent; import java.io.*; import java.util.ArrayList; import java.util.Locale; import java.util.Map; -import static com.mojang.blaze3d.platform.InputConstants.*; -import static java.awt.event.KeyEvent.*; - @OnlyIn(Dist.CLIENT) public class GuiKeyboard extends WDScreen { @@ -142,7 +129,7 @@ public class GuiKeyboard extends WDScreen { Minecraft.getInstance().setScreen(null); } - int chr = getChar(keyCode, scanCode); + int chr = CefBrowserOsr.remapKeycode(keyCode, (char) keyCode, mod); evStack.add(new TypeData(TypeData.Action.PRESS, chr, mod)); evStack.add(new TypeData(TypeData.Action.RELEASE, chr, mod));