Skip to content

Commit aacb886

Browse files
committed
Порт на MC 1.6.4
1 parent a005d66 commit aacb886

File tree

5 files changed

+49
-56
lines changed

5 files changed

+49
-56
lines changed

build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ repositories {
2020
if (repositories.hasProperty('redserver')) {
2121
redserver()
2222
}
23+
maven {
24+
url 'https://libraries.minecraft.net/'
25+
}
2326
mavenCentral()
2427
}
2528

@@ -35,8 +38,8 @@ archivesBaseName = 'FontFix'
3538
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_6
3639

3740
dependencies {
38-
compile group: 'net.minecraftforge', name: 'forgeSrc', version: '1.4.7-6.6.2.534'
39-
compile group: 'net.minecraft', name: 'launchwrapper', version: '1.5'
41+
compile group: 'net.minecraftforge', name: 'forgeSrc', version: '1.6.4-9.11.1.1345'
42+
compile group: 'net.minecraft', name: 'launchwrapper', version: '1.8'
4043
}
4144

4245
tasks.withType(JavaCompile) {
@@ -61,7 +64,7 @@ artifacts {
6164

6265
/* Reobf task */
6366
task reobf(type: BON, dependsOn: jar) {
64-
mcpFolder = getProperty('minecraft.mcp.dir') + '/1.4.7-forge'
67+
mcpFolder = getProperty('minecraft.mcp.dir') + '/1.6.4-forge'
6568
input = jar.archivePath
6669
output = jar.archivePath
6770
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Project
22
group=me.theandrey
3-
version=1.4.7
3+
version=1.6.4

src/main/java/me/theandrey/fontfix/ASMTransformer.java

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.theandrey.fontfix;
22

33
import java.util.ListIterator;
4-
import cpw.mods.fml.relauncher.IClassTransformer;
4+
import net.minecraft.launchwrapper.IClassTransformer;
55
import org.objectweb.asm.ClassWriter;
66
import org.objectweb.asm.Type;
77
import org.objectweb.asm.tree.*;
@@ -19,65 +19,54 @@ public class ASMTransformer implements IClassTransformer {
1919
"\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F" +
2020
"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F" +
2121
"\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F";
22-
private static final String ASCII_TEXTURE = "/font/default.png";
23-
private static final String CYRILLIC_TEXTURE = "/font/default_ru.png";
22+
private static final String ASCII_TEXTURE = "textures/font/ascii.png";
23+
private static final String ASCII_TEXTURE_RU = "textures/font/ascii_ru.png";
2424

2525
@Override
26-
public byte[] transform(String name, byte[] bytes) {
27-
if (name.equals("bn")) {
28-
return patchStringTranslate(bytes, true);
29-
} else if (name.equals("net.minecraft.util.StringTranslate")) {
30-
return patchStringTranslate(bytes, false);
26+
public byte[] transform(String name, String transformedName, byte[] bytes) {
27+
if (name.equals("bke")) {
28+
return patchLocale(bytes, true);
29+
} else if (name.equals("net.minecraft.client.resources.Locale")) {
30+
return patchLocale(bytes, false);
31+
} else if (name.equals("atv")) {
32+
return patchMinecraft(bytes, true);
3133
} else if (name.equals("net.minecraft.client.Minecraft")) {
32-
return patchMinecraft(bytes, LoadingPlugin.isGameObfuscated());
33-
} else if (name.equals("u") || name.equals("net.minecraft.util.ChatAllowedCharacters")) {
34+
return patchMinecraft(bytes, false);
35+
} else if (name.equals("v") || name.equals("net.minecraft.util.ChatAllowedCharacters")) {
3436
return patchAllowedCharacters(bytes);
3537
}
38+
3639
return bytes;
3740
}
3841

39-
/**
40-
* Делает русскую локаль не-unicode
41-
*/
42-
@SuppressWarnings("deprecation")
43-
private byte[] patchStringTranslate(byte[] bytes, boolean obf) {
42+
private byte[] patchLocale(byte[] bytes, boolean obf) {
4443
ClassNode clazz = Utils.readClass(bytes);
4544

46-
final String findMethod = obf ? "a" : "setLanguage";
47-
final String isUnicode = obf ? "e" : "isUnicode";
48-
final String currentLanguage = obf ? "d" : "currentLanguage";
45+
final Type classMc = Utils.getObjectType(obf ? "atv" : "net.minecraft.client.Minecraft");
46+
final Type classSettings = Utils.getObjectType(obf ? "aul" : "net.minecraft.client.settings.GameSettings");
47+
final Type classLocale = Utils.getObjectType(obf ? "bke" : "net.minecraft.client.resources.Locale");
48+
final String findMethod = obf ? "b" : "checkUnicode";
49+
final String getMinecraft = obf ? "w" : "getMinecraft";
50+
final String gameSettings = obf ? "u" : "gameSettings";
4951

5052
for (MethodNode method : clazz.methods) {
51-
if (method.name.equals(findMethod) && method.desc.equals(Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(String.class)))) {
52-
53-
ListIterator<AbstractInsnNode> iter = method.instructions.iterator();
54-
55-
while (iter.hasNext()) {
56-
AbstractInsnNode insn = iter.next();
57-
58-
if (insn.getOpcode() == PUTFIELD) {
59-
FieldInsnNode fieldInsn = ((FieldInsnNode)insn);
60-
61-
// Присвоения значения 'currentLanguage'
62-
if (fieldInsn.owner.equals(clazz.name) && fieldInsn.name.equals(currentLanguage) && fieldInsn.desc.equals(Type.getType(String.class).getDescriptor())) {
63-
64-
LabelNode label = new LabelNode();
65-
InsnList list = new InsnList();
66-
list.add(new LdcInsnNode("ru_RU"));
67-
list.add(new VarInsnNode(ALOAD, 1)); // #1 param
68-
list.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(String.class), "equals", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getType(Object.class))));
69-
list.add(new JumpInsnNode(IFEQ, label));
70-
list.add(new VarInsnNode(ALOAD, 0)); // this
71-
list.add(new InsnNode(ICONST_0));
72-
list.add(new FieldInsnNode(PUTFIELD, clazz.name, isUnicode, Type.BOOLEAN_TYPE.getDescriptor())); // this
73-
list.add(label);
74-
75-
method.instructions.insert(insn, list);
76-
break;
77-
}
78-
}
79-
}
80-
53+
if (method.name.equals(findMethod) && method.desc.equals(Type.getMethodDescriptor(Type.VOID_TYPE))) {
54+
InsnList list = new InsnList();
55+
LabelNode label = new LabelNode();
56+
57+
list.add(new LdcInsnNode("ru_RU"));
58+
list.add(new MethodInsnNode(INVOKESTATIC, classMc.getInternalName(), getMinecraft, Type.getMethodDescriptor(classMc)));
59+
list.add(new FieldInsnNode(GETFIELD, classMc.getInternalName(), gameSettings, classSettings.getDescriptor()));
60+
list.add(new FieldInsnNode(GETFIELD, classSettings.getInternalName(), obf ? "an" : "language", Type.getType(String.class).getDescriptor()));
61+
list.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(String.class), "equals", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getType(Object.class))));
62+
list.add(new JumpInsnNode(IFEQ, label));
63+
list.add(new VarInsnNode(ALOAD, 0));
64+
list.add(new InsnNode(ICONST_0));
65+
list.add(new FieldInsnNode(PUTFIELD, classLocale.getInternalName(), "field_135029_d", Type.BOOLEAN_TYPE.getDescriptor()));
66+
list.add(new InsnNode(RETURN));
67+
list.add(label);
68+
69+
method.instructions.insert(list);
8170
break;
8271
}
8372
}
@@ -91,11 +80,11 @@ private byte[] patchStringTranslate(byte[] bytes, boolean obf) {
9180
*/
9281
private byte[] patchMinecraft(byte[] bytes, boolean obf) {
9382
ClassNode clazz = Utils.readClass(bytes);
94-
final Type fondRenderer = Utils.getObjectType(obf ? "atq" : "net.minecraft.client.gui.FontRenderer");
95-
final String startGame = obf ? "a" : "startGame";
83+
final Type fondRenderer = Utils.getObjectType(obf ? "avi" : "net.minecraft.client.gui.FontRenderer");
84+
final String mStartGame = obf ? "O" : "startGame";
9685

9786
for (MethodNode method : clazz.methods) {
98-
if (method.name.equals(startGame) && method.desc.equals(Type.getMethodDescriptor(Type.VOID_TYPE))) {
87+
if (method.name.equals(mStartGame) && method.desc.equals(Type.getMethodDescriptor(Type.VOID_TYPE))) {
9988

10089
ListIterator<AbstractInsnNode> iter = method.instructions.iterator();
10190
boolean inConstructor = false;
@@ -113,7 +102,7 @@ private byte[] patchMinecraft(byte[] bytes, boolean obf) {
113102
if (insn.getType() == AbstractInsnNode.LDC_INSN && inConstructor) {
114103
LdcInsnNode ldc = (LdcInsnNode)insn;
115104
if (ldc.cst.equals(ASCII_TEXTURE)) {
116-
ldc.cst = CYRILLIC_TEXTURE;
105+
ldc.cst = ASCII_TEXTURE_RU;
117106
}
118107
}
119108

src/main/java/me/theandrey/fontfix/LoadingPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Map;
44
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
55

6+
@IFMLLoadingPlugin.SortingIndex(900)
67
public class LoadingPlugin implements IFMLLoadingPlugin {
78

89
@Override

0 commit comments

Comments
 (0)