Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.17 업데이트 #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.0"
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.1"
}
}
apply plugin: 'net.minecraftforge.gradle'
Expand All @@ -16,7 +16,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

compileJava.options.encoding = 'UTF-8'
version = '1.16.4-0.7.1'
version = '1.17.1-0.7.1'
group = 'kr.neko.sokcuri.naraechat' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'naraechat'

Expand All @@ -29,17 +29,15 @@ configurations {
compile.extendsFrom(embed)
}

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20201028-1.16.3'
mappings channel: 'official', version: '1.17.1'
// makeObfSourceJar false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

// Default run configurations.
Expand All @@ -62,11 +60,16 @@ minecraft {
}
}

java {
// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower.
toolchain.languageVersion = JavaLanguageVersion.of(16)
}

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.16.4-35.1.4'
minecraft 'net.minecraftforge:forge:1.17.1-37.1.1'
compile 'net.java.dev.jna:jna:4.1.0'
compile 'net.java.dev.jna:jna-platform:4.1.0'
compile 'org.apache.commons:commons-text:1.7'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sun Aug 25 16:00:30 KST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
56 changes: 27 additions & 29 deletions src/main/java/kr/neko/sokcuri/naraechat/IMEIndicator.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package kr.neko.sokcuri.naraechat;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import kr.neko.sokcuri.naraechat.Keyboard.KeyboardLayout;
import kr.neko.sokcuri.naraechat.Wrapper.TextComponentWrapper;
import kr.neko.sokcuri.naraechat.Wrapper.TextFieldWidgetWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.gui.Font;
import org.lwjgl.opengl.GL11;

import java.awt.*;
Expand Down Expand Up @@ -44,7 +42,7 @@ public void drawIMEIndicator(KeyboardLayout layout) {
}

TextFieldWidgetWrapper wrapper = (TextFieldWidgetWrapper)comp;
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
Font font = Minecraft.getInstance().font;

boolean enableBackgroundDrawing = wrapper.getEnableBackgroundDrawing();
boolean isEnabled = wrapper.isEnabled();
Expand All @@ -69,11 +67,11 @@ public void drawIMEIndicator(KeyboardLayout layout) {
String indicatorStr = indicatorFirst + indicatorLast;

int indicatorMargin = 1;
int indicatorFirstWidth = fontRenderer.getStringWidth(indicatorFirst);
int indicatorWidth = fontRenderer.getStringWidth(indicatorStr);
int indicatorHeight = fontRenderer.getWordWrappedHeight(indicatorStr, 100);
int indicatorFirstWidth = font.width(indicatorFirst);
int indicatorWidth = font.width(indicatorStr);
int indicatorHeight = font.wordWrapHeight(indicatorStr, 100);

int strWidth = fontRenderer.getStringWidth(text);
int strWidth = font.width(text);
if (strWidth + indicatorWidth > width) {
indicatorX = x + width - indicatorWidth;
} else {
Expand Down Expand Up @@ -102,8 +100,8 @@ public void drawIMEIndicator(KeyboardLayout layout) {
}

drawIndicatorBox(indicatorX - indicatorMargin, y - height - indicatorMargin, indicatorX + indicatorWidth + indicatorMargin, y - height + indicatorHeight + indicatorMargin);
fontRenderer.drawString(new MatrixStack(), indicatorFirst, indicatorX, y - height, layout.getIndicatorColor().getRGB());
fontRenderer.drawString(new MatrixStack(), indicatorLast, indicatorX + indicatorFirstWidth, y - height, new Color(0xFF, 0xFF, 0xFF).getRGB());
font.draw(new PoseStack(), indicatorFirst, indicatorX, y - height, layout.getIndicatorColor().getRGB());
font.draw(new PoseStack(), indicatorLast, indicatorX + indicatorFirstWidth, y - height, new Color(0xFF, 0xFF, 0xFF).getRGB());
}

void drawIndicatorBox(float x, float y, float cx, float cy) {
Expand All @@ -119,23 +117,23 @@ void drawIndicatorBox(float x, float y, float cx, float cy) {
cy = j;
}

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.enableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.polygonMode(GL_FRONT_AND_BACK, GL_FILL);
GlStateManager.color4f(0.0f, 0.0f, 0.0f, 0.7f);
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f);
GlStateManager.disableTexture();
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
bufferbuilder.pos(x, cy, 0.0D).endVertex();
bufferbuilder.pos(cx, cy, 0.0D).endVertex();
bufferbuilder.pos(cx, y, 0.0D).endVertex();
bufferbuilder.pos(x, y, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableTexture();
GlStateManager.disableAlphaTest();
GlStateManager.disableBlend();
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tesselator.getBuilder();
GlStateManager._enableBlend();
// GlStateManager.enableAlphaTest(); // need to prove why this unnecessary
GlStateManager._polygonMode(GL_FRONT_AND_BACK, GL_FILL);
RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 0.7f);
// GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f); // TODO: is this unnecessary?
GlStateManager._disableTexture();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
bufferbuilder.vertex(x, cy, 0.0D).endVertex();
bufferbuilder.vertex(cx, cy, 0.0D).endVertex();
bufferbuilder.vertex(cx, y, 0.0D).endVertex();
bufferbuilder.vertex(x, y, 0.0D).endVertex();
tesselator.end();
GlStateManager._enableTexture();
// GlStateManager.disableAlphaTest();
GlStateManager._disableBlend();
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package kr.neko.sokcuri.naraechat.Keyboard;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import kr.neko.sokcuri.naraechat.HangulProcessor;
import kr.neko.sokcuri.naraechat.IMEIndicator;
import kr.neko.sokcuri.naraechat.NaraeUtils;
import kr.neko.sokcuri.naraechat.Obfuscated.*;
import kr.neko.sokcuri.naraechat.Wrapper.TextComponentWrapper;
import kr.neko.sokcuri.naraechat.Wrapper.TextFieldWidgetWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.gui.Font;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.event.TickEvent;

Expand Down Expand Up @@ -290,23 +292,20 @@ void drawAssembleCharBox(int startX, int startY, int endX, int endY, int x, int
startX = x + width;
}

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.enableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.polygonMode(GL_FRONT_AND_BACK, GL_FILL);
GlStateManager.color4f(255.0f, 255.0f, 255.0f, 0.3f);
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f);
GlStateManager.disableTexture();
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
bufferbuilder.pos(startX, endY, 0.0D).endVertex();
bufferbuilder.pos(endX, endY, 0.0D).endVertex();
bufferbuilder.pos(endX, startY, 0.0D).endVertex();
bufferbuilder.pos(startX, startY, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableTexture();
GlStateManager.disableAlphaTest();
GlStateManager.disableBlend();
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tesselator.getBuilder();
GlStateManager._enableBlend();
GlStateManager._polygonMode(GL_FRONT_AND_BACK, GL_FILL);
RenderSystem.setShaderColor(255.0f, 255.0f, 255.0f, 0.3f);
GlStateManager._disableTexture();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
bufferbuilder.vertex(startX, endY, 0.0D).endVertex();
bufferbuilder.vertex(endX, endY, 0.0D).endVertex();
bufferbuilder.vertex(endX, startY, 0.0D).endVertex();
bufferbuilder.vertex(startX, startY, 0.0D).endVertex();
tesselator.end();
GlStateManager._enableTexture();
GlStateManager._disableBlend();
}

@Override
Expand All @@ -324,7 +323,7 @@ public void cleanUp() {
private void drawCharAssembleBox(TextComponentWrapper comp) {
if (comp instanceof TextFieldWidgetWrapper) {
TextFieldWidgetWrapper wrapper = (TextFieldWidgetWrapper) comp;
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
Font font = Minecraft.getInstance().font;

boolean enableBackgroundDrawing = wrapper.getEnableBackgroundDrawing();
boolean isEnabled = wrapper.isEnabled();
Expand All @@ -351,9 +350,9 @@ private void drawCharAssembleBox(TextComponentWrapper comp) {
if (cursorPosition == 0) return;
if (trimStr.length() == 0) return;
if (specifiedOffset == 0 || specifiedOffset - 1 >= trimStr.length()) return;
int startX = x + fontRenderer.getStringWidth(trimStr.substring(0, specifiedOffset - 1));
int startX = x + font.width(trimStr.substring(0, specifiedOffset - 1));
int startY = y - 1;
int endX = x + fontRenderer.getStringWidth(trimStr.substring(0, specifiedOffset)) - 1;
int endX = x + font.width(trimStr.substring(0, specifiedOffset)) - 1;
int endY = y + 1 + 9;
drawAssembleCharBox(startX, startY, endX, endY, x, width);
} else {
Expand Down
43 changes: 21 additions & 22 deletions src/main/java/kr/neko/sokcuri/naraechat/NaraeChat.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package kr.neko.sokcuri.naraechat;

import com.mojang.blaze3d.platform.InputConstants;
import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.win32.StdCallLibrary;

import kr.neko.sokcuri.naraechat.Keyboard.*;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.INestedGuiEventHandler;
import net.minecraft.client.gui.screen.ControlsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraft.client.gui.screens.controls.ControlsScreen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.GuiScreenEvent;
Expand All @@ -20,14 +18,15 @@
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmlclient.registry.ClientRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.swing.text.JTextComponent;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -40,13 +39,13 @@ public final class NaraeChat
{
private static KeyboardLayout keyboard = Hangul_Set_2_Layout.getInstance();
private static List<KeyboardLayout> keyboardArray = new ArrayList<>();
public static KeyBinding[] keyBindings;
public static KeyMapping[] keyBindings;

// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();

private int getBindingKeyCode(int n) {
return keyBindings[n].getKey().getKeyCode();
return keyBindings[n].getKey().getValue();
}

private void switchKeyboardLayout() {
Expand Down Expand Up @@ -112,11 +111,11 @@ public void proxyHangulSpecificKey(GuiScreenEvent.KeyboardKeyPressedEvent.Pre ev
}

// 키 바인딩 설정창일 때 우측 CONTROL이나 ALT가 단독으로만 동작하게 만들기
if (mc.currentScreen instanceof ControlsScreen) {
ControlsScreen controlsScreen = (ControlsScreen)mc.currentScreen;
if (mc.screen instanceof ControlsScreen) {
ControlsScreen controlsScreen = (ControlsScreen)mc.screen;
if (keyCode == GLFW_KEY_RIGHT_CONTROL || keyCode == GLFW_KEY_RIGHT_ALT) {
controlsScreen.keyPressed(keyCode, scanCode, glfwModifier);
controlsScreen.buttonId = null;
controlsScreen.selectedKey = null;
event.setCanceled(true);
return;
}
Expand All @@ -129,11 +128,11 @@ public void proxyHangulSpecificKey(GuiScreenEvent.KeyboardKeyPressedEvent.Pre ev
modifier = KeyModifier.NONE;
}

if (keyBindings[0].matchesKey(keyCode, scanCode) && keyBindings[0].getKeyModifier() == modifier) {
if (keyBindings[0].matches(keyCode, scanCode) && keyBindings[0].getKeyModifier() == modifier) {
switchKeyboardLayout();
}

if (keyBindings[1].matchesKey(keyCode, scanCode) && keyBindings[1].getKeyModifier() == modifier) {
if (keyBindings[1].matches(keyCode, scanCode) && keyBindings[1].getKeyModifier() == modifier) {
// hanja
}
}
Expand Down Expand Up @@ -161,22 +160,22 @@ private void setup(final FMLCommonSetupEvent event)

private void doClientStuff(final FMLClientSetupEvent event) {
// declare an array of key bindings
keyBindings = new KeyBinding[2];
keyBindings = new KeyMapping[2];

// instantiate the key bindings
keyBindings[0] = new KeyBinding("key.naraechat.ime_switch.desc", GLFW_KEY_RIGHT_ALT, "key.naraechat.category");
keyBindings[1] = new KeyBinding("key.naraechat.hanja.desc", GLFW_KEY_RIGHT_CONTROL, "key.naraechat.category");
keyBindings[0] = new KeyMapping("key.naraechat.ime_switch.desc", GLFW_KEY_RIGHT_ALT, "key.naraechat.category");
keyBindings[1] = new KeyMapping("key.naraechat.hanja.desc", GLFW_KEY_RIGHT_CONTROL, "key.naraechat.category");

if (Platform.isWindows()) {
keyBindings[0].setKeyModifierAndCode(KeyModifier.NONE, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_RIGHT_ALT));
keyBindings[1].setKeyModifierAndCode(KeyModifier.NONE, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_RIGHT_CONTROL));
keyBindings[0].setKeyModifierAndCode(KeyModifier.NONE, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_RIGHT_ALT));
keyBindings[1].setKeyModifierAndCode(KeyModifier.NONE, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_RIGHT_CONTROL));
}
else if (Platform.isMac()) {
keyBindings[0].setKeyModifierAndCode(KeyModifier.CONTROL, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_SPACE));
keyBindings[1].setKeyModifierAndCode(KeyModifier.SHIFT, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_ENTER));
keyBindings[0].setKeyModifierAndCode(KeyModifier.CONTROL, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_SPACE));
keyBindings[1].setKeyModifierAndCode(KeyModifier.SHIFT, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_ENTER));
} else {
keyBindings[0].setKeyModifierAndCode(KeyModifier.CONTROL, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_SPACE));
keyBindings[1].setKeyModifierAndCode(KeyModifier.NONE, InputMappings.Type.KEYSYM.getOrMakeInput(GLFW_KEY_F9));
keyBindings[0].setKeyModifierAndCode(KeyModifier.CONTROL, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_SPACE));
keyBindings[1].setKeyModifierAndCode(KeyModifier.NONE, InputConstants.Type.KEYSYM.getOrCreate(GLFW_KEY_F9));
}

// register all the key bindings
Expand Down
Loading