Skip to content

Commit

Permalink
Do it right damn it! (Proper clientside checking)
Browse files Browse the repository at this point in the history
Thanks RandomLabs for actually providing something that won't cause incompatibilities (Still don't know how it managed that the first time)
  • Loading branch information
ZombieHDGaming committed Oct 10, 2018
1 parent b1ea665 commit 882c029
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/org/dimdev/jeid/JEIDTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
Expand Down Expand Up @@ -125,14 +125,11 @@ private byte[] transformItemStack(byte[] basicClass) {
String descr = "(L"+Obf.EntityPlayer+";L"+Obf.ITooltipFlag+";)Ljava/util/List;";
String getIntegerName = Obf.isDeobf()?"getInteger":"func_74762_e";

try {
Class.forName("net.minecraft.client.Minecraft", false, this.getClass().getClassLoader());
if (FMLLaunchHandler.side().isClient()) {
MethodNode mn2 = locateMethod(cn, descr, "func_82840_a", "getTooltip", "a");
AbstractInsnNode target = locateTargetInsn(mn2, n -> n.getOpcode() == Opcodes.INVOKEVIRTUAL && n.getPrevious().getOpcode() == Opcodes.LDC && ((LdcInsnNode) n.getPrevious()).cst.toString().equals("id"));
mn.instructions.insertBefore(target, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Obf.NBTTagCompound, getIntegerName, "(Ljava/lang/String;)I", false));
mn.instructions.remove(target);
} catch(ClassNotFoundException e) {

}

ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
Expand Down

0 comments on commit 882c029

Please sign in to comment.