Key input

This commit is contained in:
Mysticpasta1 2023-03-05 03:04:46 -06:00
parent 57beebfc02
commit d66be53fb8
3 changed files with 115 additions and 97 deletions

View File

@ -1,22 +1,66 @@
plugins { plugins {
id 'dev.architectury.loom' version '0.12.0-SNAPSHOT' id 'eclipse'
id 'io.github.juuxel.loom-quiltflower' version '1.6.0'
id 'maven-publish' id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'org.spongepowered.mixin' version '0.7.+'
} }
sourceCompatibility = JavaVersion.VERSION_17 version = mod_version
targetCompatibility = JavaVersion.VERSION_17 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 println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
version = project.mod_version minecraft {
group = project.maven_group 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 { mods {
// Add repositories to retrieve artifacts from in here. citadel {
// You should only use this when depending on other mods because source sourceSets.main
// 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. }
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://maven.shedaniel.me/" }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven { maven {
@ -25,75 +69,65 @@ repositories {
} }
} }
loom {
accessWidenerPath = file("src/main/resources/webdisplays.accesswidener")
}
dependencies { dependencies {
// To change the versions see the gradle.properties file minecraft 'net.minecraftforge:forge:1.19.2-43.2.6'
minecraft "com.mojang:minecraft:${project.minecraft_version}" annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
mappings loom.layered() {
officialMojangMappings()
}
forge "net.minecraftforge:forge:${project.forge_version}"
modImplementation "com.github.Mysticpasta1:mcef-forge:a9bf168a92" implementation "com.github.Mysticpasta1:mcef-forge:76b4b8bfcb"
modImplementation "curse.maven:cloth_config_forge-348521:3972423" implementation "curse.maven:cloth_config_forge-348521:3972423"
modImplementation "curse.maven:SU-370704:4410614" implementation "curse.maven:SU-370704:4410614"
modImplementation "curse.maven:spark-361579:4381167" implementation "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}"
} }
loom { sourceSets {
forge { main.resources.srcDirs += 'src/generated/resources'
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()
} }
// Example for how to get properties into the manifest for reading by the runtime..
jar { jar {
from("LICENSE") { manifest {
rename { "${it}_${project.archivesBaseName}"} 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 { publishing {
publications { publications {
mavenJava(MavenPublication) { 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 { repositories {
// Add repositories to publish to here. maven {
// Notice: This block does NOT have the same function as the block in the top level. url "file:///${project.projectDir}/mcmodsrepo"
// The repositories here will be used for publishing your artifact, not for }
// retrieving dependencies.
} }
} }
apply plugin: 'org.spongepowered.mixin'
mixin {
add sourceSets.main, "webdisplays.refmap.json"
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}

View File

@ -1,23 +1,20 @@
pluginManagement { pluginManagement {
repositories { repositories {
pluginManagement { gradlePluginPortal()
repositories { maven { url = 'https://maven.minecraftforge.net/' }
//jcenter() // jcenter will be stopped in 2022 }
mavenCentral() resolutionStrategy {
maven { eachPlugin {
name = 'Fabric' switch (requested.id.toString()) {
url = 'https://maven.fabricmc.net/' case "net.minecraftforge.gradle": {
useModule("${requested.id}:ForgeGradle:${requested.version}")
break
} }
maven { url "https://maven.architectury.dev/" } case "org.spongepowered.mixin": {
maven { url "https://files.minecraftforge.net/maven/" } useModule("org.spongepowered:mixingradle:${requested.version}")
maven { break;
name = 'Cotton'
url = 'https://server.bbkr.space/artifactory/libs-release/'
} }
gradlePluginPortal()
} }
} }
mavenCentral()
gradlePluginPortal()
} }
} }

View File

@ -4,19 +4,12 @@
package net.montoyo.wd.client.gui; 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.Minecraft;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; 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.minecraftforge.fml.loading.FMLPaths;
import net.montoyo.wd.WebDisplays; import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.gui.controls.Button; 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.Log;
import net.montoyo.wd.utilities.TypeData; import net.montoyo.wd.utilities.TypeData;
import net.montoyo.wd.utilities.Util; 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.lwjgl.glfw.GLFW;
import org.cef.browser.CefBrowserOsr;
import java.awt.event.KeyEvent;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.mojang.blaze3d.platform.InputConstants.*;
import static java.awt.event.KeyEvent.*;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiKeyboard extends WDScreen { public class GuiKeyboard extends WDScreen {
@ -142,7 +129,7 @@ public class GuiKeyboard extends WDScreen {
Minecraft.getInstance().setScreen(null); 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.PRESS, chr, mod));
evStack.add(new TypeData(TypeData.Action.RELEASE, chr, mod)); evStack.add(new TypeData(TypeData.Action.RELEASE, chr, mod));