-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- TextInputUtil 클래스 래퍼가 ObfuscatedField를 이용해 값을 가져오게 고침 - 옵티파인은 ChatScreen을 상속받는 GuiChatOF 클래스를 구현하고 있음 - NaraeUtils에서 리플렉션 파트를 ReflectionFieldInfo와 ReflectionFieldMap으로 분리 표지판 크래시 수정 - TextComponentWrapper 인터페이스에서 modifyText(String) 메소드 삭제
- Loading branch information
Showing
10 changed files
with
155 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/kr/neko/sokcuri/naraechat/Obfuscated/ReflectionFieldInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kr.neko.sokcuri.naraechat.Obfuscated; | ||
|
||
public class ReflectionFieldInfo<O, T> { | ||
static public <O, T> ReflectionFieldInfo create(String name, Class<T> type, Class<O> owner, int depth) { | ||
return new ReflectionFieldInfo(name, type, owner, depth); | ||
} | ||
|
||
ReflectionFieldInfo(String name, Class<T> type, Class<O> owner, int depth) { | ||
this.name = name; | ||
this.type = type; | ||
this.owner = owner; | ||
this.depth = depth; | ||
} | ||
|
||
private String name; | ||
private Class<T> type; | ||
private Class<O> owner; | ||
private int depth; | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public Class<T> getTypeClass() { | ||
return this.type; | ||
} | ||
|
||
public Class<O> getOwnerClass() { | ||
return this.owner; | ||
} | ||
|
||
public int getDepth() { | ||
return this.depth; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/kr/neko/sokcuri/naraechat/Obfuscated/ReflectionFieldMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package kr.neko.sokcuri.naraechat.Obfuscated; | ||
|
||
import net.minecraft.client.gui.widget.TextFieldWidget; | ||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class ReflectionFieldMap<T> { | ||
private HashMap<String, List<ReflectionFieldInfo>> map = new HashMap<>(); | ||
private Class<T> target; | ||
|
||
public ReflectionFieldMap(Class<T> target) { | ||
this.target = target; | ||
} | ||
|
||
public List<ReflectionFieldInfo> getReflectionArray(List<ReflectionFieldInfo> array, Class<?> owner, int depth) { | ||
for (Field field : owner.getDeclaredFields()) { | ||
array.add(ReflectionFieldInfo.create(field.getName(), field.getType(), owner, depth)); | ||
} | ||
|
||
if (owner.getSuperclass() != null) { | ||
getReflectionArray(array, owner.getSuperclass(), depth + 1); | ||
} | ||
return array; | ||
} | ||
|
||
public T findField(Object owner) { | ||
String className = owner.getClass().getName(); | ||
if (!map.containsKey(className)) { | ||
List<ReflectionFieldInfo> fieldInfoArray = getReflectionArray(new ArrayList(), owner.getClass(), 0); | ||
List<ReflectionFieldInfo> savedInfo = new ArrayList<>(); | ||
|
||
for (ReflectionFieldInfo fieldInfo : fieldInfoArray) { | ||
if (fieldInfo.getTypeClass() == target) { | ||
savedInfo.add(fieldInfo); | ||
} | ||
} | ||
|
||
map.put(className, savedInfo); | ||
} | ||
|
||
if (map.containsKey(className)) { | ||
for (ReflectionFieldInfo fieldInfo : map.get(className)) { | ||
Object obj = ObfuscationReflectionHelper.getPrivateValue(fieldInfo.getOwnerClass(), owner, fieldInfo.getName()); | ||
if (obj instanceof TextFieldWidget) { | ||
if (((TextFieldWidget)obj).isFocused()) { | ||
return (T)obj; | ||
} | ||
} else { | ||
return (T)obj; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.