parent
865b4d7a7b
commit
f40ffd99c5
|
@ -4,5 +4,8 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="lib" path="lib/gson-2.2.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/guava-14.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-io-2.4.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -6,6 +6,8 @@ import amidst.Options;
|
|||
import amidst.map.Map;
|
||||
import amidst.map.MapObject;
|
||||
import amidst.map.layers.BiomeLayer;
|
||||
import amidst.map.layers.GridLayer;
|
||||
import amidst.map.layers.SlimeLayer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
@ -57,7 +59,7 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
panSpeed = new Point2D.Double();
|
||||
this.proj = proj;
|
||||
|
||||
testMap = new Map(proj.manager, new BiomeLayer()); //TODO: implement more layers
|
||||
testMap = new Map(proj.manager, new BiomeLayer(), new SlimeLayer(), new GridLayer()); //TODO: implement more layers
|
||||
|
||||
addMouseListener(this);
|
||||
addMouseWheelListener(this);
|
||||
|
|
|
@ -17,7 +17,6 @@ public class Project extends JPanel {
|
|||
private static final long serialVersionUID = 1132526465987018165L;
|
||||
|
||||
public MapViewer map;
|
||||
private MapInfoPanel minfo;
|
||||
public static int FRAGMENT_SIZE = 256;
|
||||
public ChunkManager manager;
|
||||
private Timer timer;
|
||||
|
@ -66,11 +65,7 @@ public class Project extends JPanel {
|
|||
|
||||
//Create MapViewer
|
||||
map = new MapViewer(this);
|
||||
|
||||
add(map, BorderLayout.CENTER);
|
||||
minfo = new MapInfoPanel(map);
|
||||
add(minfo, BorderLayout.EAST);
|
||||
|
||||
//Debug
|
||||
this.setBackground(Color.BLUE);
|
||||
|
||||
|
@ -86,7 +81,6 @@ public class Project extends JPanel {
|
|||
|
||||
public void tick() {
|
||||
map.repaint();
|
||||
minfo.repaint();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
@ -97,8 +91,6 @@ public class Project extends JPanel {
|
|||
timer.cancel();
|
||||
timer = null;
|
||||
curTarget = null;
|
||||
minfo.dispose();
|
||||
minfo = null;
|
||||
save = null;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package MoF;
|
||||
|
||||
import amidst.Amidst;
|
||||
import amidst.Log;
|
||||
import amidst.Options;
|
||||
import amidst.foreign.VersionInfo;
|
||||
|
@ -7,6 +8,7 @@ import amidst.foreign.VersionInfo;
|
|||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -25,9 +27,9 @@ public enum ReflectionInfo {
|
|||
File s = null;
|
||||
|
||||
try {
|
||||
ClasspathHacker.addFile(Options.instance.jar.get());
|
||||
ClasspathHacker.addFile(Options.instance.getJar());
|
||||
mc = ClassLoader.getSystemClassLoader().loadClass("net.minecraft.client.Minecraft");
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
fc.addChoosableFileFilter(new FileFilter() {
|
||||
public boolean accept(File f) {
|
||||
|
@ -56,6 +58,12 @@ public enum ReflectionInfo {
|
|||
} else {
|
||||
System.exit(0);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
mc = ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.MinecraftServer");
|
||||
} catch (ClassNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -74,7 +82,15 @@ public enum ReflectionInfo {
|
|||
boolean is25 = false;
|
||||
boolean atLeast131 = false;
|
||||
boolean atLeast152 = false;
|
||||
if (typeDump.equals("[Bbdzbdrbawemabdsbfybdvngngbeuawfbgeawvawvaxrawbbfqausbjgaycawwaraavybkcavwbjubkila")) {
|
||||
if (typeDump.equals("mulu[Ljr;hm[J[J[J[J[J[[J")) {
|
||||
worldName = "abv";
|
||||
atLeast131 = true;
|
||||
atLeast152 = true;
|
||||
} else if (typeDump.equals("msls[Ljp;hk[J[J[J[J[J[[J")) {
|
||||
worldName = "abr";
|
||||
atLeast131 = true;
|
||||
atLeast152 = true;
|
||||
} else if (typeDump.equals("[Bbdzbdrbawemabdsbfybdvngngbeuawfbgeawvawvaxrawbbfqausbjgaycawwaraavybkcavwbjubkila")) {
|
||||
worldName = "aab";
|
||||
atLeast131 = true;
|
||||
atLeast152 = true;
|
||||
|
|
|
@ -35,6 +35,14 @@ public enum Options {
|
|||
showIcons = new BooleanPrefModel(pref, "icons", true);
|
||||
}
|
||||
|
||||
public File getJar() {
|
||||
if (Amidst.installInformation.isPre161)
|
||||
return jar.get();
|
||||
else
|
||||
return Amidst.installInformation.getJarFile();
|
||||
|
||||
}
|
||||
|
||||
public String getSeedMessage() {
|
||||
if (seedText == null)
|
||||
return "Seed: " + seed;
|
||||
|
|
|
@ -75,7 +75,6 @@ public class Util {
|
|||
public static File getTempDir(String name) {
|
||||
File baseDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
String baseName = name + "-";
|
||||
|
||||
for (int counter=0; counter<TEMP_DIR_ATTEMPTS; counter++) {
|
||||
File tempDir = new File(baseDir, baseName + counter);
|
||||
if (tempDir.isDirectory() || tempDir.mkdir())
|
||||
|
|
|
@ -8,7 +8,8 @@ import java.util.List;
|
|||
/** Information about what each supported version is
|
||||
*/
|
||||
public enum VersionInfo {
|
||||
V1_6_1("aab", "air"),
|
||||
V1_6_2("akn", "akl"),
|
||||
V1_6_1("akj", "akh"),
|
||||
V1_5_1("ait", "air"),
|
||||
V1_5_0("ain", "ail"),
|
||||
V1_4_6("agw", "agu"),
|
||||
|
|
|
@ -40,7 +40,6 @@ public class VersionSelectWindow extends JFrame {
|
|||
Object[] profileArray = null;
|
||||
try {
|
||||
LauncherProfile profile = readObject(profileJsonFile, LauncherProfile.class);
|
||||
System.out.println(profile.profiles.get("New Profile5").name);
|
||||
profile.profiles.put("(Default)", new InstallInformation());
|
||||
|
||||
profileArray = profile.profiles.values().toArray();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package amidst.json;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import amidst.Util;
|
||||
|
||||
public class InstallInformation {
|
||||
|
@ -20,7 +22,7 @@ public class InstallInformation {
|
|||
public InstallInformation(boolean isOld) {
|
||||
if (!isOld) {
|
||||
name = "(Default)";
|
||||
lastVersionId = "1.6.1";
|
||||
lastVersionId = "1.6.2";
|
||||
} else {
|
||||
name = "Minecraft";
|
||||
lastVersionId = "None";
|
||||
|
@ -32,4 +34,8 @@ public class InstallInformation {
|
|||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getJarFile() {
|
||||
return new File(gameDir + "/versions/" + lastVersionId + "/" + lastVersionId + ".jar");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,15 @@ import java.util.Vector;
|
|||
import amidst.Log;
|
||||
|
||||
public class Fragment {
|
||||
public static final int SIZE = 256, SIZE_SHIFT = 8;
|
||||
public static final int SIZE = 256, SIZE_SHIFT = 8, MAX_OBJECTS_PER_FRAGMENT = 20;
|
||||
|
||||
public int blockX, blockY;
|
||||
|
||||
private Layer[] layers;
|
||||
|
||||
private BufferedImage[] imgBuffers;
|
||||
private MapObject[] objects;
|
||||
private int objectsLength = 0;
|
||||
|
||||
public boolean isActive = false;
|
||||
public boolean isLoaded = false;
|
||||
|
@ -32,8 +34,10 @@ public class Fragment {
|
|||
this.layers = layers;
|
||||
imgBuffers = new BufferedImage[layers.length];
|
||||
for (int i = 0; i < layers.length; i++) {
|
||||
imgBuffers[i] = new BufferedImage(layers[i].size, layers[i].size, BufferedImage.TYPE_INT_ARGB);
|
||||
if (!layers[i].isLive())
|
||||
imgBuffers[i] = new BufferedImage(layers[i].size, layers[i].size, BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
objects = new MapObject[MAX_OBJECTS_PER_FRAGMENT];
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
@ -57,22 +61,26 @@ public class Fragment {
|
|||
}
|
||||
|
||||
public void clear() {
|
||||
objectsLength = 0;
|
||||
//isLoaded = false;
|
||||
hasNext = false;
|
||||
endOfLine = false;
|
||||
isActive = true;
|
||||
for (int i = 0; i < imgBuffers.length; i++) {
|
||||
imgBuffers[i].setRGB(0, 0, layers[i].size, layers[i].size, layers[i].getDefaultData(), 0, layers[i].size);
|
||||
if (!layers[i].isLive())
|
||||
imgBuffers[i].setRGB(0, 0, layers[i].size, layers[i].size, layers[i].getDefaultData(), 0, layers[i].size);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g, AffineTransform mat) {
|
||||
for (int i = 0; i < imgBuffers.length; i++) {
|
||||
if (layers[i].isLive()) {
|
||||
layers[i].drawLive(this, g, layers[i].getMatrix(mat));
|
||||
} else {
|
||||
g.setTransform(layers[i].getScaledMatrix(mat));
|
||||
g.drawImage(imgBuffers[i], 0, 0, null);
|
||||
if (layers[i].isVisible()) {
|
||||
if (layers[i].isLive()) {
|
||||
layers[i].drawLive(this, g, layers[i].getMatrix(mat));
|
||||
} else {
|
||||
g.setTransform(layers[i].getScaledMatrix(mat));
|
||||
g.drawImage(imgBuffers[i], 0, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.imageio.ImageIO;
|
|||
|
||||
import MoF.ChunkManager;
|
||||
import amidst.Log;
|
||||
import amidst.preferences.BooleanPrefModel;
|
||||
|
||||
public class Layer implements Comparable<Layer> {
|
||||
public String name;
|
||||
|
@ -28,9 +29,12 @@ public class Layer implements Comparable<Layer> {
|
|||
public CacheManager cacheManager;
|
||||
public String cachePath;
|
||||
|
||||
protected Map map;
|
||||
private boolean live;
|
||||
protected ChunkManager chunkManager;
|
||||
|
||||
private BooleanPrefModel visible = null;
|
||||
|
||||
public Layer(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
@ -51,6 +55,15 @@ public class Layer implements Comparable<Layer> {
|
|||
for (int i = 0; i < defaultData.length; i++)
|
||||
defaultData[i] = 0x00000000;
|
||||
}
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
public boolean isVisible() {
|
||||
return (visible == null) || visible.get();
|
||||
}
|
||||
public void setVisibilityPref(BooleanPrefModel visibility) {
|
||||
visible = visibility;
|
||||
}
|
||||
|
||||
public void unload(Fragment frag) {
|
||||
if (cacheEnabled) {
|
||||
|
|
|
@ -28,8 +28,10 @@ public class Map {
|
|||
|
||||
// TODO : This must be changed with the removal of ChunkManager
|
||||
public Map(ChunkManager manager, Layer... layers) {
|
||||
for (Layer layer : layers)
|
||||
for (Layer layer : layers) {
|
||||
layer.setChunkManager(manager);
|
||||
layer.setMap(this);
|
||||
}
|
||||
|
||||
fManager = new FragmentManager(layers);
|
||||
mat = new AffineTransform();
|
||||
|
|
|
@ -63,9 +63,5 @@ public class BiomeLayer extends Layer {
|
|||
|
||||
}
|
||||
|
||||
public void drawLive(Fragment fragment, Graphics2D g, AffineTransform mat) {
|
||||
g.setColor(Color.black);
|
||||
g.setTransform(mat);
|
||||
g.fillRect(2, 2, 20, 20);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package amidst.map.layers;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import amidst.Options;
|
||||
import amidst.map.Fragment;
|
||||
import amidst.map.Layer;
|
||||
|
||||
|
||||
public class GridLayer extends Layer {
|
||||
private static Font drawFont = new Font("arial", Font.BOLD, 16);
|
||||
public GridLayer() {
|
||||
super("grid", null, 1.1f);
|
||||
setLive(true);
|
||||
setVisibilityPref(Options.instance.showGrid);
|
||||
}
|
||||
|
||||
public void drawLive(Fragment fragment, Graphics2D g, AffineTransform mat) {
|
||||
g.setColor(Color.black);
|
||||
g.setTransform(mat);
|
||||
g.drawRect(0, 0, size, size);
|
||||
double invZoom = 1.0 / map.getZoom();
|
||||
mat.scale(invZoom, invZoom);
|
||||
g.setTransform(mat);
|
||||
g.setFont(drawFont);
|
||||
g.drawString((fragment.getChunkX() << 4) + ", " +(fragment.getChunkY() << 4), 10, 20);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package amidst.map.layers;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.util.Random;
|
||||
|
||||
import amidst.Options;
|
||||
import amidst.Util;
|
||||
import amidst.map.Fragment;
|
||||
import amidst.map.Layer;
|
||||
|
||||
public class SlimeLayer extends Layer {
|
||||
private static int size = Fragment.SIZE >> 4;
|
||||
private Random random = new Random();
|
||||
public SlimeLayer() {
|
||||
super("slime", null, 0.0f, size);
|
||||
setLive(false);
|
||||
setVisibilityPref(Options.instance.showSlimeChunks);
|
||||
}
|
||||
|
||||
public void drawCached(Fragment fragment, int layerID) {
|
||||
int[] dataCache = Fragment.getIntArray();
|
||||
for (int y = 0; y < size; y++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
int xPosition = fragment.getChunkX() + x;
|
||||
int yPosition = fragment.getChunkY() + y;
|
||||
random.setSeed(
|
||||
this.chunkManager.seed +
|
||||
(xPosition * xPosition * 0x4c1906) +
|
||||
(xPosition * 0x5ac0db) +
|
||||
(yPosition * yPosition) * 0x4307a7 +
|
||||
(yPosition * 0x5f24f) ^ 0x3ad8025f
|
||||
);
|
||||
dataCache[y * size + x] = (random.nextInt(10) == 0) ? 0xA0FF00FF : 0x00000000;
|
||||
}
|
||||
}
|
||||
|
||||
fragment.setImageData(layerID, dataCache);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue