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

Update the 1.7.10 repo: Fix for the latest Optifine version and Workspace update #1294

Open
wants to merge 3 commits into
base: 1.7.10
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
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ def modid = getModIdFromJava()
version = getVersionFromJava() + project.buildnumber
group = 'net.angrypixel'
archivesBaseName = 'TheBetweenlands'
sourceCompatibility = targetCompatibility = '1.7'
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
version = '1.7.10-10.13.4.1558-1.7.10'
version = '1.7.10-10.13.4.1614-1.7.10'
runDir = 'minecraft'
replace '${version}', project.version
replace '/*!*/true/*!*/', 'false'
Expand Down Expand Up @@ -69,6 +72,12 @@ repositories {
}
}

idea {
module {
inheritOutputDirs = true
}
}

//Builds the universal jar
jar {
classifier = 'universal'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Oct 31 01:55:10 CET 2015
#Wed Jul 02 15:54:47 CDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
10 changes: 7 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ case "`uname`" in
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
Expand All @@ -56,9 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down Expand Up @@ -109,7 +114,6 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down
84 changes: 52 additions & 32 deletions java/thebetweenlands/core/TheBetweenlandsClassTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@
import static org.objectweb.asm.tree.AbstractInsnNode.METHOD_INSN;

import java.util.Iterator;
import java.util.List;
import java.util.logging.LogManager;

import cpw.mods.fml.common.FMLLog;
import org.apache.logging.log4j.Level;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.*;

import net.minecraft.launchwrapper.IClassTransformer;

Expand All @@ -70,29 +62,29 @@ public TheBetweenlandsClassTransformer() {
public byte[] transform(String name, String transformedName, byte[] classBytes) {
boolean obf;
if ("net.minecraft.server.MinecraftServer".equals(name)) {
return writeClass(transformMinecraftServer(readClass(classBytes)));
return writeClass(transformMinecraftServer(readClass(classBytes)), false);
} else if ((obf = "yz".equals(name)) || "net.minecraft.entity.player.EntityPlayer".equals(name)) {
return writeClass(transformEntityPlayer(readClass(classBytes), obf));
return writeClass(transformEntityPlayer(readClass(classBytes), obf), false);
} else if ((obf = "sv".equals(name)) || "net.minecraft.entity.EntityLivingBase".equals(name)) {
return writeClass(transformEntityLivingBase(readClass(classBytes), obf));
return writeClass(transformEntityLivingBase(readClass(classBytes), obf), false);
} else if ((obf = "bao".equals(name)) || "net.minecraft.client.Minecraft".equals(name)) {
return writeClass(transformMinecraft(readClass(classBytes), obf));
return writeClass(transformMinecraft(readClass(classBytes), obf), false);
} else if ((obf = "bdw".equals(name)) || "net.minecraft.client.gui.GuiScreen".equals(name)) {
return writeClass(transformGuiScreen(readClass(classBytes), obf));
return writeClass(transformGuiScreen(readClass(classBytes), obf), false);
} else if ((obf = "oi".equals(name)) || "net.minecraft.server.management.ServerConfigurationManager".equals(name)) {
return writeClass(transformServerConfigurationManager(readClass(classBytes), obf));
return writeClass(transformServerConfigurationManager(readClass(classBytes), obf), false);
} else if ((obf = "baj".equals(name)) || "net.minecraft.client.renderer.ActiveRenderInfo".equals(name)) {
return writeClass(transformActiveRenderInfo(readClass(classBytes), obf));
return writeClass(transformActiveRenderInfo(readClass(classBytes), obf), false);
} else if ((obf = "blt".equals(name)) || "net.minecraft.client.renderer.EntityRenderer".equals(name)) {
return writeClass(transformEntityRenderer(readClass(classBytes), obf));
return writeClass(transformEntityRenderer(readClass(classBytes), obf), true);
} else if ((obf = "bnn".equals(name)) || "net.minecraft.client.renderer.entity.RenderManager".equals(name)) {
return writeClass(transformRenderManager(readClass(classBytes), obf));
return writeClass(transformRenderManager(readClass(classBytes), obf), false);
} else if ((obf = "sa".equals(name)) || "net.minecraft.entity.Entity".equals(name)) {
return writeClass(transformEntity(readClass(classBytes), obf));
return writeClass(transformEntity(readClass(classBytes), obf), false);
} else if ("net.minecraft.command.CommandWeather".equals(name) && /*!*/true/*!*/) {
classBytes['J'+'u'+'s'*'t'+' '+'f'+'o'+'r'+' '-'t'*'h'+'e'+' '+'l'+'o'+'l'+'z'+'.'] = 0x1D; // 0x19 0x05 0x03
} else if ((obf = "mn".equals(name)) || "net.minecraft.entity.EntityTracker".equals(name)) {
return writeClass(transformEntityTracker(readClass(classBytes), obf));
return writeClass(transformEntityTracker(readClass(classBytes), obf), false);
}
return classBytes;
}
Expand All @@ -104,8 +96,11 @@ private ClassNode readClass(byte[] classBytes) {
return classNode;
}

private byte[] writeClass(ClassNode classNode) {
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
private byte[] writeClass(ClassNode classNode, boolean shouldComputeFrames) {
ClassWriter classWriter;
if (shouldComputeFrames) classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
else classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);

classNode.accept(classWriter);
return classWriter.toByteArray();
}
Expand Down Expand Up @@ -359,6 +354,19 @@ private ClassNode transformActiveRenderInfo(ClassNode classNode, boolean obf) {
return classNode;
}

private int getLocalVarIndex(List<LocalVariableNode> list, String name, String name2) {
// Returns the index of a specific local variable name from the method. This is required for compatibility with any Optifine version.
// It uses a list which you can create in the specific method using method.localVariables, and two names since for some dumb reasons,
// The game can access varX fine with the latest Optifine but not the internal name, and the opposite otherwise.

for (int i = 0; i < list.size(); i += 1) {
LocalVariableNode object = list.get(i);
if (object.name.equals(name) || object.name.equals(name2)) return object.index;
}
return -1;

}

private ClassNode transformEntityRenderer(ClassNode classNode, boolean obf) {
String orientCamera = obf ? "h" : "orientCamera";
String activeRenderInfo = obf ? "baj" : "net/minecraft/client/renderer/ActiveRenderInfo";
Expand All @@ -379,7 +387,15 @@ private ClassNode transformEntityRenderer(ClassNode classNode, boolean obf) {
boolean needsRenderWorld = true;
boolean needsGetMouseOver = true;
boolean needsPostRenderHandEvent = true;


for (MethodNode method : classNode.methods) {
List localVarList = method.localVariables;
int var7index = getLocalVarIndex(localVarList,"var7", "d0");
int var14index = getLocalVarIndex(localVarList, "var14", "frustrum");



if (needsOrientCamera && orientCamera.equals(method.name) && "(F)V".equals(method.desc)) {
method.localVariables.clear();
InsnList insns = method.instructions;
Expand Down Expand Up @@ -407,11 +423,13 @@ private ClassNode transformEntityRenderer(ClassNode classNode, boolean obf) {
}
}
boolean replacedASTORE8 = false;

for (int i = 0; i < method.instructions.size(); i++) {
AbstractInsnNode insnNode = method.instructions.get(i);
if (needsPerspectiveStuff && insnNode.getOpcode() == INVOKESTATIC && activeRenderInfo.equals(((MethodInsnNode) insnNode).owner)) {
InsnList addCameraPosToViewerPos = new InsnList();
for (int n = 0, s = 7; n < objectXYZ.length; n++, s += 2) {

for (int n = 0, s = var7index; n < objectXYZ.length; n++, s += 2) { // Replace 9 with the index of var7
addCameraPosToViewerPos.add(new VarInsnNode(DLOAD, s));
addCameraPosToViewerPos.add(new FieldInsnNode(GETSTATIC, activeRenderInfo, objectXYZ[n], "F"));
addCameraPosToViewerPos.add(new InsnNode(F2D));
Expand All @@ -428,17 +446,18 @@ private ClassNode transformEntityRenderer(ClassNode classNode, boolean obf) {
if (needsFrustumStuff) {
if (replacedASTORE8) {
// replace all things trying to get the frustum from the
// stack frame to getting the frustum from the class
// field
if (insnNode.getOpcode() == ALOAD && ((VarInsnNode) insnNode).var == 14) {
// stack frame to getting the frustum from the class field.
if (insnNode.getOpcode() == ALOAD && ((VarInsnNode) insnNode).var == var14index) { // Replace 19 with the index of var14.
((VarInsnNode) insnNode).var = 0;
method.instructions.insert(insnNode, new FieldInsnNode(GETFIELD, entityRendererOwner, fieldNameAddition, frustumDesc));
}

} else {
// instead of storing the newly created frustum into
// slot 14 of the method stack frame, put in the added
// slot 17 of the method stack frame, put in the added
// class field for external access
if (insnNode.getOpcode() == ASTORE && ((VarInsnNode) insnNode).var == 14) {

if (insnNode.getOpcode() == ASTORE && ((VarInsnNode) insnNode).var == var14index) { // Replace 19 with the index of var14.
InsnList newInsn = new InsnList();
method.instructions.insertBefore(method.instructions.get(i - 3), new VarInsnNode(ALOAD, 0));
method.instructions.set(insnNode, new FieldInsnNode(PUTFIELD, entityRendererOwner, fieldNameAddition, frustumDesc));
Expand All @@ -447,6 +466,7 @@ private ClassNode transformEntityRenderer(ClassNode classNode, boolean obf) {
}
}
}

if (needsFrustumStuff) {
classNode.fields.add(new FieldNode(ACC_PUBLIC, fieldNameAddition, frustumDesc, null, null));
}
Expand Down
2 changes: 1 addition & 1 deletion java/thebetweenlands/lib/ModInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class ModInfo
{
public static final String ID = "thebetweenlands";
public static final String NAME = "The Betweenlands";
public static final String VERSION = "1.0.6-alpha";
public static final String VERSION = "1.0.7-alpha";
public static final String CHANNEL = ID;
public static final String CLIENTPROXY_LOCATION = "thebetweenlands.proxy.ClientProxy";
public static final String COMMONPROXY_LOCATION = "thebetweenlands.proxy.CommonProxy";
Expand Down