Created
February 22, 2015 22:18
-
-
Save clienthax/499859fa3667f97cda30 to your computer and use it in GitHub Desktop.
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
import net.minecraft.client.renderer.GlStateManager; | |
import org.apache.commons.io.FileUtils; | |
import org.apache.commons.io.filefilter.TrueFileFilter; | |
import org.lwjgl.opengl.GL11; | |
import java.io.File; | |
import java.util.Collection; | |
/** | |
* Created by clienthax on 22/2/2015. | |
*/ | |
public class GLReplace { | |
public static void main(String[] args) throws Exception { | |
new GLReplace(); | |
} | |
public GLReplace() throws Exception { | |
String baseFolderLocation = "C:\\mcprojects\\Pixelmon\\main\\java\\com"; | |
Collection<File> files = FileUtils.listFilesAndDirs(new File(baseFolderLocation), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); | |
for(File file : files) { | |
if(!file.getName().endsWith(".java")) | |
continue; | |
System.out.println(file.getName()); | |
String contents = FileUtils.readFileToString(file); | |
contents = contents.replace("GL11.glPushMatrix", "GlStateManager.pushMatrix"); | |
contents = contents.replace("GL11.glPopMatrix", "GlStateManager.popMatrix"); | |
//ignore glNormal as no substitute | |
//color | |
contents = contents.replace("GL11.glColor3f", "GlStateManager.color"); | |
contents = contents.replace("GL11.glColor4f", "GlStateManager.color"); | |
contents = contents.replace("GL11.glClearColor", "GlStateManager.clearColor"); | |
contents = contents.replace("GL11.glColorMaterial", "GlStateManager.colorMaterial"); | |
//rescale normal | |
contents = contents.replace("GL11.glEnable(GL12.GL_RESCALE_NORMAL)", "GlStateManager.enableRescaleNormal()"); | |
contents = contents.replace("GL11.glDisable(GL12.GL_RESCALE_NORMAL)", "GlStateManager.disableRescaleNormal()"); | |
//tex2d | |
contents = contents.replace("GL11.glDisable(3553", "GlStateManager.disableTexture2D("); | |
contents = contents.replace("GL11.glEnable(3553", "GlStateManager.enableTexture2D("); | |
contents = contents.replace("GL11.glDisable(GL11.GL_TEXTURE_2D)", "GlStateManager.disableTexture2D()"); | |
contents = contents.replace("GL11.glEnable(GL11.GL_TEXTURE_2D)", "GlStateManager.enableTexture2D()"); | |
//bindTexture | |
contents = contents.replace("GL11.glBindTexture(", "GlStateManager.bindTexture("); | |
//colormat | |
contents = contents.replace("GL11.glEnable(GL11.GL_COLOR_MATERIAL)", "GlStateManager.enableColorMaterial()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_COLOR_MATERIAL)", "GlStateManager.disableColorMaterial()"); | |
//depth | |
contents = contents.replace("GL11.glEnable(GL11.GL_DEPTH_TEST)", "GlStateManager.enableDepth()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_DEPTH_TEST)", "GlStateManager.disableDepth()"); | |
contents = contents.replace("GL11.glDepthMask", "GlStateManager.depthMask"); | |
//lighting | |
contents = contents.replace("GL11.glEnable(GL11.GL_LIGHTING)", "GlStateManager.enableLighting()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_LIGHTING)", "GlStateManager.disableLighting()"); | |
contents = contents.replace("GL11.glEnable(2896", "GlStateManager.enableLighting("); | |
contents = contents.replace("GL11.glDisable(2896", "GlStateManager.disableLighting("); | |
//cullFace | |
contents = contents.replace("GL11.glEnable(GL11.GL_CULL_FACE)", "GlStateManager.enableCull()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_CULL_FACE)", "GlStateManager.disableCull()"); | |
//blend | |
contents = contents.replace("GL11.glEnable(GL11.GL_BLEND)", "GlStateManager.enableBlend()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_BLEND)", "GlStateManager.disableBlend()"); | |
contents = contents.replace("GL11.glEnable(3042", "GlStateManager.enableBlend("); | |
contents = contents.replace("GL11.glDisable(3042", "GlStateManager.disableBlend("); | |
contents = contents.replace("GL11.glBlendFunc", "GlStateManager.blendFunc"); | |
//alpha | |
contents = contents.replace("GL11.glEnable(GL11.GL_ALPHA_TEST)", "GlStateManager.enableAlpha()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_ALPHA_TEST)", "GlStateManager.disableAlpha()"); | |
contents = contents.replace("GL11.glAlphaFunc", "GlStateManager.alphaFunc"); | |
contents = contents.replace("GL11.glAlphaFunc", "GlStateManager.alphaFunc"); | |
//translate | |
contents = contents.replace("GL11.glTranslatef", "GlStateManager.translate"); | |
contents = contents.replace("GL11.glTranslatef", "GlStateManager.translate"); | |
contents = contents.replace("GL11.glTranslated", "GlStateManager.translate"); | |
contents = contents.replace("GL11.glTranslated", "GlStateManager.translate"); | |
//scale | |
contents = contents.replace("GL11.glScaled", "GlStateManager.scale"); | |
contents = contents.replace("GL11.glScaled", "GlStateManager.scale"); | |
contents = contents.replace("GL11.glScalef", "GlStateManager.scale"); | |
contents = contents.replace("GL11.glScalef", "GlStateManager.scale"); | |
//rotate | |
contents = contents.replace("GL11.glRotated", "GlStateManager.rotate"); | |
contents = contents.replace("GL11.glRotated", "GlStateManager.rotate"); | |
contents = contents.replace("GL11.glRotatef", "GlStateManager.rotate"); | |
contents = contents.replace("GL11.glRotatef", "GlStateManager.rotate"); | |
//fog | |
contents = contents.replace("GL11.glEnable(GL11.GL_FOG)", "GlStateManager.enableFog()"); | |
contents = contents.replace("GL11.glDisable(GL11.GL_FOG)", "GlStateManager.disableFog()"); | |
//shade | |
contents = contents.replace("GL11.glShadeModel(", "GlStateManager.shadeModel("); | |
//Lists | |
contents = contents.replace("GL11.glCallList(", "GlStateManager.callList("); | |
contents = contents.replace("GL11.glGenLists(", "GLAllocation.generateDisplayLists("); | |
GlStateManager.enableNormalize(); | |
contents = contents.replace("GLStateManager", "GlStateManager");//opps.. | |
contents = contents.replace("", ""); | |
contents = contents.replace("", ""); | |
GL11 gl11; | |
FileUtils.writeStringToFile(file, contents); | |
} | |
System.out.println("Replacement complete"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment