Skip to content

Commit

Permalink
1.2: beta fix, beta skins
Browse files Browse the repository at this point in the history
  • Loading branch information
xa committed Feb 24, 2018
1 parent 20b17f9 commit 0bbf811
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/home/kcx/.minecraft/libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar"/>
<classpathentry kind="lib" path="/home/kcx/.minecraft/libraries/org/ow2/asm/asm-all/5.2/asm-all-5.2.jar" sourcepath="/tmp/.org.sf.feeling.decompiler1519465997831/source/asm-all-5.2-sources.jar"/>
<classpathentry kind="lib" path="/home/kcx/.minecraft/libraries/org/ow2/asm/asm-all/5.2/asm-all-5.2.jar" sourcepath="/tmp/.org.sf.feeling.decompiler1519471787613/source/asm-all-5.2-sources-1519478971386.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ Enables you to play _fixed_ old versions of minecraft without ever touching .jar

**HOW TO USE (automatic)**

Download retrowrapper-installer.jar from releases and launch it.
Download latest version from releases and launch it.

Select version you want to wrap and click 'Ok'
Select version you want to wrap and click 'Install'

**HOW TO USE (manual)**

Download retrowrapper-1.1.jar from releases.
Download retrowrapper-1.2.jar from releases.

Navigate to .minecraft/libraries/com/

Create new folder 'zero' and navigate to it

Create new folder 'retrowrapper' inside 'zero' and navigate to it

Create new folder '1.1' inside 'retrowrapper' and navigate to it
Create new folder '1.2' inside 'retrowrapper' and navigate to it

Copy retrowrapper-1.1.jar to '1.1'
Copy retrowrapper-1.2.jar to '1.2'

Now go into .minecraft/versions/

Expand All @@ -38,7 +38,7 @@ Go inside that folder and add -retro to all filenames inside it
Edit <version>.json and

- add -retro to id (eg. replace **"id": "c0.30_01c",* with *"id": "c0.30_01c-retro",**)
- replace **"libraries":** with **"libraries": [{"name": "net.minecraft:launchwrapper:1.6"},**
- replace **"libraries":** with **"libraries": [{"name": "com.zero:retrowrapper:1.2"},**
- replace **--tweakClass net.minecraft.launchwrapper....VanillaTweaker** with **--tweakClass com.zero.retrowrapper.RetroTweaker**

Launch Minecraft and choose newly created version!
Expand Down
14 changes: 12 additions & 2 deletions src/com/zero/retrowrapper/emulator/SocketEmulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,18 @@ else if(line.length() < 2)

if(handler != null)
{
handler.sendHeaders(os);
handler.handle(os, get, data);
try
{
System.out.println("Request: "+get);
handler.sendHeaders(os);
handler.handle(os, get, data);
}catch(Exception e)
{
System.out.println("***************************************");
System.out.println(" Exception in handling URL: "+get);
System.out.println("***************************************");
e.printStackTrace();
}
}else
{
System.out.println("***************************************");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.zero.retrowrapper.emulator.registry.handlers.ListmapsHandler;
import com.zero.retrowrapper.emulator.registry.handlers.LoadHandler;
import com.zero.retrowrapper.emulator.registry.handlers.ResourcesHandler;
import com.zero.retrowrapper.emulator.registry.handlers.ResourcesHandlerBeta;
import com.zero.retrowrapper.emulator.registry.handlers.SaveHandler;
import com.zero.retrowrapper.emulator.registry.handlers.SkinHandler;

Expand All @@ -33,11 +34,13 @@ public IHandler getHandlerByUrl(String url)

public void registerAll()
{
register(new SkinHandler());
register(new GameHandler());
register(new SaveHandler());
register(new LoadHandler());
register(new ListmapsHandler());
register(new ResourcesHandler());
register(new ResourcesHandlerBeta());
register(new SkinHandler("/skin/"));
register(new SkinHandler("/MinecraftSkins/"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.zero.retrowrapper.emulator.registry.handlers;


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

import com.zero.retrowrapper.emulator.ByteUtils;
import com.zero.retrowrapper.emulator.registry.EmulatorHandler;
import com.zero.retrowrapper.emulator.registry.IHandler;

public class ResourcesHandlerBeta extends EmulatorHandler implements IHandler
{
public ResourcesHandlerBeta()
{
super("/MinecraftResources/");
}

@Override
public void handle(OutputStream os, String get, byte[] data) throws IOException
{
URL resourceURL = new URL("http://s3.amazonaws.com"+get);
InputStream is = resourceURL.openStream();
os.write(ByteUtils.readFully(is));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class SkinHandler extends EmulatorHandler implements IHandler
{
private HashMap<String, byte[]> skinsCache = new HashMap<>();

public SkinHandler()
public SkinHandler(String url)
{
super("/skin/");
super(url);
}

@Override
public void handle(OutputStream os, String get, byte[] data) throws IOException
{
String username = get.replace("/skin/", "").replace(".png", "");
String username = get.replace(url, "").replace(".png", "");

if(skinsCache.containsKey(username))
{
Expand Down
42 changes: 26 additions & 16 deletions src/com/zero/retrowrapper/injector/RetroTweakInjectorTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import java.applet.Applet;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -54,10 +52,13 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth
{
Class<?> clazz;

boolean veryOld = false;

try
{
clazz = getaClass("net.minecraft.client.MinecraftApplet");
} catch (ClassNotFoundException ignored) {
veryOld = true;
clazz = getaClass("com.mojang.minecraft.MinecraftApplet");
}

Expand All @@ -77,7 +78,11 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth
object.setStub(fakeLauncher);

object.setSize(854, 480);
object.getClass().getMethod("init").invoke(object);

if(veryOld)
{
object.getClass().getMethod("init").invoke(object);
}

for (Field field : clazz.getDeclaredFields())
{
Expand All @@ -88,24 +93,29 @@ public static void main(String[] args) throws ClassNotFoundException, NoSuchMeth
System.out.println("Found likely Minecraft candidate: " + field);

Field fileField = getWorkingDirField(name);
field.setAccessible(true);
Object mcObj = field.get(object);
System.out.println(mcObj);
Field appletField = null;
for(Field f: mcObj.getClass().getDeclaredFields())

if(veryOld)
{
if(f.getType().getName().equals("boolean") && Modifier.isPublic(f.getModifiers()))
field.setAccessible(true);
Object mcObj = field.get(object);
System.out.println(mcObj);
Field appletField = null;
for(Field f: mcObj.getClass().getDeclaredFields())
{
appletField = f;
break;
if(f.getType().getName().equals("boolean") && Modifier.isPublic(f.getModifiers()))
{
appletField = f;
break;
}
}

if(appletField != null)
{
System.out.println("Applet mode: "+appletField.get(mcObj));
appletField.set(mcObj, false);
}
}

if(appletField != null)
{
System.out.println("Applet mode: "+appletField.get(mcObj));
appletField.set(mcObj, false);
}
if (fileField != null)
{
System.out.println("Found File, changing to " + Launch.minecraftHome);
Expand Down
Loading

0 comments on commit 0bbf811

Please sign in to comment.