Commit c35f486df2c03c449caaf6315dcc566bd476603f

Authored by Mumfrey
1 parent 89fce7f9

adding new overlays, fixing minor bugs in AccessorTransformer

debug/obfuscation.properties
@@ -15,6 +15,9 @@ field_71425_J=running @@ -15,6 +15,9 @@ field_71425_J=running
15 field_110449_ao=defaultResourcePacks 15 field_110449_ao=defaultResourcePacks
16 field_71475_ae=serverName 16 field_71475_ae=serverName
17 field_71477_af=serverPort 17 field_71477_af=serverPort
  18 +field_147712_ad=shaderResourceLocations
  19 +field_147713_ae=shaderIndex
  20 +field_175083_ad=useShader
18 func_148833_a=processPacket 21 func_148833_a=processPacket
19 func_71411_J=runGameLoop 22 func_71411_J=runGameLoop
20 func_71407_l=runTick 23 func_71407_l=runTick
@@ -45,4 +48,8 @@ func_148260_a=saveScreenshot @@ -45,4 +48,8 @@ func_148260_a=saveScreenshot
45 func_148822_b=isFramebufferEnabled 48 func_148822_b=isFramebufferEnabled
46 func_147939_a=doRenderEntity 49 func_147939_a=doRenderEntity
47 func_76986_a=doRender 50 func_76986_a=doRender
48 -func_71370_a=resize  
49 \ No newline at end of file 51 \ No newline at end of file
  52 +func_71370_a=resize
  53 +func_175069_a=loadShader
  54 +func_78481_a=getFOVModifier
  55 +func_78479_a=setupCameraTransform
  56 +func_147693_a=loadSoundResource
50 \ No newline at end of file 57 \ No newline at end of file
java/client/com/mumfrey/liteloader/client/overlays/IEntityRenderer.java 0 → 100644
  1 +package com.mumfrey.liteloader.client.overlays;
  2 +
  3 +import net.minecraft.util.ResourceLocation;
  4 +
  5 +import com.mumfrey.liteloader.transformers.access.Accessor;
  6 +import com.mumfrey.liteloader.transformers.access.Invoker;
  7 +
  8 +/**
  9 + * Adapter for EntityRenderer to expose some private functionality
  10 + *
  11 + * @author Adam Mummery-Smith
  12 + */
  13 +@Accessor("EntityRenderer")
  14 +public interface IEntityRenderer
  15 +{
  16 + @Accessor("useShader") public abstract boolean getUseShader();
  17 + @Accessor("useShader") public abstract void setUseShader(boolean useShader);
  18 +
  19 + @Accessor("shaderResourceLocations") public abstract ResourceLocation[] getShaders();
  20 +
  21 + @Accessor("shaderIndex") public abstract int getShaderIndex();
  22 + @Accessor("shaderIndex") public abstract void setShaderIndex(int shaderIndex);
  23 +
  24 + @Invoker("loadShader") public abstract void selectShader(ResourceLocation shader);
  25 +
  26 + @Invoker("getFOVModifier") public abstract float getFOV(float partialTicks, boolean armFOV);
  27 +
  28 + @Invoker("setupCameraTransform") public abstract void setupCamera(float partialTicks, int pass);
  29 +}
java/client/com/mumfrey/liteloader/client/overlays/ISoundHandler.java 0 → 100644
  1 +package com.mumfrey.liteloader.client.overlays;
  2 +
  3 +import net.minecraft.client.audio.SoundList;
  4 +import net.minecraft.util.ResourceLocation;
  5 +
  6 +import com.mumfrey.liteloader.transformers.access.Accessor;
  7 +import com.mumfrey.liteloader.transformers.access.Invoker;
  8 +
  9 +@Accessor("SoundHandler")
  10 +public interface ISoundHandler
  11 +{
  12 + @Invoker("loadSoundResource")
  13 + public abstract void addSound(ResourceLocation sound, SoundList soundList);
  14 +}
java/client/com/mumfrey/liteloader/client/transformers/MinecraftTransformer.java
@@ -25,6 +25,8 @@ public class MinecraftTransformer extends AccessorTransformer @@ -25,6 +25,8 @@ public class MinecraftTransformer extends AccessorTransformer
25 { 25 {
26 this.addAccessor(Obf.IMinecraft.name); 26 this.addAccessor(Obf.IMinecraft.name);
27 this.addAccessor(Obf.IGuiTextField.name); 27 this.addAccessor(Obf.IGuiTextField.name);
  28 + this.addAccessor(Obf.IEntityRenderer.name);
  29 + this.addAccessor(Obf.ISoundHandler.name);
28 } 30 }
29 31
30 @Override 32 @Override
java/common/com/mumfrey/liteloader/core/runtime/Obf.java
@@ -25,8 +25,6 @@ public class Obf @@ -25,8 +25,6 @@ public class Obf
25 public static final Obf PacketEvents = new Obf("com.mumfrey.liteloader.core.PacketEvents" ); 25 public static final Obf PacketEvents = new Obf("com.mumfrey.liteloader.core.PacketEvents" );
26 public static final Obf PacketEventsClient = new Obf("com.mumfrey.liteloader.client.PacketEventsClient" ); 26 public static final Obf PacketEventsClient = new Obf("com.mumfrey.liteloader.client.PacketEventsClient" );
27 public static final Obf LoadingBar = new Obf("com.mumfrey.liteloader.client.gui.startup.LoadingBar" ); 27 public static final Obf LoadingBar = new Obf("com.mumfrey.liteloader.client.gui.startup.LoadingBar" );
28 - public static final Obf IMinecraft = new Obf("com.mumfrey.liteloader.client.overlays.IMinecraft" );  
29 - public static final Obf IGuiTextField = new Obf("com.mumfrey.liteloader.client.overlays.IGuiTextField" );  
30 public static final Obf GameProfile = new Obf("com.mojang.authlib.GameProfile" ); 28 public static final Obf GameProfile = new Obf("com.mojang.authlib.GameProfile" );
31 public static final Obf MinecraftMain = new Obf("net.minecraft.client.main.Main" ); 29 public static final Obf MinecraftMain = new Obf("net.minecraft.client.main.Main" );
32 public static final Obf MinecraftServer = new Obf("net.minecraft.server.MinecraftServer" ); 30 public static final Obf MinecraftServer = new Obf("net.minecraft.server.MinecraftServer" );
@@ -36,6 +34,13 @@ public class Obf @@ -36,6 +34,13 @@ public class Obf
36 public static final Obf postInit = new Obf("postInit" ); 34 public static final Obf postInit = new Obf("postInit" );
37 public static final Obf constructor = new Obf("<init>" ); 35 public static final Obf constructor = new Obf("<init>" );
38 36
  37 + // Overlays and Accessor Interfaces
  38 + // -----------------------------------------------------------------------------------------
  39 + public static final Obf IMinecraft = new Obf("com.mumfrey.liteloader.client.overlays.IMinecraft" );
  40 + public static final Obf IGuiTextField = new Obf("com.mumfrey.liteloader.client.overlays.IGuiTextField" );
  41 + public static final Obf IEntityRenderer = new Obf("com.mumfrey.liteloader.client.overlays.IEntityRenderer" );
  42 + public static final Obf ISoundHandler = new Obf("com.mumfrey.liteloader.client.overlays.ISoundHandler" );
  43 +
39 // Classes 44 // Classes
40 // ----------------------------------------------------------------------------------------- 45 // -----------------------------------------------------------------------------------------
41 public static final Obf Minecraft = new Obf("net.minecraft.client.Minecraft", "bsu" ); 46 public static final Obf Minecraft = new Obf("net.minecraft.client.Minecraft", "bsu" );
@@ -64,6 +69,7 @@ public class Obf @@ -64,6 +69,7 @@ public class Obf
64 public static final Obf RenderManager = new Obf("net.minecraft.client.renderer.entity.RenderManager", "cpt" ); 69 public static final Obf RenderManager = new Obf("net.minecraft.client.renderer.entity.RenderManager", "cpt" );
65 public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" ); 70 public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" );
66 public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" ); 71 public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" );
  72 + public static final Obf SoundHandler = new Obf("net.minecraft.client.audio.SoundHandler", "czh" );
67 73
68 // Fields 74 // Fields
69 // ----------------------------------------------------------------------------------------- 75 // -----------------------------------------------------------------------------------------
@@ -84,6 +90,9 @@ public class Obf @@ -84,6 +90,9 @@ public class Obf
84 public static final Obf defaultResourcePacks = new Obf("field_110449_ao", "aw" ); 90 public static final Obf defaultResourcePacks = new Obf("field_110449_ao", "aw" );
85 public static final Obf serverName = new Obf("field_71475_ae", "am" ); 91 public static final Obf serverName = new Obf("field_71475_ae", "am" );
86 public static final Obf serverPort = new Obf("field_71477_af", "an" ); 92 public static final Obf serverPort = new Obf("field_71477_af", "an" );
  93 + public static final Obf shaderResourceLocations = new Obf("field_147712_ad", "ab" );
  94 + public static final Obf shaderIndex = new Obf("field_147713_ae", "ac" );
  95 + public static final Obf useShader = new Obf("field_175083_ad", "ad" );
87 96
88 // Methods 97 // Methods
89 // ----------------------------------------------------------------------------------------- 98 // -----------------------------------------------------------------------------------------
@@ -119,6 +128,10 @@ public class Obf @@ -119,6 +128,10 @@ public class Obf
119 public static final Obf doRender = new Obf("func_76986_a", "a" ); 128 public static final Obf doRender = new Obf("func_76986_a", "a" );
120 public static final Obf doRenderShadowAndFire = new Obf("func_76979_b", "b" ); 129 public static final Obf doRenderShadowAndFire = new Obf("func_76979_b", "b" );
121 public static final Obf resize = new Obf("func_71370_a", "a" ); 130 public static final Obf resize = new Obf("func_71370_a", "a" );
  131 + public static final Obf loadShader = new Obf("func_175069_a", "a" );
  132 + public static final Obf getFOVModifier = new Obf("func_78481_a", "a" );
  133 + public static final Obf setupCameraTransform = new Obf("func_78479_a", "a" );
  134 + public static final Obf loadSoundResource = new Obf("func_147693_a", "a" );
122 135
123 public static final int MCP = 0; 136 public static final int MCP = 0;
124 public static final int SRG = 1; 137 public static final int SRG = 1;
@@ -249,6 +262,12 @@ public class Obf @@ -249,6 +262,12 @@ public class Obf
249 { 262 {
250 return -1; 263 return -1;
251 } 264 }
  265 +
  266 + @Override
  267 + public String toString()
  268 + {
  269 + return String.format("%s[%s,%s,%s]@%d", this.getClass().getSimpleName(), this.name, this.srg, this.obf, this.getOrdinal());
  270 + }
252 271
253 /** 272 /**
254 * @param seargeName 273 * @param seargeName
@@ -300,7 +319,7 @@ public class Obf @@ -300,7 +319,7 @@ public class Obf
300 { 319 {
301 for (Field fd : obf.getFields()) 320 for (Field fd : obf.getFields())
302 { 321 {
303 - if (fd.getType().equals(Obf.class)) 322 + if (Obf.class.isAssignableFrom(fd.getType()))
304 { 323 {
305 String fieldName = fd.getName(); 324 String fieldName = fd.getName();
306 Obf entry = (Obf)fd.get(null); 325 Obf entry = (Obf)fd.get(null);
java/common/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java
@@ -531,16 +531,16 @@ public abstract class ByteCodeUtilities @@ -531,16 +531,16 @@ public abstract class ByteCodeUtilities
531 * Find a method in the target class which matches the specified method name and descriptor 531 * Find a method in the target class which matches the specified method name and descriptor
532 * 532 *
533 * @param classNode 533 * @param classNode
534 - * @param methodName 534 + * @param searchFor
535 * @param desc 535 * @param desc
536 */ 536 */
537 - public static MethodNode findMethod(ClassNode classNode, Obf obf, String desc) 537 + public static MethodNode findMethod(ClassNode classNode, Obf searchFor, String desc)
538 { 538 {
539 int ordinal = 0; 539 int ordinal = 0;
540 540
541 for (MethodNode method : classNode.methods) 541 for (MethodNode method : classNode.methods)
542 { 542 {
543 - if (obf.matches(method.name, ordinal++) && method.desc.equals(desc)) 543 + if (searchFor.matches(method.name, ordinal++) && method.desc.equals(desc))
544 return method; 544 return method;
545 } 545 }
546 546
@@ -551,15 +551,15 @@ public abstract class ByteCodeUtilities @@ -551,15 +551,15 @@ public abstract class ByteCodeUtilities
551 * Find a field in the target class which matches the specified field name 551 * Find a field in the target class which matches the specified field name
552 * 552 *
553 * @param classNode 553 * @param classNode
554 - * @param fieldName 554 + * @param searchFor
555 */ 555 */
556 - public static FieldNode findField(ClassNode classNode, Obf obf) 556 + public static FieldNode findField(ClassNode classNode, Obf searchFor)
557 { 557 {
558 int ordinal = 0; 558 int ordinal = 0;
559 559
560 for (FieldNode field : classNode.fields) 560 for (FieldNode field : classNode.fields)
561 { 561 {
562 - if (obf.matches(field.name, ordinal++)) 562 + if (searchFor.matches(field.name, ordinal++))
563 return field; 563 return field;
564 } 564 }
565 565
java/common/com/mumfrey/liteloader/transformers/ObfProvider.java
@@ -14,7 +14,6 @@ public interface ObfProvider @@ -14,7 +14,6 @@ public interface ObfProvider
14 * Try to locate an obfuscation table entry by name (id), returns null if no entry was found 14 * Try to locate an obfuscation table entry by name (id), returns null if no entry was found
15 * 15 *
16 * @param name 16 * @param name
17 - * @return  
18 */ 17 */
19 public abstract Obf getByName(String name); 18 public abstract Obf getByName(String name);
20 } 19 }
java/common/com/mumfrey/liteloader/transformers/access/Accessor.java
@@ -14,5 +14,5 @@ import java.lang.annotation.Target; @@ -14,5 +14,5 @@ import java.lang.annotation.Target;
14 @Retention(RetentionPolicy.CLASS) 14 @Retention(RetentionPolicy.CLASS)
15 public @interface Accessor 15 public @interface Accessor
16 { 16 {
17 - public String value(); 17 + public String[] value();
18 } 18 }
java/common/com/mumfrey/liteloader/transformers/access/AccessorTransformer.java
@@ -105,8 +105,10 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -105,8 +105,10 @@ public abstract class AccessorTransformer extends ClassTransformer
105 * 105 *
106 * @param name Obfuscation table entry to fetch 106 * @param name Obfuscation table entry to fetch
107 */ 107 */
108 - private Obf getObf(String name) 108 + private Obf getObf(List<String> names)
109 { 109 {
  110 + String name = names.get(0);
  111 +
110 Matcher ordinalPattern = AccessorTransformer.ordinalRefPattern.matcher(name); 112 Matcher ordinalPattern = AccessorTransformer.ordinalRefPattern.matcher(name);
111 if (ordinalPattern.matches()) 113 if (ordinalPattern.matches())
112 { 114 {
@@ -128,8 +130,15 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -128,8 +130,15 @@ public abstract class AccessorTransformer extends ClassTransformer
128 { 130 {
129 return obf; 131 return obf;
130 } 132 }
131 -  
132 - throw new RuntimeException("No obfuscation table entry could be found for '" + name + "'"); 133 +
  134 + if (names.size() > 0 && names.size() < 4)
  135 + {
  136 + String name2 = names.size() > 1 ? names.get(1) : name;
  137 + String name3 = names.size() > 2 ? names.get(2) : name;
  138 + return new AccessorTransformer.Mapping(name, name2, name3);
  139 + }
  140 +
  141 + throw new RuntimeException("Invalid obfuscation table entry specified: '" + names + "'");
133 } 142 }
134 143
135 /** 144 /**
@@ -175,7 +184,7 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -175,7 +184,7 @@ public abstract class AccessorTransformer extends ClassTransformer
175 throw new RuntimeException("Accessor interfaces must be annotated with an @Accessor annotation specifying the target class"); 184 throw new RuntimeException("Accessor interfaces must be annotated with an @Accessor annotation specifying the target class");
176 } 185 }
177 186
178 - String targetClass = ByteCodeUtilities.<String>getAnnotationValue(annotation); 187 + List<String> targetClass = ByteCodeUtilities.<List<String>>getAnnotationValue(annotation);
179 if (targetClass == null || targetClass.isEmpty()) 188 if (targetClass == null || targetClass.isEmpty())
180 { 189 {
181 throw new RuntimeException("Invalid @Accessor annotation, the annotation must specify a target class"); 190 throw new RuntimeException("Invalid @Accessor annotation, the annotation must specify a target class");
@@ -233,18 +242,18 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -233,18 +242,18 @@ public abstract class AccessorTransformer extends ClassTransformer
233 242
234 LiteLoaderLogger.debug("[AccessorTransformer] Attempting to add %s to %s", method.name, classNode.name); 243 LiteLoaderLogger.debug("[AccessorTransformer] Attempting to add %s to %s", method.name, classNode.name);
235 244
236 - String targetId = null; 245 + List<String> targetId = null;
237 AnnotationNode accessor = ByteCodeUtilities.getInvisibleAnnotation(method, Accessor.class); 246 AnnotationNode accessor = ByteCodeUtilities.getInvisibleAnnotation(method, Accessor.class);
238 AnnotationNode invoker = ByteCodeUtilities.getInvisibleAnnotation(method, Invoker.class); 247 AnnotationNode invoker = ByteCodeUtilities.getInvisibleAnnotation(method, Invoker.class);
239 if (accessor != null) 248 if (accessor != null)
240 { 249 {
241 - targetId = ByteCodeUtilities.<String>getAnnotationValue(accessor); 250 + targetId = ByteCodeUtilities.<List<String>>getAnnotationValue(accessor);
242 Obf target = this.getObf(targetId); 251 Obf target = this.getObf(targetId);
243 if (this.injectAccessor(classNode, method, target)) return; 252 if (this.injectAccessor(classNode, method, target)) return;
244 } 253 }
245 else if (invoker != null) 254 else if (invoker != null)
246 { 255 {
247 - targetId = ByteCodeUtilities.<String>getAnnotationValue(invoker); 256 + targetId = ByteCodeUtilities.<List<String>>getAnnotationValue(invoker);
248 Obf target = this.getObf(targetId); 257 Obf target = this.getObf(targetId);
249 if (this.injectInvoker(classNode, method, target)) return; 258 if (this.injectInvoker(classNode, method, target)) return;
250 } 259 }
@@ -448,6 +457,14 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -448,6 +457,14 @@ public abstract class AccessorTransformer extends ClassTransformer
448 } 457 }
449 } 458 }
450 459
  460 + protected static class Mapping extends Obf
  461 + {
  462 + protected Mapping(String seargeName, String obfName, String mcpName)
  463 + {
  464 + super(seargeName, obfName, mcpName);
  465 + }
  466 + }
  467 +
451 /** 468 /**
452 * List of accessors to inject 469 * List of accessors to inject
453 */ 470 */
@@ -514,7 +531,6 @@ public abstract class AccessorTransformer extends ClassTransformer @@ -514,7 +531,6 @@ public abstract class AccessorTransformer extends ClassTransformer
514 * @param transformedName 531 * @param transformedName
515 * @param basicClass 532 * @param basicClass
516 * @param classNode 533 * @param classNode
517 - * @return  
518 */ 534 */
519 public ClassNode apply(String name, String transformedName, byte[] basicClass, ClassNode classNode) 535 public ClassNode apply(String name, String transformedName, byte[] basicClass, ClassNode classNode)
520 { 536 {
java/common/com/mumfrey/liteloader/transformers/access/Invoker.java
@@ -14,5 +14,5 @@ import java.lang.annotation.Target; @@ -14,5 +14,5 @@ import java.lang.annotation.Target;
14 @Retention(RetentionPolicy.CLASS) 14 @Retention(RetentionPolicy.CLASS)
15 public @interface Invoker 15 public @interface Invoker
16 { 16 {
17 - public String value(); 17 + public String[] value();
18 } 18 }