diff --git a/.classpath b/.classpath
index b9ad5b8a7..a91252366 100644
--- a/.classpath
+++ b/.classpath
@@ -1,14 +1,37 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index be5440803..3b90e44e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,7 @@
/logs
/nbproject
/build
+
+history.txt
+target/
+/dependency-reduced-pom.xml
\ No newline at end of file
diff --git a/.project b/.project
index 315a65dfa..c60d78bfd 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
- AMIDST
+ amidst
@@ -10,8 +10,14 @@
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+ org.eclipse.m2e.core.maven2Nature
org.eclipse.jdt.core.javanature
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..dc1b41496
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 8000cd6ca..13b3428ac 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..fb3f72c9f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+language: java
+jdk:
+- oraclejdk8
+addons:
+ apt:
+ packages:
+ - libc6:i386 # these two packages are needed by the launch4j maven plugin to work
+ - libstdc++6:i386
+before_install:
+- mvn clean # this actually installs a dependency
+before_deploy:
+- bash travis-ci/scripts/create-mac-icon.sh
+- bash travis-ci/scripts/create-windows-icon.sh
+- mvn package -DskipTests=true -f travis-ci/wrapper-for-mac/pom.xml
+- mvn package -DskipTests=true -f travis-ci/wrapper-for-windows/pom.xml
+- bash travis-ci/scripts/zip-and-move-wrapper-for-mac.sh
+- export filename=$(bash travis-ci/scripts/get-amidst-filename.sh)
+deploy:
+ provider: releases
+ api-key:
+ secure: QMXa1QpW+mlTLlxCbKOAWIRUi2cR+Y2vMQDlwiV8BoUyZchvTBR+stDYuEdxd2fK8/aSRUWEgfUhKMJ4cIZEOOwz/UA/1RQmzumbFLexwTwDXfkTfCcDQFLtzywVoep2P3s1lpheo4f1G3z2sZTCxO5yRnpd/sBtWnaq3j5uifYZB+mv84eH+EsrQL7f+0KjycOPrAdiJ8xh/2twUtGMhaStrnhcH+RCi6qm6D5Dv4mwYM4wRxG3H9i2NceGa6lHIE4bU+kKY9lc3V6EzmTnnShwEcrf+4/ZfCe4A9aU3jzFhKCHKpJ4PlqLEtMeQ08ijaMrF4LaBqwRZ5il5nqKkFdfKOtx7EHqjxrQ1dT7JUXU/3lTfEX/DLbhPa3z5Tl9LgCu9flCS+ltQoPvx7MR1leaQeHNoFCfzWJQ8ytW2CEhnOqx3nr4AIW8q5akJxQB7USfHV5F8kw2T6QmzuniQRZex+15j9SLedaDXZCvno6C0+j59sABpiF9lRVww8jW6BxqklxDcjEtkMxyHiBCG0EgGlKJvVSyGGzDsjb8FweC1KQKBHuG+5UYNE1rJesj6rwfIIrbInjJRTPndb4GpuzzbqbTGxwHd2zqzkQhnxSjCoKIzyhpBzfyCJaqTv/DfimSc95sXH1w1d6zfcO01MkopXYUSlHvr/Rjxh8vE8U=
+ file:
+ - "target/${filename}.jar"
+ - "target/${filename}.zip"
+ - "target/${filename}.exe"
+ skip_cleanup: true
+ on:
+ repo: stefandollase/amidst
+ tags: true
diff --git a/Default-sorted.json b/Default-sorted.json
deleted file mode 100644
index 835b4c208..000000000
--- a/Default-sorted.json
+++ /dev/null
@@ -1,81 +0,0 @@
-{ "name":"default-sorted", "colorMap":[
-[ "Beach M", { "r":255, "g":255, "b":125 } ],
-[ "Beach", { "r":250, "g":222, "b":85 } ],
-[ "Birch Forest Hills M", { "r":71, "g":135, "b":90 } ],
-[ "Birch Forest Hills", { "r":31, "g":95, "b":50 } ],
-[ "Birch Forest M", { "r":88, "g":156, "b":108 } ],
-[ "Birch Forest", { "r":48, "g":116, "b":68 } ],
-[ "Cold Beach M", { "r":255, "g":255, "b":232 } ],
-[ "Cold Beach", { "r":250, "g":240, "b":192 } ],
-[ "Cold Taiga Hills M", { "r":76, "g":103, "b":94 } ],
-[ "Cold Taiga Hills", { "r":36, "g":63, "b":54 } ],
-[ "Cold Taiga M", { "r":89, "g":125, "b":114 } ],
-[ "Cold Taiga", { "r":49, "g":85, "b":74 } ],
-[ "Deep Ocean M", { "r":40, "g":40, "b":88 } ],
-[ "Deep Ocean", { "r":0, "g":0, "b":48 } ],
-[ "Desert Hills M", { "r":250, "g":135, "b":58 } ],
-[ "Desert Hills", { "r":210, "g":95, "b":18 } ],
-[ "Desert M", { "r":255, "g":188, "b":64 } ],
-[ "Desert", { "r":250, "g":148, "b":24 } ],
-[ "Extreme Hills Edge M", { "r":154, "g":160, "b":194 } ],
-[ "Extreme Hills Edge", { "r":114, "g":120, "b":154 } ],
-[ "Extreme Hills M", { "r":136, "g":136, "b":136 } ],
-[ "Extreme Hills", { "r":96, "g":96, "b":96 } ],
-[ "Extreme Hills+ M", { "r":120, "g":152, "b":120 } ],
-[ "Extreme Hills+", { "r":80, "g":112, "b":80 } ],
-[ "Flower Forest", { "r":45, "g":142, "b":73 } ],
-[ "Forest Hills M", { "r":74, "g":125, "b":68 } ],
-[ "Forest Hills", { "r":34, "g":85, "b":28 } ],
-[ "Forest", { "r":5, "g":102, "b":33 } ],
-[ "Frozen Ocean M", { "r":184, "g":184, "b":200 } ],
-[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
-[ "Frozen River M", { "r":200, "g":200, "b":255 } ],
-[ "Frozen River", { "r":160, "g":160, "b":255 } ],
-[ "Hell M", { "r":255, "g":40, "b":40 } ],
-[ "Hell", { "r":255, "g":0, "b":0 } ],
-[ "Ice Mountains M", { "r":200, "g":200, "b":200 } ],
-[ "Ice Mountains", { "r":160, "g":160, "b":160 } ],
-[ "Ice Plains Spikes", { "r":180, "g":220, "b":220 } ],
-[ "Ice Plains", { "r":255, "g":255, "b":255 } ],
-[ "Jungle Edge M", { "r":138, "g":179, "b":63 } ],
-[ "Jungle Edge", { "r":98, "g":139, "b":23 } ],
-[ "Jungle Hills M", { "r":84, "g":106, "b":45 } ],
-[ "Jungle Hills", { "r":44, "g":66, "b":5 } ],
-[ "Jungle M", { "r":123, "g":163, "b":49 } ],
-[ "Jungle", { "r":83, "g":123, "b":9 } ],
-[ "Mega Spruce Taiga (Hills)", { "r":109, "g":119, "b":102 } ],
-[ "Mega Spruce Taiga", { "r":129, "g":142, "b":121 } ],
-[ "Mega Taiga Hills", { "r":69, "g":79, "b":62 } ],
-[ "Mega Taiga", { "r":89, "g":102, "b":81 } ],
-[ "Mesa (Bryce)", { "r":255, "g":109, "b":61 } ],
-[ "Mesa Plateau F M", { "r":216, "g":191, "b":141 } ],
-[ "Mesa Plateau F", { "r":176, "g":151, "b":101 } ],
-[ "Mesa Plateau M", { "r":242, "g":180, "b":141 } ],
-[ "Mesa Plateau", { "r":202, "g":140, "b":101 } ],
-[ "Mesa", { "r":217, "g":69, "b":21 } ],
-[ "Mushroom Island M", { "r":255, "g":40, "b":255 } ],
-[ "Mushroom Island Shore M", { "r":200, "g":40, "b":255 } ],
-[ "Mushroom Island Shore", { "r":160, "g":0, "b":255 } ],
-[ "Mushroom Island", { "r":255, "g":0, "b":255 } ],
-[ "Ocean M", { "r":40, "g":40, "b":152 } ],
-[ "Ocean", { "r":0, "g":0, "b":112 } ],
-[ "Plains", { "r":141, "g":179, "b":96 } ],
-[ "River M", { "r":40, "g":40, "b":255 } ],
-[ "River", { "r":0, "g":0, "b":255 } ],
-[ "Roofed Forest M", { "r":104, "g":121, "b":66 } ],
-[ "Roofed Forest", { "r":64, "g":81, "b":26 } ],
-[ "Savanna M", { "r":229, "g":218, "b":135 } ],
-[ "Savanna Plateau M", { "r":207, "g":197, "b":140 } ],
-[ "Savanna Plateau", { "r":167, "g":157, "b":100 } ],
-[ "Savanna", { "r":189, "g":178, "b":95 } ],
-[ "Sky M", { "r":168, "g":168, "b":255 } ],
-[ "Sky", { "r":128, "g":128, "b":255 } ],
-[ "Stone Beach M", { "r":202, "g":202, "b":172 } ],
-[ "Stone Beach", { "r":162, "g":162, "b":132 } ],
-[ "Sunflower Plains", { "r":181, "g":219, "b":136 } ],
-[ "Swampland M", { "r":47, "g":255, "b":218 } ],
-[ "Swampland", { "r":7, "g":249, "b":178 } ],
-[ "Taiga Hills M", { "r":62, "g":97, "b":91 } ],
-[ "Taiga Hills", { "r":22, "g":57, "b":51 } ],
-[ "Taiga M", { "r":51, "g":142, "b":129 } ],
-[ "Taiga", { "r":11, "g":102, "b":89 } ] ] }
diff --git a/README.md b/README.md
index 964f95223..0cfac67f0 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,98 @@
-AMIDST
+Amidst
======
+[](https://travis-ci.org/stefandollase/amidst)
+
Advanced Minecraft Interface and Data/Structure Tracking
+Where can I get Amidst?
+-----------------------
+
+You can download Amidst [here](https://github.com/skiphs/amidst/releases/latest). If you find any bugs, please [report](https://github.com/skiphs/amidst/issues/new) them so we can fix them. If you want to request a feature, you can to this [here](https://github.com/skiphs/amidst/issues/new). If you want to help develop Amidst, please get in contact [here](https://github.com/skiphs/amidst/issues/new). Lastly, [here](https://github.com/stefandollase/amidst/blob/refactoring/docs/BUILDING.md) is a description how you can build Amidst by yourself.
+
+What is Amidst?
+---------------
+
+What it **can** do for you:
+
+* generate an overview of a Minecraft world from a given seed and a given Minecraft version
+* display biome information
+* display slime chunks
+* display structures
+ * default world spawn
+ * strongholds
+ * desert temples
+ * jungle temples
+ * witch huts
+ * villages
+ * ocean monuments
+ * nether fortresses
+
+When the world is loaded from a Minecraft world file, Amidst **can** also:
+
+* display singleplayer and multiplayer player locations
+* load player skins
+* move players to another location, including the y-coordinate
+
+What it **cannot** do for you:
+
+* display changes to the world, that are made after the world generator was finished, this includes
+ * changes made by world editors like MCEdit
+ * changes made while loading the world in Minecraft
+* find individual blocks or mobs in the world like e.g.
+ * diamond ore
+ * cows
+
+More features include:
+
+* saving an image of the map
+
+Which Minecraft versions are supported?
+---------------------------------------
+
+We support Minecraft versions from 1.0 up to the latest snapshot. If you find an issue with a specific Minecraft version, [please report it](https://github.com/skiphs/amidst/issues/new).
+
+How can I move a player?
+------------------------
+
+You can move players in a world that was loaded from a Minecraft world file like so:
+
+* scroll to and right-click on the new player location, this opens a popup menu
+* select the player you want to move
+* enter the new y-coordinate
+* save player locations
+
+**WARNING: This will change the contents of the save folder, so there is a chance that the world gets corrupted. We try to minimize the risk by creating a backup of the changed file, before it is changed. If the backup fails, we will not write the changes. You can find the backup files in a sub folder of the world, named 'amidst_backup'. Especially, make sure to not have the world loaded in minecraft during this process.**
+
+When I load a world file I am asked what whether I want to load the Singleplayer of Multiplayer players. What does it mean?
+---------------------------------------------------------------------------------------------------------------------------
+
+Minecraft worlds have three different locations to store player information:
+
+* the `level.dat` file contains the singleplayer player
+* the `players` directory contains all multiplayer players by name, this was used before Minecraft 1.7.6
+* the `playerdata` directory contains all multiplayers players by uuid, this is used since Minecraft 1.7.6
+
+If the `players` and the `playerdata` directory exist, we will simply ignore the `players` directory, since it contains outdated information. However, other situations cannot be decided automatically. If the world was only used by a server, there will be no player information in the `level.dat`, so we will just load the multiplayer players. However, if the map was ever loaded as a singleplayer world, the `level.dat` file will create singleplayer information. Also, the `playerdata` directory will contain information about all the players that used the world as singleplayer world. Of course we could just display the singleplayer player and the multiplayer players, however this might lead to an issue when you want to move the singleplayer player. When the world is loaded as singleplayer world, Minecraft will simply ignore and overwrite the information in the multiplayer directory, that belongs to the player that opened the world. Thus, if you move your player instead of the singleplayer player, this will have no effect.
+
+**tl;dr** If you use the world just as a singleplayer world, simply choose Singleplayer.
+
+What is the internet used for?
+-------------------
+
+* Amidst v3.7 was the last version that used google analytics, so we do no longer track you
+* Amidst will check for updates on every start
+* Amidst will use web services provided by mojang, e.g. to
+ * display information about minecraft versions
+ * display information about players like the name or the skin
+
+General information
+-------------------
+
+Amidst is not owned by or related to mojang in any way.
+
License and warranty
--------------------
-AMIDST comes with ABSOLUTELY NO WARRANTY. It is free software, and you are
-welcome to redistribute it under certain conditions. See LICENSE.txt for more
-details on both of these points.
+Amidst comes with ABSOLUTELY NO WARRANTY. It is free and open source software, license under the
+[GPL v3](https://github.com/skiphs/amidst/blob/master/LICENSE.txt), and you are welcome to redistribute it under certain conditions.
diff --git a/biome/default.json b/biome/default.json
index 8faa004b5..e1aaf5646 100644
--- a/biome/default.json
+++ b/biome/default.json
@@ -1,81 +1,81 @@
-{ "name":"default", "colorMap":[
-[ "Cold Taiga M", { "r":89, "g":125, "b":114 } ],
-[ "Desert", { "r":250, "g":148, "b":24 } ],
-[ "Mushroom Island Shore", { "r":160, "g":0, "b":255 } ],
-[ "Taiga", { "r":11, "g":102, "b":89 } ],
-[ "Extreme Hills Edge M", { "r":154, "g":160, "b":194 } ],
-[ "Cold Beach M", { "r":255, "g":255, "b":232 } ],
-[ "Mesa Plateau", { "r":202, "g":140, "b":101 } ],
-[ "Birch Forest Hills M", { "r":71, "g":135, "b":90 } ],
-[ "Ice Mountains", { "r":160, "g":160, "b":160 } ],
-[ "Swampland M", { "r":47, "g":255, "b":218 } ],
-[ "Mushroom Island M", { "r":255, "g":40, "b":255 } ],
-[ "Birch Forest Hills", { "r":31, "g":95, "b":50 } ],
-[ "Extreme Hills+ M", { "r":120, "g":152, "b":120 } ],
-[ "Taiga M", { "r":51, "g":142, "b":129 } ],
-[ "Jungle M", { "r":123, "g":163, "b":49 } ],
-[ "Mega Spruce Taiga (Hills)", { "r":109, "g":119, "b":102 } ],
-[ "Savanna", { "r":189, "g":178, "b":95 } ],
-[ "Roofed Forest M", { "r":104, "g":121, "b":66 } ],
-[ "Mesa Plateau F", { "r":176, "g":151, "b":101 } ],
-[ "Mesa Plateau F M", { "r":216, "g":191, "b":141 } ],
-[ "Ice Mountains M", { "r":200, "g":200, "b":200 } ],
-[ "Mega Taiga Hills", { "r":69, "g":79, "b":62 } ],
-[ "Ice Plains Spikes", { "r":180, "g":220, "b":220 } ],
-[ "Mushroom Island Shore M", { "r":200, "g":40, "b":255 } ],
-[ "Deep Ocean M", { "r":40, "g":40, "b":88 } ],
-[ "Ice Plains", { "r":255, "g":255, "b":255 } ],
-[ "Mesa Plateau M", { "r":242, "g":180, "b":141 } ],
-[ "Cold Taiga Hills M", { "r":76, "g":103, "b":94 } ],
-[ "Frozen River", { "r":160, "g":160, "b":255 } ],
-[ "Frozen River M", { "r":200, "g":200, "b":255 } ],
-[ "Forest", { "r":5, "g":102, "b":33 } ],
-[ "Mesa (Bryce)", { "r":255, "g":109, "b":61 } ],
-[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
-[ "Forest Hills", { "r":34, "g":85, "b":28 } ],
-[ "Mega Spruce Taiga", { "r":129, "g":142, "b":121 } ],
-[ "Beach", { "r":250, "g":222, "b":85 } ],
-[ "Desert Hills", { "r":210, "g":95, "b":18 } ],
-[ "Roofed Forest", { "r":64, "g":81, "b":26 } ],
-[ "Hell M", { "r":255, "g":40, "b":40 } ],
-[ "Stone Beach", { "r":162, "g":162, "b":132 } ],
-[ "Extreme Hills M", { "r":136, "g":136, "b":136 } ],
-[ "Desert M", { "r":255, "g":188, "b":64 } ],
-[ "Deep Ocean", { "r":0, "g":0, "b":48 } ],
-[ "Extreme Hills", { "r":96, "g":96, "b":96 } ],
-[ "Jungle Hills M", { "r":84, "g":106, "b":45 } ],
-[ "Jungle", { "r":83, "g":123, "b":9 } ],
-[ "Taiga Hills M", { "r":62, "g":97, "b":91 } ],
-[ "Ocean M", { "r":40, "g":40, "b":152 } ],
-[ "Savanna Plateau", { "r":167, "g":157, "b":100 } ],
-[ "Extreme Hills Edge", { "r":114, "g":120, "b":154 } ],
-[ "Sky", { "r":128, "g":128, "b":255 } ],
-[ "Mushroom Island", { "r":255, "g":0, "b":255 } ],
-[ "Birch Forest", { "r":48, "g":116, "b":68 } ],
-[ "Mesa", { "r":217, "g":69, "b":21 } ],
-[ "Mega Taiga", { "r":89, "g":102, "b":81 } ],
-[ "Savanna M", { "r":229, "g":218, "b":135 } ],
-[ "River", { "r":0, "g":0, "b":255 } ],
-[ "Swampland", { "r":7, "g":249, "b":178 } ],
-[ "Sunflower Plains", { "r":181, "g":219, "b":136 } ],
-[ "Extreme Hills+", { "r":80, "g":112, "b":80 } ],
-[ "River M", { "r":40, "g":40, "b":255 } ],
-[ "Flower Forest", { "r":45, "g":142, "b":73 } ],
-[ "Ocean", { "r":0, "g":0, "b":112 } ],
-[ "Plains", { "r":141, "g":179, "b":96 } ],
-[ "Beach M", { "r":255, "g":255, "b":125 } ],
-[ "Sky M", { "r":168, "g":168, "b":255 } ],
-[ "Hell", { "r":255, "g":0, "b":0 } ],
-[ "Taiga Hills", { "r":22, "g":57, "b":51 } ],
-[ "Jungle Edge M", { "r":138, "g":179, "b":63 } ],
-[ "Cold Taiga", { "r":49, "g":85, "b":74 } ],
-[ "Forest Hills M", { "r":74, "g":125, "b":68 } ],
-[ "Jungle Edge", { "r":98, "g":139, "b":23 } ],
-[ "Birch Forest M", { "r":88, "g":156, "b":108 } ],
-[ "Jungle Hills", { "r":44, "g":66, "b":5 } ],
-[ "Stone Beach M", { "r":202, "g":202, "b":172 } ],
-[ "Desert Hills M", { "r":250, "g":135, "b":58 } ],
-[ "Frozen Ocean M", { "r":184, "g":184, "b":200 } ],
-[ "Savanna Plateau M", { "r":207, "g":197, "b":140 } ],
-[ "Cold Taiga Hills", { "r":36, "g":63, "b":54 } ],
-[ "Cold Beach", { "r":250, "g":240, "b":192 } ] ] }
+{ "name":"default", "colorMap":[
+[ "Ocean", { "r":0, "g":0, "b":112 } ],
+[ "Plains", { "r":141, "g":179, "b":96 } ],
+[ "Desert", { "r":250, "g":148, "b":24 } ],
+[ "Extreme Hills", { "r":96, "g":96, "b":96 } ],
+[ "Forest", { "r":5, "g":102, "b":33 } ],
+[ "Taiga", { "r":11, "g":102, "b":89 } ],
+[ "Swampland", { "r":7, "g":249, "b":178 } ],
+[ "River", { "r":0, "g":0, "b":255 } ],
+[ "Hell", { "r":255, "g":0, "b":0 } ],
+[ "Sky", { "r":128, "g":128, "b":255 } ],
+[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
+[ "Frozen River", { "r":160, "g":160, "b":255 } ],
+[ "Ice Plains", { "r":255, "g":255, "b":255 } ],
+[ "Ice Mountains", { "r":160, "g":160, "b":160 } ],
+[ "Mushroom Island", { "r":255, "g":0, "b":255 } ],
+[ "Mushroom Island Shore", { "r":160, "g":0, "b":255 } ],
+[ "Beach", { "r":250, "g":222, "b":85 } ],
+[ "Desert Hills", { "r":210, "g":95, "b":18 } ],
+[ "Forest Hills", { "r":34, "g":85, "b":28 } ],
+[ "Taiga Hills", { "r":22, "g":57, "b":51 } ],
+[ "Extreme Hills Edge", { "r":114, "g":120, "b":154 } ],
+[ "Jungle", { "r":83, "g":123, "b":9 } ],
+[ "Jungle Hills", { "r":44, "g":66, "b":5 } ],
+[ "Jungle Edge", { "r":98, "g":139, "b":23 } ],
+[ "Deep Ocean", { "r":0, "g":0, "b":48 } ],
+[ "Stone Beach", { "r":162, "g":162, "b":132 } ],
+[ "Cold Beach", { "r":250, "g":240, "b":192 } ],
+[ "Birch Forest", { "r":48, "g":116, "b":68 } ],
+[ "Birch Forest Hills", { "r":31, "g":95, "b":50 } ],
+[ "Roofed Forest", { "r":64, "g":81, "b":26 } ],
+[ "Cold Taiga", { "r":49, "g":85, "b":74 } ],
+[ "Cold Taiga Hills", { "r":36, "g":63, "b":54 } ],
+[ "Mega Taiga", { "r":89, "g":102, "b":81 } ],
+[ "Mega Taiga Hills", { "r":69, "g":79, "b":62 } ],
+[ "Extreme Hills+", { "r":80, "g":112, "b":80 } ],
+[ "Savanna", { "r":189, "g":178, "b":95 } ],
+[ "Savanna Plateau", { "r":167, "g":157, "b":100 } ],
+[ "Mesa", { "r":217, "g":69, "b":21 } ],
+[ "Mesa Plateau F", { "r":176, "g":151, "b":101 } ],
+[ "Mesa Plateau", { "r":202, "g":140, "b":101 } ],
+[ "Ocean M", { "r":40, "g":40, "b":152 } ],
+[ "Sunflower Plains", { "r":181, "g":219, "b":136 } ],
+[ "Desert M", { "r":255, "g":188, "b":64 } ],
+[ "Extreme Hills M", { "r":136, "g":136, "b":136 } ],
+[ "Flower Forest", { "r":45, "g":142, "b":73 } ],
+[ "Taiga M", { "r":51, "g":142, "b":129 } ],
+[ "Swampland M", { "r":47, "g":255, "b":218 } ],
+[ "River M", { "r":40, "g":40, "b":255 } ],
+[ "Hell M", { "r":255, "g":40, "b":40 } ],
+[ "Sky M", { "r":168, "g":168, "b":255 } ],
+[ "Frozen Ocean M", { "r":184, "g":184, "b":200 } ],
+[ "Frozen River M", { "r":200, "g":200, "b":255 } ],
+[ "Ice Plains Spikes", { "r":180, "g":220, "b":220 } ],
+[ "Ice Mountains M", { "r":200, "g":200, "b":200 } ],
+[ "Mushroom Island M", { "r":255, "g":40, "b":255 } ],
+[ "Mushroom Island Shore M", { "r":200, "g":40, "b":255 } ],
+[ "Beach M", { "r":255, "g":255, "b":125 } ],
+[ "Desert Hills M", { "r":250, "g":135, "b":58 } ],
+[ "Forest Hills M", { "r":74, "g":125, "b":68 } ],
+[ "Taiga Hills M", { "r":62, "g":97, "b":91 } ],
+[ "Extreme Hills Edge M", { "r":154, "g":160, "b":194 } ],
+[ "Jungle M", { "r":123, "g":163, "b":49 } ],
+[ "Jungle Hills M", { "r":84, "g":106, "b":45 } ],
+[ "Jungle Edge M", { "r":138, "g":179, "b":63 } ],
+[ "Deep Ocean M", { "r":40, "g":40, "b":88 } ],
+[ "Stone Beach M", { "r":202, "g":202, "b":172 } ],
+[ "Cold Beach M", { "r":255, "g":255, "b":232 } ],
+[ "Birch Forest M", { "r":88, "g":156, "b":108 } ],
+[ "Birch Forest Hills M", { "r":71, "g":135, "b":90 } ],
+[ "Roofed Forest M", { "r":104, "g":121, "b":66 } ],
+[ "Cold Taiga M", { "r":89, "g":125, "b":114 } ],
+[ "Cold Taiga Hills M", { "r":76, "g":103, "b":94 } ],
+[ "Mega Spruce Taiga", { "r":129, "g":142, "b":121 } ],
+[ "Mega Spruce Taiga (Hills)", { "r":109, "g":119, "b":102 } ],
+[ "Extreme Hills+ M", { "r":120, "g":152, "b":120 } ],
+[ "Savanna M", { "r":229, "g":218, "b":135 } ],
+[ "Savanna Plateau M", { "r":207, "g":197, "b":140 } ],
+[ "Mesa (Bryce)", { "r":255, "g":109, "b":61 } ],
+[ "Mesa Plateau F M", { "r":216, "g":191, "b":141 } ],
+[ "Mesa Plateau M", { "r":242, "g":180, "b":141 } ] ] }
diff --git a/biome/test.json b/biome/test.json
index 8cc5f6a92..eaa9380af 100644
--- a/biome/test.json
+++ b/biome/test.json
@@ -1,81 +1,81 @@
{ "name":"test", "colorMap":[
-[ "Cold Taiga M", { "r":89, "g":125, "b":114 } ],
+[ "Ocean", { "r":0, "g":0, "b":112 } ],
+[ "Plains", { "r":141, "g":179, "b":96 } ],
[ "Desert", { "r":250, "g":148, "b":24 } ],
-[ "Mushroom Island Shore", { "r":160, "g":0, "b":255 } ],
-[ "Taiga", { "r":11, "g":2, "b":89 } ],
-[ "Extreme Hills Edge M", { "r":154, "g":160, "b":194 } ],
-[ "Cold Beach M", { "r":255, "g":255, "b":232 } ],
-[ "Mesa Plateau", { "r":202, "g":140, "b":101 } ],
-[ "Birch Forest Hills M", { "r":71, "g":15, "b":90 } ],
-[ "Ice Mountains", { "r":160, "g":160, "b":160 } ],
-[ "Swampland M", { "r":47, "g":255, "b":18 } ],
-[ "Mushroom Island M", { "r":255, "g":40, "b":255 } ],
-[ "Birch Forest Hills", { "r":31, "g":5, "b":50 } ],
-[ "Extreme Hills+ M", { "r":120, "g":52, "b":120 } ],
-[ "Taiga M", { "r":51, "g":142, "b":19 } ],
-[ "Jungle M", { "r":123, "g":13, "b":49 } ],
-[ "Mega Spruce Taiga (Hills)", { "r":109, "g":119, "b":102 } ],
-[ "Savanna", { "r":189, "g":18, "b":95 } ],
-[ "Roofed Forest M", { "r":104, "g":121, "b":66 } ],
-[ "Mesa Plateau F", { "r":17, "g":151, "b":101 } ],
-[ "Mesa Plateau F M", { "r":216, "g":191, "b":141 } ],
-[ "Ice Mountains M", { "r":20, "g":20, "b":200 } ],
-[ "Mega Taiga Hills", { "r":69, "g":7, "b":62 } ],
-[ "Ice Plains Spikes", { "r":180, "g":20, "b":220 } ],
-[ "Mushroom Island Shore M", { "r":200, "g":40, "b":255 } ],
-[ "Deep Ocean M", { "r":40, "g":40, "b":88 } ],
-[ "Ice Plains", { "alias":"test", "r":255, "g":255, "b":255 } ],
-[ "Mesa Plateau M", { "r":242, "g":180, "b":141 } ],
-[ "Cold Taiga Hills M", { "r":76, "g":103, "b":94 } ],
-[ "Frozen River", { "r":160, "g":160, "b":255 } ],
-[ "Frozen River M", { "r":200, "g":200, "b":255 } ],
+[ "Extreme Hills", { "r":96, "g":96, "b":96 } ],
[ "Forest", { "r":5, "g":102, "b":33 } ],
-[ "Mesa (Bryce)", { "r":255, "g":109, "b":61 } ],
+[ "Taiga", { "r":11, "g":2, "b":89 } ],
+[ "Swampland", { "r":7, "g":249, "b":178 } ],
+[ "River", { "r":0, "g":0, "b":255 } ],
+[ "Hell", { "r":255, "g":0, "b":0 } ],
+[ "Sky", { "r":128, "g":128, "b":255 } ],
[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
-[ "Forest Hills", { "r":34, "g":85, "b":28 } ],
-[ "Mega Spruce Taiga", { "r":129, "g":142, "b":121 } ],
+[ "Frozen River", { "r":160, "g":160, "b":255 } ],
+[ "Ice Plains", { "r":255, "g":255, "b":255 } ],
+[ "Ice Mountains", { "r":160, "g":160, "b":160 } ],
+[ "Mushroom Island", { "r":255, "g":0, "b":255 } ],
+[ "Mushroom Island Shore", { "r":160, "g":0, "b":255 } ],
[ "Beach", { "r":250, "g":222, "b":85 } ],
[ "Desert Hills", { "r":210, "g":95, "b":18 } ],
-[ "Roofed Forest", { "r":64, "g":81, "b":26 } ],
-[ "Hell M", { "r":255, "g":40, "b":40 } ],
-[ "Stone Beach", { "r":162, "g":162, "b":132 } ],
-[ "Extreme Hills M", { "r":136, "g":136, "b":136 } ],
-[ "Desert M", { "r":255, "g":188, "b":64 } ],
-[ "Deep Ocean", { "r":0, "g":0, "b":48 } ],
-[ "Extreme Hills", { "r":96, "g":96, "b":96 } ],
-[ "Jungle Hills M", { "r":84, "g":106, "b":45 } ],
-[ "Jungle", { "r":83, "g":123, "b":9 } ],
-[ "Taiga Hills M", { "r":62, "g":97, "b":91 } ],
-[ "Ocean M", { "r":40, "g":40, "b":152 } ],
-[ "Savanna Plateau", { "r":167, "g":157, "b":100 } ],
+[ "Forest Hills", { "r":34, "g":85, "b":28 } ],
+[ "Taiga Hills", { "r":22, "g":57, "b":51 } ],
[ "Extreme Hills Edge", { "r":114, "g":120, "b":154 } ],
-[ "Sky", { "r":128, "g":128, "b":255 } ],
-[ "Mushroom Island", { "r":255, "g":0, "b":255 } ],
+[ "Jungle", { "r":83, "g":123, "b":9 } ],
+[ "Jungle Hills", { "r":44, "g":66, "b":5 } ],
+[ "Jungle Edge", { "r":98, "g":139, "b":23 } ],
+[ "Deep Ocean", { "r":0, "g":0, "b":48 } ],
+[ "Stone Beach", { "r":162, "g":162, "b":132 } ],
+[ "Cold Beach", { "r":250, "g":240, "b":192 } ],
[ "Birch Forest", { "r":48, "g":116, "b":68 } ],
-[ "Mesa", { "r":217, "g":69, "b":21 } ],
+[ "Birch Forest Hills", { "r":31, "g":5, "b":50 } ],
+[ "Roofed Forest", { "r":64, "g":81, "b":26 } ],
+[ "Cold Taiga", { "r":49, "g":85, "b":74 } ],
+[ "Cold Taiga Hills", { "r":36, "g":63, "b":54 } ],
[ "Mega Taiga", { "r":89, "g":102, "b":81 } ],
-[ "Savanna M", { "r":229, "g":218, "b":135 } ],
-[ "River", { "r":0, "g":0, "b":255 } ],
-[ "Swampland", { "r":7, "g":249, "b":178 } ],
-[ "Sunflower Plains", { "r":181, "g":219, "b":136 } ],
+[ "Mega Taiga Hills", { "r":69, "g":7, "b":62 } ],
[ "Extreme Hills+", { "r":80, "g":112, "b":80 } ],
-[ "River M", { "r":40, "g":40, "b":255 } ],
+[ "Savanna", { "r":189, "g":18, "b":95 } ],
+[ "Savanna Plateau", { "r":167, "g":157, "b":100 } ],
+[ "Mesa", { "r":217, "g":69, "b":21 } ],
+[ "Mesa Plateau F", { "r":17, "g":151, "b":101 } ],
+[ "Mesa Plateau", { "r":202, "g":140, "b":101 } ],
+[ "Ocean M", { "r":40, "g":40, "b":152 } ],
+[ "Sunflower Plains", { "r":181, "g":219, "b":136 } ],
+[ "Desert M", { "r":255, "g":188, "b":64 } ],
+[ "Extreme Hills M", { "r":136, "g":136, "b":136 } ],
[ "Flower Forest", { "r":45, "g":142, "b":73 } ],
-[ "Ocean", { "r":0, "g":0, "b":112 } ],
-[ "Plains", { "r":141, "g":179, "b":96 } ],
-[ "Beach M", { "r":255, "g":255, "b":125 } ],
+[ "Taiga M", { "r":51, "g":142, "b":19 } ],
+[ "Swampland M", { "r":47, "g":255, "b":18 } ],
+[ "River M", { "r":40, "g":40, "b":255 } ],
+[ "Hell M", { "r":255, "g":40, "b":40 } ],
[ "Sky M", { "r":168, "g":168, "b":255 } ],
-[ "Hell", { "r":255, "g":0, "b":0 } ],
-[ "Taiga Hills", { "r":22, "g":57, "b":51 } ],
-[ "Jungle Edge M", { "r":138, "g":179, "b":63 } ],
-[ "Cold Taiga", { "r":49, "g":85, "b":74 } ],
+[ "Frozen Ocean M", { "r":184, "g":184, "b":200 } ],
+[ "Frozen River M", { "r":200, "g":200, "b":255 } ],
+[ "Ice Plains Spikes", { "r":180, "g":20, "b":220 } ],
+[ "Ice Mountains M", { "r":20, "g":20, "b":200 } ],
+[ "Mushroom Island M", { "r":255, "g":40, "b":255 } ],
+[ "Mushroom Island Shore M", { "r":200, "g":40, "b":255 } ],
+[ "Beach M", { "r":255, "g":255, "b":125 } ],
+[ "Desert Hills M", { "r":250, "g":135, "b":58 } ],
[ "Forest Hills M", { "r":74, "g":125, "b":68 } ],
-[ "Jungle Edge", { "r":98, "g":139, "b":23 } ],
-[ "Birch Forest M", { "r":88, "g":156, "b":108 } ],
-[ "Jungle Hills", { "r":44, "g":66, "b":5 } ],
+[ "Taiga Hills M", { "r":62, "g":97, "b":91 } ],
+[ "Extreme Hills Edge M", { "r":154, "g":160, "b":194 } ],
+[ "Jungle M", { "r":123, "g":13, "b":49 } ],
+[ "Jungle Hills M", { "r":84, "g":106, "b":45 } ],
+[ "Jungle Edge M", { "r":138, "g":179, "b":63 } ],
+[ "Deep Ocean M", { "r":40, "g":40, "b":88 } ],
[ "Stone Beach M", { "r":202, "g":202, "b":172 } ],
-[ "Desert Hills M", { "r":250, "g":135, "b":58 } ],
-[ "Frozen Ocean M", { "r":184, "g":184, "b":200 } ],
+[ "Cold Beach M", { "r":255, "g":255, "b":232 } ],
+[ "Birch Forest M", { "r":88, "g":156, "b":108 } ],
+[ "Birch Forest Hills M", { "r":71, "g":15, "b":90 } ],
+[ "Roofed Forest M", { "r":104, "g":121, "b":66 } ],
+[ "Cold Taiga M", { "r":89, "g":125, "b":114 } ],
+[ "Cold Taiga Hills M", { "r":76, "g":103, "b":94 } ],
+[ "Mega Spruce Taiga", { "r":129, "g":142, "b":121 } ],
+[ "Mega Spruce Taiga (Hills)", { "r":109, "g":119, "b":102 } ],
+[ "Extreme Hills+ M", { "r":120, "g":52, "b":120 } ],
+[ "Savanna M", { "r":229, "g":218, "b":135 } ],
[ "Savanna Plateau M", { "r":207, "g":197, "b":140 } ],
-[ "Cold Taiga Hills", { "r":36, "g":63, "b":54 } ],
-[ "Cold Beach", { "r":250, "g":240, "b":192 } ] ] }
+[ "Mesa (Bryce)", { "r":255, "g":109, "b":61 } ],
+[ "Mesa Plateau F M", { "r":216, "g":191, "b":141 } ],
+[ "Mesa Plateau M", { "r":242, "g":180, "b":141 } ] ] }
diff --git a/build.xml b/build.xml
deleted file mode 100644
index cdfa7571f..000000000
--- a/build.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
- Build AMIDST
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/BUILDING.md b/docs/BUILDING.md
new file mode 100644
index 000000000..d2c1117bd
--- /dev/null
+++ b/docs/BUILDING.md
@@ -0,0 +1,36 @@
+Building Amidst
+=====
+
+The build process is configured via the file `src/main/resources/amidst/metadata.properties`. For example the `` is taken from the variable `amidst.build.filename`.
+
+Amidst uses maven for its build process. Here are the steps to build from source:
+
+* `mvn clean`
+* `mvn install`
+
+This will place the jar file under `target/.jar`.
+
+To build the wrapper for mac, follow these steps:
+
+* `mvn clean`
+* `mvn install`
+* `bash travis-ci/scripts/create-mac-icon.sh`
+* `mvn package -DskipTests=true -f travis-ci/wrapper-for-mac/pom.xml`
+* `bash travis-ci/scripts/zip-and-move-wrapper-for-mac.sh`
+
+This will place the zip file under `target/.zip`.
+
+To build the wrapper for windows, follow these steps:
+
+* `mvn clean`
+* `mvn install`
+* `bash travis-ci/scripts/create-windows-icon.sh`
+* `mvn package -DskipTests=true -f travis-ci/wrapper-for-windows/pom.xml`
+
+This will place the exe file under `target/.exe`.
+
+You will need imagemagick installed to create the icons. Of course, you can also create the icon files by yourself and place them as `target/icon.icns` (mac) or `target/icon.ico` (windows) to the expected location. The `zip-and-move-wrapper-for-mac.sh` bash script simply creates a zip file from the directory located at `travis-ci/wrapper-for-mac/target//`. You can also do this by yourself.
+
+All of these steps are also executed by travis-ci to create a new release. However the regular travis-ci build will not create the wrappers for mac and windows.
+
+The command `mvn clean` will actually install a dependency that is not available from a public maven repository to the local maven repository, so it is necessary to execute.
diff --git a/lib/JGoogleAnalytics_0.4.jar b/lib/JGoogleAnalytics_0.4.jar
deleted file mode 100644
index cceba1c88..000000000
Binary files a/lib/JGoogleAnalytics_0.4.jar and /dev/null differ
diff --git a/lib/args4j-2.0.21.jar b/lib/args4j-2.0.21.jar
deleted file mode 100644
index e188b3dfe..000000000
Binary files a/lib/args4j-2.0.21.jar and /dev/null differ
diff --git a/lib/gson-2.2.4.jar b/lib/gson-2.2.4.jar
deleted file mode 100644
index 9478253e8..000000000
Binary files a/lib/gson-2.2.4.jar and /dev/null differ
diff --git a/lib/js.jar b/lib/js.jar
deleted file mode 100644
index 6f0dafbbc..000000000
Binary files a/lib/js.jar and /dev/null differ
diff --git a/lib/kryonet-2.21-all.jar b/lib/kryonet-2.21-all.jar
deleted file mode 100644
index e7b0c94ef..000000000
Binary files a/lib/kryonet-2.21-all.jar and /dev/null differ
diff --git a/lib/miglayout-4.0-swing.jar b/lib/miglayout-4.0-swing.jar
deleted file mode 100644
index 7b6a22cac..000000000
Binary files a/lib/miglayout-4.0-swing.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 000000000..1fe96b8c3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,134 @@
+
+ 4.0.0
+ amidst
+ amidst
+ 0.0.1-SNAPSHOT
+
+ yyyy-MM-dd HH:mm
+
+
+ ${amidst.build.filename}
+
+
+ org.codehaus.mojo
+ properties-maven-plugin
+ 1.0.0
+
+
+ initialize
+
+ read-project-properties
+
+
+
+ ${basedir}/src/main/resources/amidst/metadata.properties
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+ 2.5.2
+
+
+ install-jnbt
+ clean
+
+ install-file
+
+
+ ${basedir}/lib/JNBT_1.3.jar
+ default
+ jnbt
+ jnbt
+ 1.3
+ jar
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+ 2.9
+
+ true
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ ${amidst.build.jdk.version}
+ ${amidst.build.jdk.version}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+
+ package
+
+ shade
+
+
+
+
+ amidst.Amidst
+
+ ${amidst.build.filename}
+ ${maven.build.timestamp}
+
+
+
+
+
+
+
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.5
+
+
+ com.miglayout
+ miglayout-swing
+ 4.2
+
+
+ args4j
+ args4j
+ 2.32
+
+
+ jnbt
+ jnbt
+ 1.3
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+ org.codehaus.mojo
+ properties-maven-plugin
+ 1.0.0
+ provided
+ maven-plugin
+
+
+
\ No newline at end of file
diff --git a/src/MoF/FinderWindow.java b/src/MoF/FinderWindow.java
deleted file mode 100644
index ebbbe1be3..000000000
--- a/src/MoF/FinderWindow.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package MoF;
-
-
-import amidst.Amidst;
-import amidst.gui.menu.AmidstMenu;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.event.*;
-import javax.swing.JFrame;
-
-public class FinderWindow extends JFrame {
- private static final long serialVersionUID = 196896954675968191L;
- public static FinderWindow instance;
- private Container pane;
- public Project curProject; //TODO
- public static boolean dataCollect;
- private final AmidstMenu menuBar;
- public FinderWindow() {
- //Initialize window
- super("Amidst v" + Amidst.version());
-
- setSize(1000,800);
- //setLookAndFeel();
- pane = getContentPane();
- //UI Manager:
- pane.setLayout(new BorderLayout());
- new UpdateManager(this, true).start();
- setJMenuBar(menuBar = new AmidstMenu(this));
- setVisible(true);
- setIconImage(Amidst.icon);
- instance = this;
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- dispose();
- System.exit(0);
- }
- });
- }
-
- public void clearProject() {
- // FIXME Release resources.
- if (curProject != null) {
- removeKeyListener(curProject.getKeyListener());
- curProject.dispose();
- pane.remove(curProject);
- System.gc();
- }
- }
- public void setProject(Project ep) {
- menuBar.mapMenu.setEnabled(true);
- curProject = ep;
-
- addKeyListener(ep.getKeyListener());
- pane.add(curProject, BorderLayout.CENTER);
-
- this.validate();
- }
-}
diff --git a/src/MoF/Google.java b/src/MoF/Google.java
deleted file mode 100644
index 8966bce47..000000000
--- a/src/MoF/Google.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package MoF;
-
-import amidst.Amidst;
-
-import com.boxysystems.jgoogleanalytics.*;
-
-
-public class Google {
- private static JGoogleAnalyticsTracker tracker;
- public static void startTracking() {
- tracker = new JGoogleAnalyticsTracker("AMIDST", Amidst.version(), "UA-27092717-1");
-
- }
-
- public static void track(String s) {
- FocusPoint focusPoint = new FocusPoint(s);
- tracker.trackAsynchronously(focusPoint);
- }
-
-}
diff --git a/src/MoF/MapViewer.java b/src/MoF/MapViewer.java
deleted file mode 100644
index a6ce03a92..000000000
--- a/src/MoF/MapViewer.java
+++ /dev/null
@@ -1,395 +0,0 @@
-package MoF;
-
-
-import amidst.Options;
-import amidst.gui.menu.PlayerMenuItem;
-import amidst.logging.Log;
-import amidst.map.FragmentManager;
-import amidst.map.IconLayer;
-import amidst.map.ImageLayer;
-import amidst.map.LiveLayer;
-import amidst.map.Map;
-import amidst.map.MapObject;
-import amidst.map.MapObjectPlayer;
-import amidst.map.layers.BiomeLayer;
-import amidst.map.layers.GridLayer;
-import amidst.map.layers.NetherFortressLayer;
-import amidst.map.layers.OceanMonumentLayer;
-import amidst.map.layers.PlayerLayer;
-import amidst.map.layers.SlimeLayer;
-import amidst.map.layers.SpawnLayer;
-import amidst.map.layers.StrongholdLayer;
-import amidst.map.layers.TempleLayer;
-import amidst.map.layers.VillageLayer;
-import amidst.map.widget.BiomeToggleWidget;
-import amidst.map.widget.BiomeWidget;
-import amidst.map.widget.CursorInformationWidget;
-import amidst.map.widget.DebugWidget;
-import amidst.map.widget.FpsWidget;
-import amidst.map.widget.ScaleWidget;
-import amidst.map.widget.PanelWidget.CornerAnchorPoint;
-import amidst.map.widget.SeedWidget;
-import amidst.map.widget.SelectedObjectWidget;
-import amidst.map.widget.Widget;
-import amidst.minecraft.MinecraftUtil;
-import amidst.resources.ResourceLoader;
-
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.RenderingHints;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseWheelEvent;
-import java.awt.event.MouseWheelListener;
-import java.awt.geom.Point2D;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.imageio.ImageIO;
-import javax.swing.JComponent;
-import javax.swing.JPopupMenu;
-
-public class MapViewer extends JComponent implements MouseListener, MouseWheelListener, KeyListener {
- private static final long serialVersionUID = -8309927053337294612L;
- // TODO: This should likely be moved somewhere else.
- private static FragmentManager fragmentManager;
- private static PlayerLayer playerLayer;
-
- private Widget mouseOwner;
- private static BufferedImage
- dropShadowBottomLeft = ResourceLoader.getImage("dropshadow/inner_bottom_left.png"),
- dropShadowBottomRight = ResourceLoader.getImage("dropshadow/inner_bottom_right.png"),
- dropShadowTopLeft = ResourceLoader.getImage("dropshadow/inner_top_left.png"),
- dropShadowTopRight = ResourceLoader.getImage("dropshadow/inner_top_right.png"),
- dropShadowBottom = ResourceLoader.getImage("dropshadow/inner_bottom.png"),
- dropShadowTop = ResourceLoader.getImage("dropshadow/inner_top.png"),
- dropShadowLeft = ResourceLoader.getImage("dropshadow/inner_left.png"),
- dropShadowRight = ResourceLoader.getImage("dropshadow/inner_right.png");
- static {
- fragmentManager = new FragmentManager(
- new ImageLayer[] {
- new BiomeLayer(),
- new SlimeLayer()
- },
- new LiveLayer[] {
- new GridLayer()
- },
- new IconLayer[] {
- new VillageLayer(),
- new OceanMonumentLayer(),
- new StrongholdLayer(),
- new TempleLayer(),
- new SpawnLayer(),
- new NetherFortressLayer(),
- playerLayer = new PlayerLayer()
- });
- }
-
- private Project proj;
-
- private JPopupMenu menu = new JPopupMenu();
- public int strongholdCount, villageCount;
-
- private Map worldMap;
- private MapObject selectedObject = null;
- private Point lastMouse;
- public Point lastRightClick = null;
- private Point2D.Double panSpeed;
-
- private static int zoomLevel = 0, zoomTicksRemaining = 0;
- private static double targetZoom = 0.25f, curZoom = 0.25f;
- private Point zoomMouse = new Point();
-
- private Font textFont = new Font("arial", Font.BOLD, 15);
-
- private FontMetrics textMetrics;
-
- private ArrayList widgets = new ArrayList();
- private long lastTime;
-
- public void dispose() {
- Log.debug("Disposing of map viewer.");
- worldMap.dispose();
- menu.removeAll();
- proj = null;
- }
-
- MapViewer(Project proj) {
- panSpeed = new Point2D.Double();
- this.proj = proj;
- if (playerLayer.isEnabled = proj.saveLoaded) {
- playerLayer.setPlayers(proj.save);
- for (MapObjectPlayer player : proj.save.getPlayers()) {
- menu.add(new PlayerMenuItem(this, player, playerLayer));
- }
- }
-
- worldMap = new Map(fragmentManager); //TODO: implement more layers
- worldMap.setZoom(curZoom);
-
- widgets.add(new FpsWidget(this).setAnchorPoint(CornerAnchorPoint.BOTTOM_LEFT));
- widgets.add(new ScaleWidget(this).setAnchorPoint(CornerAnchorPoint.BOTTOM_CENTER));
- widgets.add(new SeedWidget(this).setAnchorPoint(CornerAnchorPoint.TOP_LEFT));
- widgets.add(new DebugWidget(this).setAnchorPoint(CornerAnchorPoint.BOTTOM_RIGHT));
- widgets.add(new SelectedObjectWidget(this).setAnchorPoint(CornerAnchorPoint.TOP_LEFT));
- widgets.add(new CursorInformationWidget(this).setAnchorPoint(CornerAnchorPoint.TOP_RIGHT));
- widgets.add(new BiomeToggleWidget(this).setAnchorPoint(CornerAnchorPoint.BOTTOM_RIGHT));
- widgets.add(BiomeWidget.get(this).setAnchorPoint(CornerAnchorPoint.NONE));
- addMouseListener(this);
- addMouseWheelListener(this);
-
- setFocusable(true);
- lastTime = System.currentTimeMillis();
-
- textMetrics = getFontMetrics(textFont);
- }
-
- @Override
- public void paint(Graphics g) {
- Graphics2D g2d = (Graphics2D)g.create();
-
- long currentTime = System.currentTimeMillis();
- float time = Math.min(Math.max(0, currentTime - lastTime), 100) / 1000.0f;
- lastTime = currentTime;
-
- g2d.setColor(Color.black);
- g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
-
- if (zoomTicksRemaining-- > 0) {
- double lastZoom = curZoom;
- curZoom = (targetZoom + curZoom) * 0.5;
-
- Point2D.Double targetZoom = worldMap.getScaled(lastZoom, curZoom, zoomMouse);
- worldMap.moveBy(targetZoom);
- worldMap.setZoom(curZoom);
- }
-
- Point curMouse = getMousePosition();
- if (lastMouse != null) {
- if (curMouse != null) {
- double difX = curMouse.x - lastMouse.x;
- double difY = curMouse.y - lastMouse.y;
- // TODO : Scale with time
- panSpeed.setLocation(difX * 0.2, difY * 0.2);
- }
-
- lastMouse.translate((int) panSpeed.x, (int)panSpeed.y);
- }
-
- worldMap.moveBy((int)panSpeed.x, (int)panSpeed.y);
- if (Options.instance.mapFlicking.get()) {
- panSpeed.x *= 0.95f;
- panSpeed.y *= 0.95f;
- } else {
- panSpeed.x *= 0.f;
- panSpeed.y *= 0.f;
- }
-
- worldMap.width = getWidth();
- worldMap.height = getHeight();
-
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- worldMap.draw((Graphics2D)g2d.create(), time);
- g2d.drawImage(dropShadowTopLeft, 0, 0, null);
- g2d.drawImage(dropShadowTopRight, getWidth() - 10, 0, null);
- g2d.drawImage(dropShadowBottomLeft, 0, getHeight() - 10, null);
- g2d.drawImage(dropShadowBottomRight, getWidth() - 10, getHeight() - 10, null);
-
- g2d.drawImage(dropShadowTop, 10, 0, getWidth() - 20, 10, null);
- g2d.drawImage(dropShadowBottom, 10, getHeight() - 10, getWidth() - 20, 10, null);
- g2d.drawImage(dropShadowLeft, 0, 10, 10, getHeight() - 20, null);
- g2d.drawImage(dropShadowRight, getWidth() - 10, 10, 10, getHeight() - 20, null);
-
- g2d.setFont(textFont);
- for (Widget widget : widgets) {
- if (widget.isVisible()) {
- g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, widget.getAlpha()));
- widget.draw(g2d, time);
- }
- }
- }
-
-
- public void centerAt(long x, long y) {
- worldMap.centerOn(x, y);
- }
-
- public void adjustZoom(Point position, int notches) {
- zoomMouse = position;
- if (notches > 0) {
- if (zoomLevel < (Options.instance.maxZoom.get()?10:10000)) {
- targetZoom /= 1.1;
- zoomLevel++;
- zoomTicksRemaining = 100;
- }
- } else {
- if (zoomLevel > -20) {
- targetZoom *= 1.1;
- zoomLevel--;
- zoomTicksRemaining = 100;
- }
- }
- }
-
- @Override
- public void mouseWheelMoved(MouseWheelEvent e) {
- int notches = e.getWheelRotation();
- Point mouse = e.getPoint(); // Don't use getMousePosition() because when computer is swapping/grinding, mouse may have moved out of window before execution reaches here.
- for (Widget widget : widgets) {
- if ((widget.isVisible()) &&
- (mouse.x > widget.getX()) &&
- (mouse.y > widget.getY()) &&
- (mouse.x < widget.getX() + widget.getWidth()) &&
- (mouse.y < widget.getY() + widget.getHeight())) {
- if (widget.onMouseWheelMoved(mouse.x - widget.getX(), mouse.y - widget.getY(), notches))
- return;
- }
- }
- adjustZoom(getMousePosition(), notches);
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- if (!e.isMetaDown()) {
- Point mouse = e.getPoint(); // Don't use getMousePosition() because when computer is swapping/grinding, mouse may have moved out of window before execution reaches here.
- for (Widget widget : widgets) {
- if ((widget.isVisible()) &&
- (mouse.x > widget.getX()) &&
- (mouse.y > widget.getY()) &&
- (mouse.x < widget.getX() + widget.getWidth()) &&
- (mouse.y < widget.getY() + widget.getHeight())) {
- if (widget.onClick(mouse.x - widget.getX(), mouse.y - widget.getY()))
- return;
- }
- }
- MapObject object = worldMap.getObjectAt(mouse, 50.0);
-
- if (selectedObject != null)
- selectedObject.localScale = 1.0;
-
- if (object != null)
- object.localScale = 1.5;
- selectedObject = object;
- }
- }
-
-
- @Override
- public void mouseEntered(MouseEvent arg0) {
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- }
- @Override
- public void mousePressed(MouseEvent e) {
- if (e.isMetaDown())
- return;
- Point mouse = e.getPoint(); // Don't use getMousePosition() because when computer is swapping/grinding, mouse may have moved out of window before execution reaches here.
- for (Widget widget : widgets) {
- if ((widget.isVisible()) &&
- (mouse.x > widget.getX()) &&
- (mouse.y > widget.getY()) &&
- (mouse.x < widget.getX() + widget.getWidth()) &&
- (mouse.y < widget.getY() + widget.getHeight())) {
- if (widget.onMousePressed(mouse.x - widget.getX(), mouse.y - widget.getY())) {
- mouseOwner = widget;
- return;
- }
- }
- }
- lastMouse = mouse;
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger() && MinecraftUtil.getVersion().saveEnabled()) {
- lastRightClick = getMousePosition();
- if (proj.saveLoaded) {
- menu.show(e.getComponent(), e.getX(), e.getY());
- }
- } else {
- if (mouseOwner != null) {
- mouseOwner.onMouseReleased();
- mouseOwner = null;
- } else {
- lastMouse = null;
- }
- }
- }
-
- public MapObject getSelectedObject() {
- return selectedObject;
- }
-
-
- public void movePlayer(String name, ActionEvent e) {
- //PixelInfo p = getCursorInformation(new Point(tempX, tempY));
-
- //proj.movePlayer(name, p);
- }
-
- public void saveToFile(File f) {
- BufferedImage image = new BufferedImage(worldMap.width, worldMap.height, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = image.createGraphics();
-
- worldMap.draw(g2d, 0);
-
- for (Widget widget : widgets)
- if (widget.isVisible())
- widget.draw(g2d, 0);
-
- try {
- ImageIO.write(image, "png", f);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- g2d.dispose();
- image.flush();
- }
-
- @Override
- public void keyPressed(KeyEvent e) {
- // TODO Auto-generated method stub
- Point mouse = getMousePosition();
- if (mouse == null)
- mouse = new Point(getWidth() >> 1, getHeight () >> 1);
- if (e.getKeyCode() == KeyEvent.VK_EQUALS)
- adjustZoom(mouse, -1);
- else if (e.getKeyCode() == KeyEvent.VK_MINUS)
- adjustZoom(mouse, 1);
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- public FragmentManager getFragmentManager() {
- return fragmentManager;
- }
-
- public Map getMap() {
- return worldMap;
- }
-
- public FontMetrics getFontMetrics() {
- return textMetrics;
- }
-}
diff --git a/src/MoF/Project.java b/src/MoF/Project.java
deleted file mode 100644
index a98aae34b..000000000
--- a/src/MoF/Project.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package MoF;
-
-import amidst.Options;
-import amidst.logging.Log;
-import amidst.map.MapObject;
-import amidst.minecraft.MinecraftUtil;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.event.KeyListener;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.sql.Timestamp;
-import java.util.Date;
-
-import javax.swing.JPanel;
-
-@Deprecated //TODO: we should remove this and integrate it into Options
-public class Project extends JPanel {
- private static final long serialVersionUID = 1132526465987018165L;
-
- public MapViewer map;
- public static int FRAGMENT_SIZE = 256;
- private Timer timer;
- public MapObject curTarget;
-
- public boolean saveLoaded;
- public SaveLoader save;
-
- public Project(String seed) {
- this(stringToLong(seed));
- Options.instance.seedText = seed;
-
- Google.track("seed/" + seed + "/" + Options.instance.seed);
- }
-
- public Project(long seed) {
- this(seed, SaveLoader.Type.DEFAULT.getName());
- }
-
- public Project(SaveLoader file) {
- this(file.seed, SaveLoader.genType.getName(), file);
-
- Google.track("seed/file/" + Options.instance.seed);
- }
-
- public Project(String seed, String type) {
- this(stringToLong(seed), type);
-
- Google.track("seed/" + seed + "/" + Options.instance.seed);
- }
-
- public Project(long seed, String type) {
- this(seed, type, null);
- }
-
- private void logSeedHistory(long seed) {
- File historyFile = new File("./history.txt");
- if (Options.instance.historyPath != null) {
- historyFile = new File(Options.instance.historyPath);
- if (!historyFile.exists()) {
- try {
- historyFile.createNewFile();
- } catch (IOException e) {
- Log.w("Unable to create history file: " + historyFile);
- e.printStackTrace();
- return;
- }
- }
- }
-
- if (historyFile.exists() && historyFile.isFile()) {
- FileWriter writer = null;
- try {
- writer = new FileWriter(historyFile, true);
- writer.append(new Timestamp(new Date().getTime()).toString() + " " + seed + "\r\n");
- } catch (IOException e) {
- Log.w("Unable to write to history file.");
- e.printStackTrace();
- } finally {
- try {
- if (writer != null)
- writer.close();
- } catch (IOException e) {
- Log.w("Unable to close writer for history file.");
- e.printStackTrace();
- }
- }
- }
-
-
- }
-
- public Project(long seed, String type, SaveLoader saveLoader) {
- logSeedHistory(seed);
- saveLoaded = !(saveLoader == null);
- save = saveLoader;
- //Enter seed data:
- Options.instance.seed = seed;
-
- BorderLayout layout = new BorderLayout();
- this.setLayout(layout);
- if (saveLoaded)
- MinecraftUtil.createWorld(seed, type, save.getGeneratorOptions());
- else
- MinecraftUtil.createWorld(seed, type);
- //Create MapViewer
- map = new MapViewer(this);
- add(map, BorderLayout.CENTER);
- //Debug
- this.setBackground(Color.BLUE);
-
- //Timer:
- timer = new Timer();
-
- timer.scheduleAtFixedRate(new TimerTask() {
- public void run() {
- tick();
- }
- }, 20, 20);
-
- }
-
- public void tick() {
- map.repaint();
- }
-
- public void dispose() {
- map.dispose();
- map = null;
- timer.cancel();
- timer = null;
- curTarget = null;
- save = null;
- System.gc();
- }
-
- private static long stringToLong(String seed) {
- long ret;
- try {
- ret = Long.parseLong(seed);
- } catch (NumberFormatException err) {
- ret = seed.hashCode();
- }
- return ret;
- }
-
-
- public KeyListener getKeyListener() {
- return map;
- }
- public void moveMapTo(long x, long y) {
- map.centerAt(x, y);
- }
-}
diff --git a/src/MoF/SaveLoader.java b/src/MoF/SaveLoader.java
deleted file mode 100644
index 0588d71f1..000000000
--- a/src/MoF/SaveLoader.java
+++ /dev/null
@@ -1,209 +0,0 @@
-package MoF;
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.map.MapObjectPlayer;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import javax.swing.filechooser.FileFilter;
-
-import org.jnbt.CompoundTag;
-import org.jnbt.DoubleTag;
-import org.jnbt.ListTag;
-import org.jnbt.NBTInputStream;
-import org.jnbt.NBTOutputStream;
-import org.jnbt.Tag;
-
-public class SaveLoader {
- public static Type genType = Type.DEFAULT;
-
- public enum Type {
- DEFAULT("Default", "default"), FLAT("Flat", "flat"), LARGE_BIOMES("Large Biomes", "largeBiomes"), AMPLIFIED("Amplified", "amplified"), CUSTOMIZED("Customized", "customized");
- private final String name;
- private final String value;
- Type(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public static Type fromMixedCase(String name) {
- name = name.toLowerCase();
- for (Type t : values())
- if (t.name.toLowerCase().equals(name) || t.value.toLowerCase().equals(name))
- return t;
- Log.crash("Unable to find World Type: " + name);
- return null;
- }
-
- }
- public static Type[] selectableTypes = new Type[] { Type.DEFAULT, Type.FLAT, Type.LARGE_BIOMES, Type.AMPLIFIED };
- public static FileFilter getFilter() {
- return (new FileFilter() {
- public boolean accept(File f) {
- if (f.isDirectory())
- return true;
- String[] st = f.getName().split("\\/");
- return st[st.length - 1].equalsIgnoreCase("level.dat");
- }
-
- @Override
- public String getDescription() {
- return "Minecraft Data File (level.dat)";
- }
- });
- }
-
- private File file;
- private List players;
- public long seed;
- private boolean multi;
- private List back;
- private String generatorOptions = "";
-
- public List getPlayers() {
- return players;
- }
- public void movePlayer(String name, int x, int y) {
- File out;
- if (multi) {
- String outPath = file.getParent() + "/players/" + name +".dat";
- out = new File(outPath);
- backupFile(out);
- try {
- NBTInputStream inStream = new NBTInputStream(new FileInputStream(out));
- CompoundTag root = (CompoundTag)inStream.readTag();
- inStream.close();
-
- HashMap rootMap = new HashMap(root.getValue());
- ArrayList posTag = new ArrayList(((ListTag)rootMap.get("Pos")).getValue());
- posTag.set(0, new DoubleTag("x", x));
- posTag.set(1, new DoubleTag("y", 120));
- posTag.set(2, new DoubleTag("z", y));
- rootMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
- root = new CompoundTag("Data", rootMap);
- NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
- outStream.writeTag(root);
- outStream.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- } else {
- out = file;
- backupFile(out);
- try {
- NBTInputStream inStream = new NBTInputStream(new FileInputStream(out));
- CompoundTag root = (CompoundTag)(((CompoundTag)inStream.readTag()).getValue().get("Data"));
- inStream.close();
-
- HashMap rootMap = new HashMap(root.getValue());
- HashMap playerMap = new HashMap(((CompoundTag)rootMap.get("Player")).getValue());
- ArrayList posTag = new ArrayList(((ListTag)playerMap.get("Pos")).getValue());
- posTag.set(0, new DoubleTag("x", x));
- posTag.set(1, new DoubleTag("y", 120));
- posTag.set(2, new DoubleTag("z", y));
- rootMap.put("Player", new CompoundTag("Player", playerMap));
- playerMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
- root = new CompoundTag("Data", rootMap);
- HashMap base = new HashMap();
- base.put("Data", root);
- root = new CompoundTag("Base", base);
- NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
- outStream.writeTag(root);
- outStream.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private void backupFile(File inputFile) {
- File backupFolder = new File(inputFile.getParentFile() + "/amidst_backup/");
- if (!backupFolder.exists())
- backupFolder.mkdir();
-
- File outputFile = new File(backupFolder + "/" + inputFile.getName());
- if (!back.contains(outputFile.toString())) {
- try {
- FileReader in = new FileReader(inputFile);
- FileWriter out = new FileWriter(outputFile);
- int c;
-
- while ((c = in.read()) != -1)
- out.write(c);
-
- in.close();
- out.close();
- back.add(outputFile.toString());
- } catch (Exception ignored) {}
- }
- }
-
- public SaveLoader(File f) {
- file = f;
- players = new ArrayList();
- back = new ArrayList();
- try {
- NBTInputStream inStream = new NBTInputStream(new FileInputStream(f));
- CompoundTag root = (CompoundTag) ((CompoundTag)inStream.readTag()).getValue().get("Data");
- inStream.close();
- seed = (Long)(root.getValue().get("RandomSeed").getValue());
- if (root.getValue().get("generatorName") != null) {
- genType = Type.fromMixedCase((String)(root.getValue().get("generatorName").getValue()));
-
- if (genType == Type.CUSTOMIZED)
- generatorOptions = (String)root.getValue().get("generatorOptions").getValue();
- }
- CompoundTag playerTag = (CompoundTag)root.getValue().get("Player");
-
- File playersFolder = new File(f.getParent(), "players");
- boolean multi = (playersFolder.exists() && (playersFolder.listFiles().length > 0));
-
- if (multi)
- Log.i("Multiplayer map detected.");
- else
- Log.i("Singleplayer map detected.");
-
- if (!multi) {
- addPlayer("Player", playerTag);
- } else {
- File[] listing = playersFolder.listFiles();
- for (int i = 0; i < (listing != null ? listing.length : 0); i++) {
- if (listing[i].isFile()) {
- NBTInputStream playerInputStream = new NBTInputStream(new FileInputStream(listing[i]));
- addPlayer(listing[i].getName().split("\\.")[0], (CompoundTag) ((CompoundTag)playerInputStream.readTag()));
- playerInputStream.close();
- }
- }
-
- }
- } catch (Exception e) {
- Util.showError(e);
- }
- }
-
- private void addPlayer(String name, CompoundTag ps) {
- List pos = ((ListTag)(ps.getValue().get("Pos"))).getValue();
- double x = (Double)pos.get(0).getValue();
- double z = (Double)pos.get(2).getValue();
- players.add(new MapObjectPlayer(name, (int) x, (int) z));
- }
-
- public String getGeneratorOptions() {
- return generatorOptions;
- }
-}
diff --git a/src/MoF/SkinManager.java b/src/MoF/SkinManager.java
deleted file mode 100644
index 7e5c25ef1..000000000
--- a/src/MoF/SkinManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package MoF;
-
-import amidst.map.MapObjectPlayer;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Stack;
-
-import javax.imageio.ImageIO;
-
-public class SkinManager extends Thread {
- private Stack players;
- public boolean active;
- public SkinManager() {
- players = new Stack();
- active = true;
- }
-
- public void addPlayer(MapObjectPlayer p) {
- players.push(p);
- }
- public void run() {
- while (this.active) {
- try {
- if (players.isEmpty()) {
- Thread.sleep(50L);
- } else {
- MapObjectPlayer p = players.pop();
- try {
- URL url = new URL("http://s3.amazonaws.com/MinecraftSkins/" + p.getName() + ".png");
- BufferedImage img = ImageIO.read(url);
- BufferedImage pimg = new BufferedImage(20,20,BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = pimg.createGraphics();
- g2d.setColor(Color.black);
- g2d.fillRect(0, 0, 20, 20);
- g2d.drawImage(img, 2, 2, 18, 18, 8, 8, 16, 16, null);
- g2d.dispose();
- img.flush();
- p.setMarker(pimg);
- Thread.sleep(20L);
- } catch (MalformedURLException e2) {
- } catch (IOException e) {
- }
- }
- } catch (InterruptedException e) {
-
- }
- }
- if (!this.active) {
- dispose();
- }
- }
-
- public void dispose() {
- players.clear();
- players = null;
- }
-}
diff --git a/src/MoF/UpdateManager.java b/src/MoF/UpdateManager.java
deleted file mode 100644
index f3f959e97..000000000
--- a/src/MoF/UpdateManager.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package MoF;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-import amidst.Amidst;
-import org.w3c.dom.*;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-public class UpdateManager extends Thread {
- public static final String updateURL = "https://sites.google.com/site/mothfinder/update.xml";
- public static final String updateUnstableURL = "https://sites.google.com/site/mothfinder/update_unstable.xml";
- private JFrame window;
- private boolean silent;
- public UpdateManager(JFrame window) {
- this.setWindow(window);
- silent = false;
- }
- public UpdateManager(JFrame window, boolean silence) {
- this.setWindow(window);
- silent = silence;
- }
- public void run() {
-
- try {
- URL url = new URL(updateURL);
- DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- Document doc = docBuilder.parse(url.openStream());
-
- doc.getDocumentElement().normalize();
- NodeList vlist = doc.getDocumentElement().getElementsByTagName("version");
- NodeList version = vlist.item(0).getChildNodes();
-
- int major = 0;
- int minor = 0;
- String updateURL = doc.getFirstChild().getAttributes().item(0).getNodeValue();
- for (int i = 0; i < version.getLength(); i++) {
- Node v = version.item(i);
- if (v.getNodeType() == Node.ELEMENT_NODE) {
- if (v.getNodeName().toLowerCase().equals("major")) {
- major = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
- } else if (v.getNodeName().toLowerCase().equals("minor")) {
- minor = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
- }
- }
- }
- int n = JOptionPane.NO_OPTION;
-
- if (major > Amidst.version_major) {
- n = JOptionPane.showConfirmDialog(
- window,
- "A new version was found. Would you like to update?",
- "Update Found",
- JOptionPane.YES_NO_OPTION);
- } else if ((major == Amidst.version_major) && (minor > Amidst.version_minor)) {
- n = JOptionPane.showConfirmDialog(
- window,
- "A minor revision was found. Update?",
- "Update Found",
- JOptionPane.YES_NO_OPTION);
- } else if (!silent)
- JOptionPane.showMessageDialog(window, "There are no new updates.");
-
- if (n==0) {
- if( !java.awt.Desktop.isDesktopSupported()) {
- JOptionPane.showMessageDialog(window, "Error unable to open browser.");
- }
-
- java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
-
- if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
- JOptionPane.showMessageDialog(window, "Error unable to open browser page.");
- }
- java.net.URI uri = new java.net.URI(updateURL);
- desktop.browse(uri);
- }
- } catch (MalformedURLException e1) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error connecting to update server: Malformed URL.");
- } catch (IOException e1) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error reading update data.");
- } catch (ParserConfigurationException e) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error with XML parser configuration.");
- } catch (SAXException e) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error parsing update file.");
- } catch (NumberFormatException e) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error parsing version numbers.");
- } catch (NullPointerException e) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error \"NullPointerException\" in update.");
- } catch (URISyntaxException e) {
- if (!silent)
- JOptionPane.showMessageDialog(window, "Error parsing update URL.");
- }
-
- }
- public JFrame getWindow() {
- return window;
- }
- public void setWindow(JFrame window) {
- this.window = window;
- }
-}
diff --git a/src/amidst/Amidst.java b/src/amidst/Amidst.java
deleted file mode 100644
index 7e2ec33c7..000000000
--- a/src/amidst/Amidst.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package amidst;
-
-import java.awt.Image;
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.kohsuke.args4j.CmdLineException;
-import org.kohsuke.args4j.CmdLineParser;
-
-import com.google.gson.Gson;
-
-import MoF.FinderWindow;
-import MoF.Google;
-import amidst.gui.version.VersionSelectWindow;
-import amidst.logging.FileLogger;
-import amidst.logging.Log;
-import amidst.minecraft.Minecraft;
-import amidst.minecraft.MinecraftUtil;
-import amidst.preferences.BiomeColorProfile;
-import amidst.resources.ResourceLoader;
-
-public class Amidst {
- public final static int version_major = 3;
- public final static int version_minor = 7;
- public final static String versionOffset = "";
- public static Image icon = ResourceLoader.getImage("icon.png");
- public static final Gson gson = new Gson();
-
-
- public static void main(String args[]) {
- Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
- @Override
- public void uncaughtException(Thread thread, Throwable e) {
- Log.crash(e, "Amidst has encounted an uncaught exception on thread: " + thread);
- }
- });
- CmdLineParser parser = new CmdLineParser(Options.instance);
- try {
- parser.parseArgument(args);
- } catch (CmdLineException e) {
- Log.w("There was an issue parsing command line options.");
- e.printStackTrace();
- }
- Util.setMinecraftDirectory();
- Util.setMinecraftLibraries();
-
- if (Options.instance.logPath != null)
- Log.addListener("file", new FileLogger(new File(Options.instance.logPath)));
-
-
- if (!isOSX()) { Util.setLookAndFeel(); }
- Google.startTracking();
- Google.track("Run");
- System.setProperty("sun.java2d.opengl","True");
- System.setProperty("sun.java2d.accthreshold", "0");
- BiomeColorProfile.scan();
-
- if (Options.instance.minecraftJar != null)
- {
- try {
- Util.setProfileDirectory(Options.instance.minecraftPath);
- MinecraftUtil.setBiomeInterface(new Minecraft(new File(Options.instance.minecraftJar)).createInterface());
- new FinderWindow();
- } catch (MalformedURLException e) {
- Log.crash(e, "MalformedURLException on Minecraft load.");
- }
- }
- else
- {
- new VersionSelectWindow();
- }
- }
-
- public static boolean isOSX() {
- String osName = System.getProperty("os.name");
- return osName.contains("OS X");
- }
-
- public static String version() {
- if (MinecraftUtil.hasInterface())
- return version_major + "." + version_minor + versionOffset + " [Using Minecraft version: " + MinecraftUtil.getVersion() + "]";
- return version_major + "." + version_minor + versionOffset;
- }
-
-}
diff --git a/src/amidst/Options.java b/src/amidst/Options.java
deleted file mode 100644
index 834e8c284..000000000
--- a/src/amidst/Options.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package amidst;
-
-import amidst.preferences.BiomeColorProfile;
-import amidst.preferences.BooleanPrefModel;
-import amidst.preferences.FilePrefModel;
-import amidst.preferences.SelectPrefModel;
-import amidst.preferences.StringPreference;
-
-import java.io.File;
-import java.util.prefs.Preferences;
-
-import org.kohsuke.args4j.Option;
-
-/** Currently selected options that change AMIDST’s behavior
- */
-public enum Options {
- instance;
-
- //per-run preferences. TODO: store elsewhere?
- public long seed;
- public String seedText;
-
- //permanent preferences
- public final FilePrefModel jar;
- public final BooleanPrefModel showSlimeChunks;
- public final BooleanPrefModel showGrid;
- public final BooleanPrefModel showNetherFortresses;
- public final BooleanPrefModel showTemples, showPlayers, showStrongholds, showVillages, showOceanMonuments, showSpawn;
- public final BooleanPrefModel mapFlicking, mapFading, showFPS, showScale, showDebug;
- public final BooleanPrefModel updateToUnstable;
- public final BooleanPrefModel maxZoom;
-
- public final StringPreference lastProfile;
-
- public final SelectPrefModel worldType;
- public BiomeColorProfile biomeColorProfile;
- private Preferences preferences;
-
- //CLI
- @Option (name="-history", usage="Sets the path to seed history file.", metaVar="")
- public String historyPath;
-
- @Option (name="-log", usage="Sets the path to logging file.", metaVar="")
- public String logPath;
-
- @Option (name="-mcpath", usage="Sets the path to the .minecraft directory.", metaVar="")
- public String minecraftPath;
-
- @Option (name="-mcjar", usage="Sets the path to the minecraft .jar", metaVar="")
- public String minecraftJar;
-
- @Option (name="-mcjson", usage="Sets the path to the minecraft .json", metaVar="")
- public String minecraftJson;
-
- @Option (name="-mclibs", usage="Sets the path to the libraries/ folder", metaVar="")
- public String minecraftLibraries;
-
- private Options() {
- seed = 0L;
- seedText = null;
-
-
- Preferences pref = Preferences.userNodeForPackage(Amidst.class);
- preferences = pref;
- jar = new FilePrefModel( pref, "jar", new File(Util.minecraftDirectory, "bin/minecraft.jar"));
- showSlimeChunks = new BooleanPrefModel(pref, "slimeChunks", false);
- showGrid = new BooleanPrefModel(pref, "grid", false);
- showNetherFortresses = new BooleanPrefModel(pref, "netherFortressIcons", false);
- mapFlicking = new BooleanPrefModel(pref, "mapFlicking", true);
- mapFading = new BooleanPrefModel(pref, "mapFading", true);
- maxZoom = new BooleanPrefModel(pref, "maxZoom", true);
- showStrongholds = new BooleanPrefModel(pref, "strongholdIcons", true);
- showPlayers = new BooleanPrefModel(pref, "playerIcons", true);
- showTemples = new BooleanPrefModel(pref, "templeIcons", true);
- showVillages = new BooleanPrefModel(pref, "villageIcons", true);
- showOceanMonuments = new BooleanPrefModel(pref, "oceanMonumentIcons", true);
- showSpawn = new BooleanPrefModel(pref, "spawnIcon", true);
- showFPS = new BooleanPrefModel(pref, "showFPS", true);
- showScale = new BooleanPrefModel(pref, "showScale", true);
- showDebug = new BooleanPrefModel(pref, "showDebug", false);
- updateToUnstable = new BooleanPrefModel(pref, "updateToUnstable", false);
- lastProfile = new StringPreference(pref, "profile", null);
- biomeColorProfile = new BiomeColorProfile();
- worldType = new SelectPrefModel( pref, "worldType", "Prompt each time", new String[] { "Prompt each time", "Default", "Flat", "Large Biomes", "Amplified" });
- biomeColorProfile.fillColorArray();
-
-
- }
-
- public Preferences getPreferences() {
- return preferences;
- }
-
- public File getJar() {
- return jar.get();
- }
-
- public String getSeedMessage() {
- if (seedText == null)
- return "Seed: " + seed;
- return "Seed: \"" + seedText + "\" (" + seed + ")";
- }
-}
diff --git a/src/amidst/Util.java b/src/amidst/Util.java
deleted file mode 100644
index befc06cb9..000000000
--- a/src/amidst/Util.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package amidst;
-
-import javax.swing.*;
-
-import amidst.logging.Log;
-
-import com.google.gson.JsonIOException;
-import com.google.gson.JsonSyntaxException;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-
-public class Util {
- /** Shows an error message for an exception
- * @param e the exception for which the stachtrace is to be shown
- */
- public static final String REMOTE_VERSION_LIST_URL = "https://s3.amazonaws.com/Minecraft.Download/versions/versions.json";
- private static String osString;
-
- public static String getOs() {
- if (osString == null) {
- String os = System.getProperty("os.name").toLowerCase();
- if (os.contains("win"))
- osString = "windows";
- else if (os.contains("mac"))
- osString = "osx";
- else
- osString = "linux";
- }
- return osString;
- }
-
- public static void showError(Exception e) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- e.printStackTrace(ps);
- String trace = baos.toString();
-
- e.printStackTrace();
-
- JOptionPane.showMessageDialog(
- null,
- trace,
- e.toString(),
- JOptionPane.ERROR_MESSAGE);
- }
-
- public static void setLookAndFeel() {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- Log.printTraceStack(e);
- }
- }
-
- public static File minecraftDirectory;
- public static void setMinecraftDirectory() {
- if (Options.instance.minecraftPath != null) {
- minecraftDirectory = new File(Options.instance.minecraftPath);
- if (minecraftDirectory.exists() && minecraftDirectory.isDirectory())
- return;
- Log.w("Unable to set Minecraft directory to: " + minecraftDirectory + " as that location does not exist or is not a folder.");
- }
- File mcDir = null;
- File homeDirectory = new File(System.getProperty("user.home", "."));
- String os = System.getProperty("os.name").toLowerCase();
-
- if (os.contains("win")) {
- File appData = new File(System.getenv("APPDATA"));
- if (appData.isDirectory())
- mcDir = new File(appData, ".minecraft");
- } else if (os.contains("mac")) {
- mcDir = new File(homeDirectory, "Library/Application Support/minecraft");
- }
- minecraftDirectory = (mcDir != null) ? mcDir : new File(homeDirectory, ".minecraft");
- }
-
- public static File minecraftLibraries;
- public static void setMinecraftLibraries() {
- minecraftLibraries = (Options.instance.minecraftLibraries == null) ? new File(minecraftDirectory, "libraries") : new File(Options.instance.minecraftLibraries);
- }
-
- public static File profileDirectory;
- public static void setProfileDirectory(String gameDir) {
- if (gameDir != null && !gameDir.isEmpty()) {
- profileDirectory = new File(gameDir);
- if (profileDirectory.exists() && profileDirectory.isDirectory())
- return;
- Log.w("Unable to set Profile directory to: " + profileDirectory + " as that location does not exist or is not a folder.");
- }
- profileDirectory = null;
- }
-
- public static int makeColor(int r, int g, int b) {
- int color = 0xFF000000;
- color |= 0xFF0000 & (r << 16);
- color |= 0xFF00 & (g << 8);
- color |= 0xFF & b;
- return color;
- }
- public static int mcColor(int color) {
- return 0xFF000000 | color;
- }
-
- private static final int TEMP_DIR_ATTEMPTS = 1000;
-
- /** Guava's method, moved here to avoid a huge dependency
- * TODO: maybe switch to JDK 7 to use its java.nio.file.Files#createTempDirectory()
- */
- public static File createTempDir() {
- return getTempDir(System.currentTimeMillis() + "");
- }
-
- public static File getTempDir(String name) {
- File baseDir = new File(System.getProperty("java.io.tmpdir"));
- String baseName = name + "-";
- for (int counter=0; counter T readObject(BufferedReader reader, final Class clazz) throws JsonIOException, JsonSyntaxException {
- return Amidst.gson.fromJson(reader, clazz);
- }
-
- public static T readObject(File path, final Class clazz) throws IOException, JsonIOException, JsonSyntaxException {
- final BufferedReader reader = new BufferedReader(new FileReader(path));
- T object = Amidst.gson.fromJson(reader, clazz);
- reader.close();
- return object;
- }
-
- public static T readObject(String path, final Class clazz) throws IOException {
- return readObject(new File(path), clazz);
- }
-
- public static int deselectColor(int color) {
- int r = (color & 0x00FF0000) >> 16;
- int g = (color & 0x0000FF00) >> 8;
- int b = (color & 0x000000FF);
-
- int average = (r + g + b);
- r = (r + average) / 30;
- g = (g + average) / 30;
- b = (b + average) / 30;
- return makeColor(r, g, b);
- }
-
- public static int lightenColor(int color, int brightness) {
- int r = (color & 0x00FF0000) >> 16;
- int g = (color & 0x0000FF00) >> 8;
- int b = (color & 0x000000FF);
-
- r += brightness;
- g += brightness;
- b += brightness;
-
- if (r > 0xFF) r = 0xFF;
- if (g > 0xFF) g = 0xFF;
- if (b > 0xFF) b = 0xFF;
-
- return makeColor(r, g, b);
- }
-
- public static int greyScale(int color) {
- int r = (color & 0x00FF0000) >> 16;
- int g = (color & 0x0000FF00) >> 8;
- int b = (color & 0x000000FF);
- int average = (r + g + b) / 3;
- return makeColor(average, average, average);
- }
-}
diff --git a/src/amidst/bytedata/ByteClass.java b/src/amidst/bytedata/ByteClass.java
deleted file mode 100644
index d06643e47..000000000
--- a/src/amidst/bytedata/ByteClass.java
+++ /dev/null
@@ -1,357 +0,0 @@
-package amidst.bytedata;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ByteClass {
- public static class AccessFlags {
- public static int
- PUBLIC = 0x01,
- PRIVATE = 0x02,
- PROTECTED = 0x04,
- STATIC = 0x08,
- FINAL = 0x10,
- VOLATILE = 0x40,
- TRANSIENT = 0x80;
- }
- /*ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its package.
-ACC_PRIVATE 0x0002 Declared private; usable only within the defining class.
-ACC_PROTECTED 0x0004 Declared protected; may be accessed within subclasses.
-ACC_STATIC 0x0008 Declared static.
-ACC_FINAL 0x0010 Declared final; no further assignment after initialization.
-ACC_VOLATILE 0x0040 Declared volatile; cannot be cached.
-ACC_TRANSIENT 0x0080 Declared transient; not written or read by a persistent object manager.
-*/
- public class Field {
- public int accessFlags;
- public Field() { }
- };
-
- private byte[] data;
- private boolean isValidClass;
- public int minorVersion;
- public int majorVersion;
- private int cpSize;
- private DataInputStream stream;
- private ClassConstant>[] constants;
- private int[] constantTypes;
- private String name;
- public int accessFlags;
-
- private Vector> stringIndices;
- private Vector methodIndices;
- private Vector methods, properties, constructors;
- private Vector floatConstants;
- private Vector longConstants;
- private Vector utfConstants;
-
- public Field[] fields;
- public int methodCount; // (Method count includes constructors)
- public int constructorCount;
-
- public ByteClass(String name, byte[] classData) {
- this.name = name;
- methods = new Vector();
- properties = new Vector();
- constructors = new Vector();
- floatConstants = new Vector();
- longConstants = new Vector();
- methodIndices = new Vector();
- stringIndices = new Vector>();
- utfConstants = new Vector();
-
- try {
- data = classData;
- stream = new DataInputStream(new ByteArrayInputStream(data));
- isValidClass = stream.readInt() == 0xCAFEBABE;
- if (isValidClass) {
- minorVersion = stream.readUnsignedShort();
- majorVersion = stream.readUnsignedShort();
- cpSize = stream.readUnsignedShort(); cpSize--;
- constants = new ClassConstant>[cpSize];
- constantTypes = new int[cpSize];
- long offset = 10;
- for (int q = 0; q < cpSize; q++) {
- byte tag = stream.readByte();
- offset++;
- constantTypes[q] = tag;
- switch (tag) {
- case 1: //String
- int len = stream.readUnsignedShort();
- String strVal = "";
- for (int i = 0; i < len; i++)
- strVal += (char)stream.readByte();
- constants[q] = new ClassConstant(tag, offset, strVal);
- utfConstants.add(strVal);
- offset += 2 + len;
- break;
- case 3: //Int
- constants[q] = new ClassConstant(tag, offset, stream.readInt());
- offset += 4;
- break;
- case 4: //Float
- float cFloat = stream.readFloat();
- constants[q] = new ClassConstant(tag, offset, cFloat);
- floatConstants.add(cFloat);
- offset += 4;
- break;
- case 5: //Long
- long cLong = stream.readLong();
- constants[q] = new ClassConstant(tag, offset, cLong);
- longConstants.add(cLong);
- offset += 8;
- q++;
- break;
- case 6: //Double
- constants[q] = new ClassConstant(tag, offset, stream.readDouble());
- offset += 8;
- q++;
- break;
- case 7: //Class reference
- constants[q] = new ClassConstant(tag, offset, stream.readUnsignedShort());
- offset += 2;
- break;
- case 8: //String reference
- ClassConstant strRef = new ClassConstant(tag, offset, stream.readUnsignedShort());
- constants[q] = strRef;
- stringIndices.add(strRef);
- offset += 2;
- break;
- case 9: //Field reference
- constants[q] = new ClassConstant(tag, offset, new ReferenceIndex(stream.readUnsignedShort(), stream.readUnsignedShort()));
- offset += 4;
- break;
- case 10: //Method reference
- constants[q] = new ClassConstant(tag, offset, new ReferenceIndex(stream.readUnsignedShort(), stream.readUnsignedShort()));
-
- offset += 4;
- break;
- case 11: //Interface method reference
- constants[q] = new ClassConstant(tag, offset, new ReferenceIndex(stream.readUnsignedShort(), stream.readUnsignedShort()));
- offset += 4;
- break;
- case 12: //Name and type descriptor
- constants[q] = new ClassConstant(tag, offset, new ReferenceIndex(stream.readUnsignedShort(), stream.readUnsignedShort()));
- offset += 4;
- break;
- }
- }
-
- //Access Flags
- accessFlags = stream.readUnsignedShort();
-
-
- //This class
- stream.skip(2);
-
- //Super class
- stream.skip(2);
-
- //Interfaces
- int iCount = stream.readUnsignedShort();
- stream.skip(iCount*2);
-
- //Fields
- fields = new Field[stream.readUnsignedShort()];
- for (int i = 0; i < fields.length; i++) {
- fields[i] = new Field();
- fields[i].accessFlags = stream.readUnsignedShort();
- stream.skip(4);
- int attributeInfoCount = stream.readUnsignedShort();
- for (int q = 0; q < attributeInfoCount; q++) {
- stream.skip(2);
- int attributeCount = stream.readInt();
- for (int z = 0; z < attributeCount; z++)
- stream.skip(1);
- }
- }
-
- //Methods
- methodCount = stream.readUnsignedShort();
- for (int i = 0; i < methodCount; i++) {
- stream.skip(2);
- int nameIndex = stream.readUnsignedShort();
- methodIndices.add(new ReferenceIndex(nameIndex, stream.readUnsignedShort()));
-
- if (((String)constants[nameIndex - 1].get()).contains(""))
- constructorCount++;
-
- int attributeInfoCount = stream.readUnsignedShort();
- for (int q = 0; q < attributeInfoCount; q++) {
- stream.skip(2);
- int attributeCount = stream.readInt();
- for (int z = 0; z < attributeCount; z++)
- stream.skip(1);
- }
- }
-
- //Attributes
-
- stream.close();
-
-
- }
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(0);
- }
- }
- public boolean searchForString(String str) {
- for (ClassConstant i : stringIndices) {
- if (((String)constants[i.get() - 1].get()).contains(str))
- return true;
- }
- return false;
- }
-
- public boolean searchForUtf(String str) {
- for (String text : utfConstants) {
- if (text.equals(str))
- return true;
- }
- return false;
- }
-
- public byte[] getData() {
-
- return data;
- }
-
- @Override
- public String toString() {
- return "[ByteClass " + name + "]";
- }
- public String searchByReturnType(String type) {
- for (ReferenceIndex ref : methodIndices) {
- String refType = (String)constants[ref.val2-1].get();
- //Log.i("L" + type + " = " + refType);
- if (("L" + type + ";").equals(refType.substring(refType.indexOf(')') + 1)))
- return (String)constants[ref.val1-1].get();
- }
- return null;
- }
- public void addMethod(String method, String name) {
- methods.add(new String[] {method, name});
- }
- public String getClassName() {
- return name;
- }
- public Vector getMethods() {
- return methods;
- }
- public void addProperty(String property, String name) {
- properties.add(new String[] { property, name});
- }
- public Vector getProperties() {
- return properties;
- }
- public void addConstructor(String constructor, String name) {
- constructors.add(new String[] {constructor, name});
- }
- public Vector getConstructors() {
- return constructors;
- }
- public boolean isInterface() {
- return (accessFlags & 0x0200) == 0x0200;
- }
- public boolean isFinal() {
- return (accessFlags & 0x0010) == 0x0010;
- }
- public String getArguementsForConstructor(int ID) {
- int i = 0;
- for (ReferenceIndex ref : methodIndices) {
- String name = (String)constants[ref.val1-1].get();
- if (name.equals("")) {
- if (i==ID) {
- String args = (String)constants[ref.val2-1].get();
- return toArguementString(args);
- }
- i++;
- }
- }
- return "";
- }
- public static String toArguementString(String eArgs) {
- String[] args = readArguements(eArgs);
- String out = "(";
- for (int i = 0; i < args.length ;i++) {
- out += args[i] + ((i == args.length - 1)?"":",");
- }
- out += ")";
- return out;
- }
- public static String[] readArguements(String eArgs) {
- //Log.i(eArgs);
- String args = eArgs.substring(1);
- String[] argSplit = args.split("\\)");
-
- args = argSplit[0];
- Stack argStack = new Stack();
- Pattern argRegex = Pattern.compile("([\\[]+)?([BCDFIJSZ]|L[^;]+)");
- Pattern objectRegex = Pattern.compile("^([\\[]+)?[LBCDFIJSZ]");
- Matcher matcher = argRegex.matcher(args);
- while (matcher.find()) {
- String arg =args.substring(matcher.start(), matcher.end());
- Matcher objectMatcher = objectRegex.matcher(arg);
- if (objectMatcher.find()) {
- String replaceWith = "";
- switch (arg.charAt(objectMatcher.end()-1)) {
- case 'B':
- replaceWith = "byte";
- break;
- case 'C':
- replaceWith = "char";
- break;
- case 'D':
- replaceWith = "double";
- break;
- case 'F':
- replaceWith = "float";
- break;
- case 'I':
- replaceWith = "int";
- break;
- case 'J':
- replaceWith = "long";
- break;
- case 'S':
- replaceWith = "short";
- break;
- case 'Z':
- replaceWith = "boolean";
- break;
- }
- arg = arg.substring(0, Math.max(0, objectMatcher.end()-1)) +
- replaceWith +
- arg.substring(Math.min(objectMatcher.end(), arg.length()));
-
- }
- argStack.push(arg);
- }
- String[] argArray = new String[argStack.size()];
- for (int i = 0; i < argArray.length; i++) {
- argArray[argArray.length - 1 - i] = argStack.pop();
- }
- return argArray;
- }
- public boolean searchForFloat(float f) {
- for (Float cFloat : floatConstants) {
- if (cFloat.floatValue() == f) {
- return true;
- }
- }
- return false;
- }
- public boolean searchForLong(long l) {
- for (Long cLong : longConstants) {
- if (cLong.longValue() == l) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/src/amidst/bytedata/CCByteMatch.java b/src/amidst/bytedata/CCByteMatch.java
deleted file mode 100644
index f666ebcc8..000000000
--- a/src/amidst/bytedata/CCByteMatch.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCByteMatch extends ClassChecker {
- private byte[] checkData;
- private int dataOffset;
- public CCByteMatch(String name, byte[] data, int offset) { // FIXME : Dead class
- super(name);
- checkData = data;
- dataOffset = offset;
- }
- public boolean check(ByteClass bClass) {
- byte[] data = bClass.getData();
-
- if (data.length < dataOffset + checkData.length)
- return false;
-
- for (int i = 0; i < checkData.length; i++) {
- if (checkData[i] != data[i + dataOffset])
- return false;
- }
- return true;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/src/amidst/bytedata/CCByteSearch.java b/src/amidst/bytedata/CCByteSearch.java
deleted file mode 100644
index 72ec5616f..000000000
--- a/src/amidst/bytedata/CCByteSearch.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCByteSearch extends ClassChecker {
- private byte[] checkData;
- public CCByteSearch(String publicName, byte[] data) {
- super(publicName);
- checkData = data;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- byte[] data = bClass.getData();
-
- for (int i = 0; i < data.length + 1 - checkData.length; i++) {
- boolean searching = true;
- int sIndex = 0;
- while (searching) {
- if (data[i + sIndex] != checkData[sIndex])
- searching = false;
- sIndex++;
- if (searching && (sIndex == checkData.length)) {
- isComplete = true;
- m.registerClass(publicName, bClass);
- return;
- }
- }
- }
- }
-}
diff --git a/src/amidst/bytedata/CCConstructorPreset.java b/src/amidst/bytedata/CCConstructorPreset.java
deleted file mode 100644
index 67a8c790e..000000000
--- a/src/amidst/bytedata/CCConstructorPreset.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCConstructorPreset extends ClassChecker {
- private String[] constructor;
- private boolean multiple;
- private int ID;
- private String name;
- public CCConstructorPreset(String name, String... constructor) {
- super(name);
- multiple = true;
- this.constructor = constructor;
- }
- public CCConstructorPreset(String name, int i, String construct) {
- super(name);
- multiple = false;
- ID = i;
- this.name = construct;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- ByteClass clazz = mc.getByteClass(publicName);
- if (multiple) {
- for (int i = 0; i < constructor.length; i += 2) {
- clazz.addConstructor(constructor[i], constructor[i+1]);
- }
- } else {
- String args = clazz.getArguementsForConstructor(ID);
- clazz.addConstructor(args, name);
- }
- isComplete = true;
- }
-}
diff --git a/src/amidst/bytedata/CCFloatMatch.java b/src/amidst/bytedata/CCFloatMatch.java
deleted file mode 100644
index c6335a5fd..000000000
--- a/src/amidst/bytedata/CCFloatMatch.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCFloatMatch extends ClassChecker {
- private float[] checkData;
- public CCFloatMatch(String name, float... data) {
- super(name);
- checkData = data;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- boolean isMatch = true;
- for (int i = 0; i < checkData.length; i++) {
- isMatch &= bClass.searchForFloat(checkData[i]);
- }
- if (isMatch) {
- m.registerClass(publicName, bClass);
- isComplete = true;
- }
- }
-}
diff --git a/src/amidst/bytedata/CCLongMatch.java b/src/amidst/bytedata/CCLongMatch.java
deleted file mode 100644
index 6effa0329..000000000
--- a/src/amidst/bytedata/CCLongMatch.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCLongMatch extends ClassChecker {
- private long[] checkData;
- public CCLongMatch(String name, long... data) {
- super(name);
- checkData = data;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- boolean isMatch = true;
- for (int i = 0; i < checkData.length; i++) {
- isMatch &= bClass.searchForLong(checkData[i]);
- }
- if (isMatch) {
- m.registerClass(publicName, bClass);
- isComplete = true;
- }
- }
-}
diff --git a/src/amidst/bytedata/CCMethodByReturnType.java b/src/amidst/bytedata/CCMethodByReturnType.java
deleted file mode 100644
index 9c4254af1..000000000
--- a/src/amidst/bytedata/CCMethodByReturnType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCMethodByReturnType extends ClassChecker {
- private String name, className, returnType, param;
- public CCMethodByReturnType(String className, String returnType, String param, String name) {
- this.name = name;
- this.className = className;
- this.param = param;
- this.returnType = returnType;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- ByteClass clazz = mc.getByteClass(className);
- String internalName = mc.getByteClass(returnType).getClassName();
- clazz.addMethod(clazz.searchByReturnType(internalName) + param, name);
- isComplete = true;
- }
-}
diff --git a/src/amidst/bytedata/CCMethodPreset.java b/src/amidst/bytedata/CCMethodPreset.java
deleted file mode 100644
index cebc9bdde..000000000
--- a/src/amidst/bytedata/CCMethodPreset.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCMethodPreset extends ClassChecker {
- private String[] methods;
- public CCMethodPreset(String name, String... methods) {
- super(name);
- this.methods = methods;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- ByteClass clazz = mc.getByteClass(publicName);
- for (int i = 0; i < methods.length; i += 2) {
- clazz.addMethod(methods[i], methods[i+1]);
- }
- isComplete = true;
- }
-}
diff --git a/src/amidst/bytedata/CCMulti.java b/src/amidst/bytedata/CCMulti.java
deleted file mode 100644
index 4af19151e..000000000
--- a/src/amidst/bytedata/CCMulti.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCMulti extends ClassChecker {
- private ClassChecker[] checks;
- public CCMulti(ClassChecker... checks) {
- super(checks[0].getName());
- this.checks = checks;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- boolean complete = true;
- for (int i = 0; i < checks.length; i++) {
- if (!checks[i].isComplete)
- checks[i].check(mc, bClass);
- complete &= checks[i].isComplete;
- }
- isComplete = complete;
- }
-
-}
diff --git a/src/amidst/bytedata/CCPropertyPreset.java b/src/amidst/bytedata/CCPropertyPreset.java
deleted file mode 100644
index f1179763b..000000000
--- a/src/amidst/bytedata/CCPropertyPreset.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCPropertyPreset extends ClassChecker {
- private String[] properties;
- public CCPropertyPreset(String name, String... properties) {
- super(name);
- this.properties = properties;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- ByteClass clazz = mc.getByteClass(publicName);
- for (int i = 0; i < properties.length; i += 2) {
- clazz.addProperty(properties[i], properties[i+1]);
- }
- isComplete = true;
- }
-}
\ No newline at end of file
diff --git a/src/amidst/bytedata/CCRequire.java b/src/amidst/bytedata/CCRequire.java
deleted file mode 100644
index 695593572..000000000
--- a/src/amidst/bytedata/CCRequire.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCRequire extends ClassChecker {
- private ClassChecker checker;
- private String[] names;
- public CCRequire(ClassChecker cc, String... requiredNames) {
- super(cc.getName());
- checker = cc;
- names = requiredNames;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- for (int i = 0; i < names.length; i++) {
- if (mc.getByteClass(names[i]) == null) return;
- }
- checker.check(mc, bClass);
- isComplete = checker.isComplete;
- }
- @Override
- public String toString() {
- return "[Require " + names[0] + " " + checker + "]";
- }
-}
diff --git a/src/amidst/bytedata/CCRequireAccessFlags.java b/src/amidst/bytedata/CCRequireAccessFlags.java
deleted file mode 100644
index 242b05622..000000000
--- a/src/amidst/bytedata/CCRequireAccessFlags.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCRequireAccessFlags extends CCRequireSimple {
- private int flags;
- public CCRequireAccessFlags(ClassChecker checker, int flags) {
- super(checker);
- this.flags = flags;
- }
- @Override
- public boolean canPass(Minecraft mc, ByteClass bClass) {
- return bClass.accessFlags == flags;
- }
-}
diff --git a/src/amidst/bytedata/CCRequireFinal.java b/src/amidst/bytedata/CCRequireFinal.java
deleted file mode 100644
index 3641964ee..000000000
--- a/src/amidst/bytedata/CCRequireFinal.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCRequireFinal extends CCRequireSimple {
- public CCRequireFinal(ClassChecker checker) {
- super(checker);
- }
-
- @Override
- public boolean canPass(Minecraft mc, ByteClass bClass) {
- return bClass.isFinal();
- }
-}
diff --git a/src/amidst/bytedata/CCRequireInterface.java b/src/amidst/bytedata/CCRequireInterface.java
deleted file mode 100644
index 109cfc4ad..000000000
--- a/src/amidst/bytedata/CCRequireInterface.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCRequireInterface extends CCRequireSimple {
- public CCRequireInterface(ClassChecker checker) {
- super(checker);
- }
-
- @Override
- public boolean canPass(Minecraft mc, ByteClass bClass) {
- return bClass.isInterface();
- }
-}
diff --git a/src/amidst/bytedata/CCRequireSimple.java b/src/amidst/bytedata/CCRequireSimple.java
deleted file mode 100644
index 50e1e997e..000000000
--- a/src/amidst/bytedata/CCRequireSimple.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCRequireSimple extends ClassChecker {
- private ClassChecker checker;
- public CCRequireSimple(ClassChecker checker) {
- this.checker = checker;
- }
- public boolean canPass(Minecraft mc, ByteClass bClass) {
- return true;
- }
- @Override
- public void check(Minecraft mc, ByteClass bClass) {
- if (canPass(mc, bClass)) {
- checker.check(mc, bClass);
- }
- isComplete = checker.isComplete;
- }
-}
diff --git a/src/amidst/bytedata/CCStringMatch.java b/src/amidst/bytedata/CCStringMatch.java
deleted file mode 100644
index 5801ffc86..000000000
--- a/src/amidst/bytedata/CCStringMatch.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public class CCStringMatch extends ClassChecker {
- private String checkData;
- public CCStringMatch(String name, String data) {
- super(name);
- checkData = data;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- if (bClass.searchForString(checkData)) {
- m.registerClass(publicName, bClass);
- isComplete = true;
- }
- }
-
-}
diff --git a/src/amidst/bytedata/CCWildcardByteSearch.java b/src/amidst/bytedata/CCWildcardByteSearch.java
deleted file mode 100644
index b478d14c3..000000000
--- a/src/amidst/bytedata/CCWildcardByteSearch.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-public class CCWildcardByteSearch extends ClassChecker {
- private int[] checkData;
- public CCWildcardByteSearch(String publicName, int[] data) {
- super(publicName);
- checkData = data;
- }
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- byte[] data = bClass.getData();
-
- for (int i = 0; i < data.length + 1 - checkData.length; i++) {
- boolean searching = true;
- int sIndex = 0;
- while (searching) {
- if ((checkData[sIndex] != -1) && (data[i + sIndex] != (byte)checkData[sIndex]))
- searching = false;
- sIndex++;
- if (searching && (sIndex == checkData.length)) {
- isComplete = true;
- m.registerClass(publicName, bClass);
- return;
- }
- }
- }
- }
-}
diff --git a/src/amidst/bytedata/ClassChecker.java b/src/amidst/bytedata/ClassChecker.java
deleted file mode 100644
index 31baaf652..000000000
--- a/src/amidst/bytedata/ClassChecker.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package amidst.bytedata;
-
-import amidst.minecraft.Minecraft;
-
-
-public abstract class ClassChecker {
- protected String publicName;
- public boolean isComplete;
- public int passes = 10;
- public ClassChecker() {
- this.publicName = "unknown";
- }
- public ClassChecker(String publicName) {
- this.publicName = publicName;
- }
- public abstract void check(Minecraft m, ByteClass bClass);
-
- public String getName() {
- return publicName;
- }
- public ClassChecker passes(int p) {
- passes = p;
- return this;
- }
-}
diff --git a/src/amidst/bytedata/ClassConstant.java b/src/amidst/bytedata/ClassConstant.java
deleted file mode 100644
index dc1b0655e..000000000
--- a/src/amidst/bytedata/ClassConstant.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package amidst.bytedata;
-
-public class ClassConstant {
- private T value;
- private byte type;
- public ClassConstant(byte type, long offset, T value) {
- this.value = value;
- this.type = type;
- }
- public T get() {
- return value;
- }
- public int getTag() {
- return type;
- }
-}
diff --git a/src/amidst/bytedata/ReferenceIndex.java b/src/amidst/bytedata/ReferenceIndex.java
deleted file mode 100644
index ff0c5847a..000000000
--- a/src/amidst/bytedata/ReferenceIndex.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package amidst.bytedata;
-
-public class ReferenceIndex {
- public int val1, val2;
- public ReferenceIndex(int val1, int val2) {
- this.val1 = val1;
- this.val2 = val2;
- }
-}
diff --git a/src/amidst/gui/CrashDialog.java b/src/amidst/gui/CrashDialog.java
deleted file mode 100644
index 9d4684e67..000000000
--- a/src/amidst/gui/CrashDialog.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package amidst.gui;
-
-import java.awt.Color;
-import java.awt.Container;
-import java.awt.Font;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.border.LineBorder;
-
-import amidst.logging.LogRecorder;
-import net.miginfocom.swing.MigLayout;
-
-public class CrashDialog extends JFrame {
- public CrashDialog(String message) {
- super("AMIDST encountered an unexpected error.");
- Container contentPane = getContentPane();
- contentPane.setLayout(new MigLayout());
-
- add(new JLabel("AMIDST has crashed with the following message:"), "growx, pushx, wrap");
- add(new JLabel(message), "growx, pushx, wrap");
-
- JTextArea logText = new JTextArea(LogRecorder.getContents());
-
- JScrollPane scrollPane = new JScrollPane(logText);
- scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-
- logText.setFont(new Font("arial", Font.PLAIN, 10));
- scrollPane.setBorder(new LineBorder(Color.darkGray, 1));
-
- add(scrollPane,"grow, push");
-
- setSize(500, 400);
- setVisible(true);
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- dispose();
- System.exit(4);
- }
- });
-
- }
-}
diff --git a/src/amidst/gui/License.java b/src/amidst/gui/License.java
deleted file mode 100644
index a09ab47c0..000000000
--- a/src/amidst/gui/License.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package amidst.gui;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import amidst.logging.Log;
-import amidst.resources.ResourceLoader;
-
-public class License {
- private InputStream fileStream;
- private String name;
- private String contents;
- private boolean loaded = false;
-
- public License(String name, String path) {
- this.name = name;
- try {
- fileStream = ResourceLoader.getResourceStream(path);
- } catch (NullPointerException e) {
- Log.w("Error finding license for: " + name + " at path: " + path);
- e.printStackTrace();
- }
- }
-
- public String getName() {
- return name;
- }
-
- public void load() {
- if (loaded)
- return;
- BufferedReader fileReader = new BufferedReader(new InputStreamReader(fileStream));
- BufferedReader bufferedReader = new BufferedReader(fileReader);
- try {
- StringBuilder stringBuilder = new StringBuilder();
- String line = bufferedReader.readLine();
-
- while (line != null) {
- stringBuilder.append(line);
- stringBuilder.append('\n');
- line = bufferedReader.readLine();
- }
- contents = stringBuilder.toString();
- loaded = true;
- } catch (IOException e) {
- Log.w("Unable to read file: " + name + ".");
- e.printStackTrace();
- } finally {
- try {
- bufferedReader.close();
- } catch (IOException e) {
- Log.w("Unable to close BufferedReader for: " + name + ".");
- e.printStackTrace();
- }
- }
-
- }
-
- public String getContents() {
- return contents;
- }
-
- public boolean isLoaded() {
- return loaded;
- }
-
- @Override
- public String toString() {
- return name;
- }
-}
diff --git a/src/amidst/gui/LicenseWindow.java b/src/amidst/gui/LicenseWindow.java
deleted file mode 100644
index f382124d0..000000000
--- a/src/amidst/gui/LicenseWindow.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package amidst.gui;
-
-import java.awt.Color;
-import java.awt.Container;
-import java.util.ArrayList;
-
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.ListSelectionModel;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.border.LineBorder;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import amidst.Amidst;
-import net.miginfocom.swing.MigLayout;
-
-public class LicenseWindow extends JFrame {
- private static final long serialVersionUID = 3936119740592768287L;
- private ArrayList licenses = new ArrayList();
- private JList licenseList;
- private JTextArea licenseText = new JTextArea();
- public LicenseWindow() {
- super("Licenses");
- setIconImage(Amidst.icon);
- licenseText.setEditable(false);
- licenseText.setLineWrap(true);
- licenseText.setWrapStyleWord(true);
-
- licenses.add(new License("AMIDST", "licenses/amidst.txt"));
- licenses.add(new License("Args4j", "licenses/args4j.txt"));
- licenses.add(new License("Gson", "licenses/gson.txt"));
- licenses.add(new License("JGoogleAnalytics", "licenses/jgoogleanalytics.txt"));
- licenses.add(new License("JNBT", "licenses/jnbt.txt"));
- licenses.add(new License("Kryonet", "licenses/kryonet.txt"));
- licenses.add(new License("MiG Layout", "licenses/miglayout.txt"));
- licenses.add(new License("Rhino", "licenses/rhino.txt"));
- licenseList = new JList(licenses.toArray());
- licenseList.setBorder(new LineBorder(Color.darkGray, 1));
- Container contentPane = this.getContentPane();
- MigLayout layout = new MigLayout();
- contentPane.setLayout(layout);
- contentPane.add(licenseList, "w 100!, h 0:2400:2400");
- JScrollPane scrollPane = new JScrollPane(licenseText);
- scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- contentPane.add(scrollPane, "w 0:4800:4800, h 0:2400:2400");
- setSize(870, 550);
- setVisible(true);
- licenseList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- licenseList.addListSelectionListener(new ListSelectionListener() {
- @Override
- public void valueChanged(ListSelectionEvent e) {
- License license = (License)licenseList.getSelectedValue();
- license.load();
-
- if (license.isLoaded()) {
- licenseText.setText(license.getContents());
- licenseText.setCaretPosition(0);
- }
- }
- });
- licenseList.setSelectedIndex(0);
- }
-
- public void addLicense(License license) {
- licenses.add(license);
- licenseList.setListData(licenses.toArray());
- }
-}
diff --git a/src/amidst/gui/menu/AmidstMenu.java b/src/amidst/gui/menu/AmidstMenu.java
deleted file mode 100644
index 48a6425e7..000000000
--- a/src/amidst/gui/menu/AmidstMenu.java
+++ /dev/null
@@ -1,644 +0,0 @@
-package amidst.gui.menu;
-
-import MoF.*;
-import amidst.Options;
-import amidst.Util;
-import amidst.gui.LicenseWindow;
-import amidst.logging.Log;
-import amidst.map.MapObjectPlayer;
-import amidst.map.layers.StrongholdLayer;
-import amidst.minecraft.MinecraftUtil;
-import amidst.preferences.BiomeColorProfile;
-import amidst.preferences.SelectPrefModel.SelectButtonModel;
-import amidst.resources.ResourceLoader;
-
-import javax.swing.*;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import java.awt.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.ClipboardOwner;
-import java.awt.datatransfer.StringSelection;
-import java.awt.datatransfer.Transferable;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/** Structured menubar-creation to alleviate the huge mess that it would be elsewise
- */
-
-// TODO: This class is a mess-- it should be split into pieces.
-public class AmidstMenu extends JMenuBar {
- final JMenu fileMenu;
- //final JMenu scriptMenu;
- public final JMenu mapMenu; //TODO: protected
- final JMenu optionsMenu;
- final JMenu helpMenu;
-
- private final FinderWindow window;
-
- public AmidstMenu(FinderWindow window) {
- this.window = window;
-
- fileMenu = add(new FileMenu());
- mapMenu = add(new MapMenu());
- optionsMenu = add(new OptionsMenu());
- helpMenu = add(new HelpMenu());
- }
-
- private class FileMenu extends JMenu {
- private FileMenu() {
- super("File");
- setMnemonic(KeyEvent.VK_F);
-
- add(new JMenu("New") {{
- setMnemonic(KeyEvent.VK_N);
- add(new SeedMenuItem());
- add(new FileMenuItem());
- add(new RandomSeedMenuItem());
- //add(new JMenuItem("From Server"));
- }});
-
- add(new JMenuItem("Save player locations") {{
- setEnabled(MinecraftUtil.getVersion().saveEnabled());
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- if (window.curProject.saveLoaded) {
- for (MapObjectPlayer player : window.curProject.save.getPlayers()) {
- if (player.needSave) {
- window.curProject.save.movePlayer(player.getName(), player.globalX, player.globalY);
- player.needSave = false;
- }
- }
- }
- }
- });
- }});
-
- add(new JMenuItem("Exit") {{
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
- }});
- }
- private String showSeedPrompt(String title) {
- final String blankText = "A random seed will be generated if left blank.";
- final String leadingSpaceText = "Warning: There is a space at the start!";
- final String trailingSpaceText = "Warning: There is a space at the end!";
-
- final JTextField inputText = new JTextField();
-
- inputText.addAncestorListener( new AncestorListener() {
- @Override
- public void ancestorAdded(AncestorEvent arg0) {
- inputText.requestFocus();
- }
- @Override
- public void ancestorMoved(AncestorEvent arg0) {
- inputText.requestFocus();
- }
- @Override
- public void ancestorRemoved(AncestorEvent arg0) {
- inputText.requestFocus();
- }
- });
-
- final JLabel inputInformation = new JLabel(blankText);
- inputInformation.setForeground(Color.red);
- inputInformation.setFont(new Font("arial", Font.BOLD, 10));
- inputText.getDocument().addDocumentListener(new DocumentListener() {
- @Override
- public void changedUpdate(DocumentEvent e) {
- update();
- }
- @Override
- public void insertUpdate(DocumentEvent e) {
- update();
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- update();
- }
- public void update() {
- String text = inputText.getText();
- if (text.equals("")) {
- inputInformation.setText(blankText);
- inputInformation.setForeground(Color.red);
- } else if (text.startsWith(" ")) {
- inputInformation.setText(leadingSpaceText);
- inputInformation.setForeground(Color.red);
- } else if (text.endsWith(" ")) {
- inputInformation.setText(trailingSpaceText);
- inputInformation.setForeground(Color.red);
- } else {
- try {
- Long.parseLong(text);
- inputInformation.setText("Seed is valid.");
- inputInformation.setForeground(Color.gray);
- } catch (NumberFormatException e) {
- inputInformation.setText("This seed's value is " + text.hashCode() + ".");
- inputInformation.setForeground(Color.black);
- }
- }
- }
- });
-
- final JComponent[] inputs = new JComponent[] {
- new JLabel("Enter your seed: "),
- inputInformation,
- inputText
- };
- int result = JOptionPane.showConfirmDialog(window, inputs, title, JOptionPane.OK_CANCEL_OPTION);
- return (result == 0)?inputText.getText():null;
- }
-
- private class SeedMenuItem extends JMenuItem {
- private SeedMenuItem() {
- super("From seed");
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- String seed = showSeedPrompt("New Project");
- if (seed != null) {
- String worldTypePreference = Options.instance.worldType.get();
- SaveLoader.Type worldType = null;
- if (worldTypePreference.equals("Prompt each time")) {
- worldType = choose("New Project", "Enter world type\n", SaveLoader.selectableTypes);
- } else {
- worldType = SaveLoader.Type.fromMixedCase(worldTypePreference);
- }
-
- if (seed.equals(""))
- seed = "" + (new Random()).nextLong();
- if (worldType != null) {
- window.clearProject();
- window.setProject(new Project(seed, worldType.getValue()));
- }
- }
- }
- });
- }
- }
-
- private class RandomSeedMenuItem extends JMenuItem {
- private RandomSeedMenuItem() {
- super("From random seed");
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- //Create the JOptionPane.
- Random random = new Random();
- long seed = random.nextLong();
- String worldTypePreference = Options.instance.worldType.get();
- SaveLoader.Type worldType = null;
- if (worldTypePreference.equals("Prompt each time")) {
- worldType = choose("New Project", "Enter world type\n", SaveLoader.selectableTypes);
- } else {
- worldType = SaveLoader.Type.fromMixedCase(worldTypePreference);
- }
-
- //If a string was returned, say so.
- if (worldType != null) {
- window.clearProject();
- window.setProject(new Project(seed, worldType.getValue()));
- }
- }
-
- });
- }
- }
-
- private class FileMenuItem extends JMenuItem {
- private FileMenuItem() {
- super("From file or folder");
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- JFileChooser fc = new JFileChooser();
- fc.setFileFilter(SaveLoader.getFilter());
- fc.setAcceptAllFileFilterUsed(false);
- fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- File savesDir = null;
- if (Util.profileDirectory != null)
- savesDir = new File(Util.profileDirectory, "saves");
- else
- savesDir = new File(Util.minecraftDirectory, "saves");
- //if (!savesDir.mkdirs()) {
- // Log.w("Unable to create save directory!");
- // return;
- //}
- fc.setCurrentDirectory(savesDir);
- fc.setFileHidingEnabled(false);
- if (fc.showOpenDialog(window) == JFileChooser.APPROVE_OPTION) {
- File f = fc.getSelectedFile();
-
- SaveLoader s = null;
- if (f.isDirectory())
- s = new SaveLoader(new File(f.getAbsoluteFile() + "/level.dat"));
- else
- s = new SaveLoader(f);
- window.clearProject();
- window.setProject(new Project(s));
- }
- }
- });
- }
- }
- }
-
- public class DisplayingCheckbox extends JCheckBoxMenuItem {
- private DisplayingCheckbox(String text, BufferedImage icon, int key, JToggleButton.ToggleButtonModel model) {
- super(text, (icon != null) ? new ImageIcon(icon) : null);
- if (key != -1)
- setAccelerator(KeyStroke.getKeyStroke(key, InputEvent.CTRL_DOWN_MASK));
- setModel(model);
- }
- }
- private class MapMenu extends JMenu {
- private MapMenu() {
- super("Map");
- setEnabled(false);
- setMnemonic(KeyEvent.VK_M);
- add(new FindMenu());
- add(new GoToMenu());
- add(new LayersMenu());
- add(new CopySeedMenuItem());
- add(new CaptureMenuItem());
-
- }
-
- private class FindMenu extends JMenu {
- private FindMenu() {
- super("Find");
- //add(new JMenuItem("Biome"));
- //add(new JMenuItem("Village"));
- add(new JMenuItem("Stronghold") {{
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK));
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- goToChosenPoint(StrongholdLayer.instance.getStrongholds(), "Stronghold");
- }
- });
- }});
- }
- }
-
- private class GoToMenu extends JMenu {
- private GoToMenu() {
- super("Go to");
- add(new JMenuItem("Coordinate") {{
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- String s = JOptionPane.showInputDialog(null, "Enter coordinates: (Ex. 123,456)", "Go To", JOptionPane.QUESTION_MESSAGE);
- if (s != null) {
- String[] c = s.replaceAll(" ", "").split(",");
- try {
- long x = Long.parseLong(c[0]);
- long y = Long.parseLong(c[1]);
- window.curProject.moveMapTo(x, y);
- } catch (NumberFormatException e1) {
- Log.w("Invalid location entered, ignoring.");
- e1.printStackTrace();
- }
- }
- }
- });
- }});
-
- add(new JMenuItem("Player") {{
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- if (window.curProject.saveLoaded) {
- List playerList = window.curProject.save.getPlayers();
- MapObjectPlayer[] players = playerList.toArray(new MapObjectPlayer[playerList.size()]);
- goToChosenPoint(players, "Player");
- MapObjectPlayer p = choose("Go to", "Select player:", players);
- if (p != null)
- window.curProject.moveMapTo(p.globalX, p.globalY);
- }
- }
- });
- }});
- //add(new JMenuItem("Spawn"));
- //add(new JMenuItem("Chunk"));
- }
- }
-
- private class LayersMenu extends JMenu {
- private LayersMenu() {
- super("Layers");
-
- add(new DisplayingCheckbox("Grid",
- ResourceLoader.getImage("grid.png"),
- KeyEvent.VK_1,
- Options.instance.showGrid));
-
- add(new DisplayingCheckbox("Slime chunks",
- ResourceLoader.getImage("slime.png"),
- KeyEvent.VK_2,
- Options.instance.showSlimeChunks));
-
- add(new DisplayingCheckbox("Village Icons",
- ResourceLoader.getImage("village.png"),
- KeyEvent.VK_3,
- Options.instance.showVillages));
-
- add(new DisplayingCheckbox("Ocean Monument Icons",
- ResourceLoader.getImage("ocean_monument.png"),
- KeyEvent.VK_4,
- Options.instance.showOceanMonuments));
-
- add(new DisplayingCheckbox("Temple/Witch Hut Icons",
- ResourceLoader.getImage("desert.png"),
- KeyEvent.VK_5,
- Options.instance.showTemples));
-
- add(new DisplayingCheckbox("Stronghold Icons",
- ResourceLoader.getImage("stronghold.png"),
- KeyEvent.VK_6,
- Options.instance.showStrongholds));
-
- add(new DisplayingCheckbox("Player Icons",
- ResourceLoader.getImage("player.png"),
- KeyEvent.VK_7,
- Options.instance.showPlayers));
-
- add(new DisplayingCheckbox("Nether Fortress Icons",
- ResourceLoader.getImage("nether_fortress.png"),
- KeyEvent.VK_8,
- Options.instance.showNetherFortresses));
-
- add(new DisplayingCheckbox("Spawn Location Icon",
- ResourceLoader.getImage("spawn.png"),
- KeyEvent.VK_9,
- Options.instance.showSpawn));
-
- }
-
-
- }
- private class CaptureMenuItem extends JMenuItem {
- private CaptureMenuItem() {
- super("Capture");
-
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK));
-
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JFileChooser fc = new JFileChooser();
- fc.setFileFilter(new PNGFileFilter());
- fc.setAcceptAllFileFilterUsed(false);
- int returnVal = fc.showSaveDialog(window);
-
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- String s = fc.getSelectedFile().toString();
- if (!s.toLowerCase().endsWith(".png"))
- s += ".png";
- window.curProject.map.saveToFile(new File(s));
- }
- }
- });
- }
- }
- private class CopySeedMenuItem extends JMenuItem {
- private CopySeedMenuItem() {
- super("Copy Seed to Clipboard");
-
- setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
-
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- StringSelection stringSelection = new StringSelection(Options.instance.seed + "");
- Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- clipboard.setContents(stringSelection, new ClipboardOwner() {
- @Override
- public void lostOwnership(Clipboard arg0, Transferable arg1) {
- // TODO Auto-generated method stub
-
- }
- });
- }
- });
- }
- }
- }
-
- private class OptionsMenu extends JMenu {
- private OptionsMenu() {
- super("Options");
- add(new MapOptionsMenu());
- if (BiomeColorProfile.isEnabled)
- add(new BiomeColorMenu());
- add(new WorldTypeMenu());
- setMnemonic(KeyEvent.VK_M);
- }
- private class BiomeColorMenu extends JMenu {
- private ArrayList profileCheckboxes = new ArrayList();
- private JMenuItem reloadMenuItem;
- private class BiomeProfileActionListener implements ActionListener {
- private BiomeColorProfile profile;
- private ArrayList profileCheckboxes;
- private JCheckBoxMenuItem checkBox;
- public BiomeProfileActionListener(BiomeColorProfile profile, JCheckBoxMenuItem checkBox, ArrayList profileCheckboxes) {
- this.profile = profile;
- this.checkBox = checkBox;
- this.profileCheckboxes = profileCheckboxes;
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- for (int i = 0; i < profileCheckboxes.size(); i++)
- profileCheckboxes.get(i).setSelected(false);
- checkBox.setSelected(true);
- profile.activate();
- }
- }
- private BiomeColorMenu() {
- super("Biome profile");
- reloadMenuItem = new JMenuItem("Reload Menu");
- final BiomeColorMenu biomeColorMenu = this;
- reloadMenuItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg) {
- profileCheckboxes.clear();
- Log.i("Reloading additional biome color profiles.");
- File colorProfileFolder = new File("./biome");
- biomeColorMenu.removeAll();
- scanAndLoad(colorProfileFolder, biomeColorMenu);
- biomeColorMenu.add(reloadMenuItem);
- }
- });
- reloadMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl B"));
- Log.i("Checking for additional biome color profiles.");
- File colorProfileFolder = new File("./biome");
- scanAndLoad(colorProfileFolder, this);
- profileCheckboxes.get(0).setSelected(true);
- add(reloadMenuItem);
- }
-
- private boolean scanAndLoad(File folder, JMenu menu) {
- File[] files = folder.listFiles();
- BiomeColorProfile profile;
- boolean foundProfiles = false;
- for (int i = 0; i < files.length; i++) {
- if (files[i].isFile()) {
- if ((profile = BiomeColorProfile.createFromFile(files[i])) != null) {
- JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(profile.name);
- menuItem.addActionListener(new BiomeProfileActionListener(profile, menuItem, profileCheckboxes));
- if (profile.shortcut != null) {
- KeyStroke accelerator = KeyStroke.getKeyStroke(profile.shortcut);
- if (accelerator != null)
- menuItem.setAccelerator(accelerator);
- else
- Log.i("Unable to create keyboard shortcut from: " + profile.shortcut);
- }
- menu.add(menuItem);
- profileCheckboxes.add(menuItem);
- foundProfiles = true;
- }
- } else {
- JMenu subMenu = new JMenu(files[i].getName());
- if (scanAndLoad(files[i], subMenu)) {
- menu.add(subMenu);
- }
- }
- }
- return foundProfiles;
- }
-
- }
- private class MapOptionsMenu extends JMenu {
- private MapOptionsMenu() {
- super("Map");
-
- add(new DisplayingCheckbox("Map Flicking (Smooth Scrolling)",
- null,
- KeyEvent.VK_I,
- Options.instance.mapFlicking));
-
- add(new DisplayingCheckbox("Restrict Maximum Zoom",
- null,
- KeyEvent.VK_Z,
- Options.instance.maxZoom));
-
- add(new DisplayingCheckbox("Show Framerate",
- null,
- KeyEvent.VK_L,
- Options.instance.showFPS));
-
- add(new DisplayingCheckbox("Show Scale",
- null,
- KeyEvent.VK_K,
- Options.instance.showScale));
-
- add(new DisplayingCheckbox("Use Fragment Fading",
- null,
- -1,
- Options.instance.mapFading));
-
- add(new DisplayingCheckbox("Show Debug Info",
- null,
- -1,
- Options.instance.showDebug));
- }
-
- }
- private class WorldTypeMenu extends JMenu {
- private WorldTypeMenu() {
- super("World type");
-
- SelectButtonModel[] buttonModels = Options.instance.worldType.getButtonModels();
-
- for (int i = 0; i < buttonModels.length; i++) {
- add(new DisplayingCheckbox(buttonModels[i].getName(),
- null,
- -1,
- buttonModels[i]));
- }
- }
-
- }
- }
-
- private class HelpMenu extends JMenu {
- private HelpMenu() {
- super("Help");
-
- add(new JMenuItem("Check for updates") {{
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new UpdateManager(window).start();
- }
- });
- }});
-
- add(new JMenuItem("View licenses") {{
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- new LicenseWindow();
- }
- });
- }});
-
- add(new JMenuItem("About") {{
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(window,
- "Advanced Minecraft Interfacing and Data/Structure Tracking (AMIDST)\n" +
- "By Skidoodle (amidst.project@gmail.com)");
- }
- });
- }});
-
- }
- }
-
- /** Allows the user to choose one of several things.
- *
- * Convenience wrapper around JOptionPane.showInputDialog
- */
- private T choose(String title, String message, T[] choices) {
- return (T) JOptionPane.showInputDialog(
- window,
- message,
- title,
- JOptionPane.PLAIN_MESSAGE,
- null,
- choices,
- choices[0]);
- }
-
- /** Lets the user decide one of the given points and go to it
- * @param points Given points to choose from
- * @param name name displayed in the choice
- */
- private void goToChosenPoint(T[] points, String name) {
-
- T p = choose("Go to", "Select " + name + ":", points);
- if (p != null)
- window.curProject.moveMapTo(p.x, p.y);
- }
-}
diff --git a/src/amidst/gui/menu/PlayerMenuItem.java b/src/amidst/gui/menu/PlayerMenuItem.java
deleted file mode 100644
index bc6e7136b..000000000
--- a/src/amidst/gui/menu/PlayerMenuItem.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package amidst.gui.menu;
-
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JMenuItem;
-
-import MoF.MapViewer;
-import amidst.map.Fragment;
-import amidst.map.Map;
-import amidst.map.MapObjectPlayer;
-import amidst.map.layers.PlayerLayer;
-
-public class PlayerMenuItem extends JMenuItem implements ActionListener {
- private PlayerLayer playerLayer;
- private MapObjectPlayer player;
- private MapViewer mapViewer;
-
- public PlayerMenuItem(MapViewer mapViewer, MapObjectPlayer player, PlayerLayer playerLayer) {
- super(player.getName());
- this.playerLayer = playerLayer;
- this.player = player;
- this.mapViewer = mapViewer;
- addActionListener(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent event) {
- Map map = playerLayer.getMap();
-
- if (player.parentFragment != null) {
- player.parentFragment.removeObject(player);
- }
- Point lastRightClick = mapViewer.lastRightClick;
- if (lastRightClick != null) {
- Point location = map.screenToLocal(lastRightClick);
- player.setPosition(location.x, location.y);
- Fragment fragment = map.getFragmentAt(location);
- fragment.addObject(player);
- player.parentFragment = fragment;
- }
- }
-
-}
diff --git a/src/amidst/gui/version/LocalVersionComponent.java b/src/amidst/gui/version/LocalVersionComponent.java
deleted file mode 100644
index 05e093eb9..000000000
--- a/src/amidst/gui/version/LocalVersionComponent.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package amidst.gui.version;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.net.MalformedURLException;
-
-import MoF.FinderWindow;
-import amidst.Options;
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.minecraft.Minecraft;
-import amidst.minecraft.MinecraftUtil;
-import amidst.version.IProfileUpdateListener;
-import amidst.version.MinecraftProfile;
-import amidst.version.ProfileUpdateEvent;
-import amidst.version.MinecraftProfile.Status;
-
-public class LocalVersionComponent extends VersionComponent {
- protected MinecraftProfile profile;
- protected int oldWidth = 0;
- protected String drawName;
- private String name;
-
-
- public LocalVersionComponent(MinecraftProfile profile) {
- this.profile = profile;
- drawName = profile.getProfileName();
- name = "local:" + profile.getProfileName();
-
- profile.addUpdateListener(new IProfileUpdateListener() {
- @Override
- public void onProfileUpdate(ProfileUpdateEvent event) {
- repaint();
- }
- });
- }
-
- @Override
- public void paintComponent(Graphics g) {
- Graphics2D g2d = (Graphics2D)g;
- FontMetrics fontMetrics = null;
-
- if (isLoading)
- g2d.setColor(loadingBgColor);
- else if (isSelected())
- g2d.setColor(selectedBgColor);
- else
- g2d.setColor(Color.white);
- g2d.fillRect(0, 0, getWidth(), getHeight());
-
- g2d.setColor(Color.black);
- g2d.setFont(versionFont);
- fontMetrics = g2d.getFontMetrics();
- int versionNameX = getWidth() - 40 - fontMetrics.stringWidth(profile.getVersionName());
- g2d.drawString(profile.getVersionName(), versionNameX, 20);
-
- g2d.setColor(Color.black);
- g2d.setFont(nameFont);
- if (oldWidth != getWidth()) {
- fontMetrics = g2d.getFontMetrics();
- String name = profile.getProfileName();
- if (fontMetrics.stringWidth(name) > versionNameX - 25) {
- int widthSum = 0;
- for (int i = 0; i < name.length(); i++) {
- widthSum += fontMetrics.charWidth(name.charAt(i));
- if (widthSum > versionNameX - 25) {
- name = name.substring(0, i) + "...";
- break;
- }
- }
- }
- drawName = name;
- oldWidth = getWidth();
- }
- g2d.drawString(drawName, 5, 30);
-
- g2d.setColor(Color.gray);
- g2d.setFont(statusFont);
- fontMetrics = g2d.getFontMetrics();
- String statusString = profile.getStatus().toString();
- g2d.drawString(statusString, getWidth() - 40 - fontMetrics.stringWidth(statusString), 32);
-
- BufferedImage image = inactiveIcon;
- if (isLoading)
- image = loadingIcon;
- else if (profile.getStatus() == Status.FOUND)
- image = activeIcon;
- g2d.drawImage(image, getWidth() - image.getWidth() - 5, 4, null);
- }
-
-
- public String getProfileName() {
- return profile.getProfileName();
- }
-
- public MinecraftProfile getProfile() {
- return profile;
- }
-
- @Override
- public boolean isReadyToLoad() {
- return profile.getStatus() == Status.FOUND;
- }
-
- @Override
- public void load() {
- isLoading = true;
- repaint();
- Options.instance.lastProfile.set(name);
- (new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Util.setProfileDirectory(profile.getGameDir());
- MinecraftUtil.setBiomeInterface(new Minecraft(profile.getJarFile()).createInterface());
- new FinderWindow();
- VersionSelectWindow.get().dispose();
- } catch (MalformedURLException e) {
- Log.crash(e, "MalformedURLException on Minecraft load.");
- }
- }
- })).start();
- }
-
- @Override
- public String getVersionName() {
- return name;
- }
-}
diff --git a/src/amidst/gui/version/RemoteVersionComponent.java b/src/amidst/gui/version/RemoteVersionComponent.java
deleted file mode 100644
index 0501968d6..000000000
--- a/src/amidst/gui/version/RemoteVersionComponent.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package amidst.gui.version;
-
-import MoF.FinderWindow;
-import amidst.Options;
-import amidst.minecraft.MinecraftUtil;
-import amidst.minecraft.remote.RemoteMinecraft;
-
-public class RemoteVersionComponent extends VersionComponent {
- private String remoteAddress;
- private String name;
-
- public RemoteVersionComponent(String address) {
- remoteAddress = address;
- name = "remote:" + address;
- }
- public RemoteVersionComponent() {
- this("127.0.0.1");
- }
-
- @Override
- public void load() {
- isLoading = true;
- repaint();
- Options.instance.lastProfile.set(name);
- (new Thread(new Runnable() {
- @Override
- public void run() {
- MinecraftUtil.setBiomeInterface(new RemoteMinecraft(remoteAddress));
- new FinderWindow();
- VersionSelectWindow.get().dispose();
- }
- })).start();
- }
-
- @Override
- public boolean isReadyToLoad() {
- return true;
- }
- @Override
- public String getVersionName() {
- return name;
- }
-}
diff --git a/src/amidst/gui/version/VersionComponent.java b/src/amidst/gui/version/VersionComponent.java
deleted file mode 100644
index 3efc35db3..000000000
--- a/src/amidst/gui/version/VersionComponent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package amidst.gui.version;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.image.BufferedImage;
-
-import javax.swing.JComponent;
-
-import amidst.resources.ResourceLoader;
-
-public abstract class VersionComponent extends JComponent {
- protected static Font nameFont = new Font("arial", Font.BOLD, 30);
- protected static Font statusFont = new Font("arial", Font.BOLD, 10);
- protected static Font versionFont = new Font("arial", Font.BOLD, 16);
- protected static BufferedImage activeIcon = ResourceLoader.getImage("active_profile.png");
- protected static BufferedImage inactiveIcon = ResourceLoader.getImage("inactive_profile.png");
- protected static BufferedImage loadingIcon = ResourceLoader.getImage("loading_profile.png");
- protected static Color selectedBgColor = new Color(160, 190, 255);
- protected static Color loadingBgColor = new Color(112, 203, 91);
-
- protected boolean selected = false;
- protected boolean isLoading = false;
-
- public VersionComponent() {
- this.setMinimumSize(new Dimension(300, 40));
- this.setPreferredSize(new Dimension(500, 40));
- }
-
- public boolean isSelected() {
- return selected;
- }
- public void setSelected(boolean value) {
- selected = value;
- }
-
- public abstract void load();
- public abstract boolean isReadyToLoad();
- public abstract String getVersionName();
-}
diff --git a/src/amidst/gui/version/VersionSelectPanel.java b/src/amidst/gui/version/VersionSelectPanel.java
deleted file mode 100644
index 490814c32..000000000
--- a/src/amidst/gui/version/VersionSelectPanel.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package amidst.gui.version;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.util.ArrayList;
-import javax.swing.JPanel;
-
-import net.miginfocom.swing.MigLayout;
-
-public class VersionSelectPanel extends JPanel implements MouseListener, KeyListener {
- private String emptyMessage;
- private int emptyMessageWidth;
- private FontMetrics emptyMessageMetric;
- private Font emptyMessageFont = new Font("arial", Font.BOLD, 30);
- private boolean isLoading = false;
-
- private ArrayList components = new ArrayList();
- private VersionComponent selected = null;
- private int selectedIndex = -1;
-
- public VersionSelectPanel() {
- setLayout(new MigLayout("ins 0", "", "[]0[]"));
- setEmptyMessage("Empty");
- addMouseListener(this);
-
-
- }
-
- public void addVersion(VersionComponent version) {
- add(version, "growx, pushx, wrap");
- components.add(version);
- }
-
- @Override
- public void paintChildren(Graphics g) {
- super.paintChildren(g);
- Graphics2D g2d = (Graphics2D)g;
- g2d.setColor(Color.gray);
- for (int i = 1; i <= components.size(); i++) {
- g2d.drawLine(0, i * 40, getWidth(), i * 40);
- }
- }
-
- @Override
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- if (emptyMessageMetric == null) {
- emptyMessageMetric = g.getFontMetrics(emptyMessageFont);
- emptyMessageWidth = emptyMessageMetric.stringWidth(emptyMessage);
- }
- g.setColor(Color.white);
- g.fillRect(0, 0, getWidth(), getHeight());
-
- if (components.size() == 0) {
- g.setColor(Color.gray);
- g.setFont(emptyMessageFont);
- g.drawString(emptyMessage, (getWidth() >> 1) - (emptyMessageWidth >> 1), 30);
- }
-
- }
-
- public void setEmptyMessage(String message) {
- emptyMessage = message;
- if (emptyMessageMetric != null)
- emptyMessageWidth = emptyMessageMetric.stringWidth(emptyMessage);
- }
-
- public void select(String name) {
- for (int i = 0; i < components.size(); i++) {
- if (components.get(i).getVersionName().equals(name)) {
- select(i);
- break;
- }
- }
- }
-
- public void select(VersionComponent component) {
- for (int i = 0; i < components.size(); i++) {
- if (components.get(i) == component) {
- select(i);
- break;
- }
- }
- }
-
- public void select(int index) {
- if (selected != null) {
- selected.setSelected(false);
- selected.repaint();
- }
-
- selected = null;
-
- if (index < components.size()) {
- selected = components.get(index);
- selected.setSelected(true);
- selected.repaint();
- selectedIndex = index;
- }
- }
-
- private void loadSelectedProfile() {
- if ((selected == null) || !selected.isReadyToLoad())
- return;
- isLoading = true;
- selected.load();
- }
-
- @Override
- public void mouseClicked(MouseEvent arg0) {
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- }
- @Override
- public void mousePressed(MouseEvent event) {
- if (isLoading)
- return;
-
- int index = event.getPoint().y / 40;
- select(index);
-
- if (event.getPoint().x > getWidth() - 40)
- loadSelectedProfile();
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- }
-
- @Override
- public void keyPressed(KeyEvent event) {
- if (isLoading)
- return;
- int key = event.getKeyCode();
- switch (key) {
- case KeyEvent.VK_DOWN:
- if (selectedIndex < components.size() - 1)
- select(selectedIndex + 1);
- break;
- case KeyEvent.VK_UP:
- if (selectedIndex > 0)
- select(selectedIndex - 1);
- else if (selectedIndex == -1)
- select(0);
- break;
- case KeyEvent.VK_ENTER:
- loadSelectedProfile();
- break;
- }
- }
- @Override
- public void keyReleased(KeyEvent arg0) {
- }
- @Override
- public void keyTyped(KeyEvent event) {
- }
-}
diff --git a/src/amidst/gui/version/VersionSelectWindow.java b/src/amidst/gui/version/VersionSelectWindow.java
deleted file mode 100644
index c92b40867..000000000
--- a/src/amidst/gui/version/VersionSelectWindow.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package amidst.gui.version;
-
-import java.awt.Container;
-import java.awt.Font;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-import javax.swing.SwingConstants;
-
-import net.miginfocom.swing.MigLayout;
-import amidst.Amidst;
-import amidst.Options;
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.version.LatestVersionList;
-import amidst.version.MinecraftProfile;
-import amidst.version.VersionFactory;
-
-public class VersionSelectWindow extends JFrame {
- private static VersionSelectWindow instance;
- private VersionFactory versionFactory = new VersionFactory();
-
- public VersionSelectWindow() {
- super("Profile Selector");
- instance = this;
- setIconImage(Amidst.icon);
- Container contentPane = getContentPane();
- contentPane.setLayout(new MigLayout());
-
- LatestVersionList.get().load(true);
-
- if (!Util.minecraftDirectory.exists() || !Util.minecraftDirectory.isDirectory()) {
- Log.crash("Unable to find Minecraft directory at: " + Util.minecraftDirectory);
- return;
- }
-
- final JLabel titleLabel = new JLabel("Please select a Minecraft version:", SwingConstants.CENTER);
- titleLabel.setFont(new Font("arial", Font.BOLD, 16));
-
- add(titleLabel, "h 20!,w :400:, growx, pushx, wrap");
-
- final VersionSelectPanel versionSelector = new VersionSelectPanel();
-
- (new Thread(new Runnable() {
- @Override
- public void run() {
- versionFactory.scanForProfiles();
- MinecraftProfile[] localVersions = versionFactory.getProfiles();
- String selectedProfile = Options.instance.lastProfile.get();
-
- if (localVersions == null) {
- versionSelector.setEmptyMessage("Empty");
- return;
- }
- for (int i = 0; i < localVersions.length; i++)
- versionSelector.addVersion(new LocalVersionComponent(localVersions[i]));
- versionSelector.addVersion(new RemoteVersionComponent());
-
- if (selectedProfile != null)
- versionSelector.select(selectedProfile);
-
- pack();
- try {
- Thread.sleep(100);
- } catch (InterruptedException ignored) { }
- pack();
- }
- })).start();
-
- versionSelector.setEmptyMessage("Scanning...");
-
- JScrollPane scrollPane = new JScrollPane(versionSelector);
- add(scrollPane, "grow, push, h 80::");
- pack();
- setLocation(200, 200);
- setVisible(true);
-
- addKeyListener(versionSelector);
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- dispose();
- System.exit(0);
- }
- });
- }
-
- public static VersionSelectWindow get() {
- return instance;
- }
-}
diff --git a/src/amidst/json/InstallInformation.java b/src/amidst/json/InstallInformation.java
deleted file mode 100644
index e0fda989f..000000000
--- a/src/amidst/json/InstallInformation.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package amidst.json;
-
-public class InstallInformation {
- public String name;
- public String lastVersionId = "latest";
- public String gameDir;
- public String javaDir;
- public String javaArgs;
- public String playerUUID;
- public Resolution resolution;
- public String[] allowedReleaseTypes = new String[] { "release" };
-}
\ No newline at end of file
diff --git a/src/amidst/json/JarLibrary.java b/src/amidst/json/JarLibrary.java
deleted file mode 100644
index 449f9e982..000000000
--- a/src/amidst/json/JarLibrary.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package amidst.json;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import amidst.Util;
-import amidst.logging.Log;
-
-public class JarLibrary {
- public String name;
- public ArrayList rules;
-
- private File file;
-
- public JarLibrary() {
- rules = new ArrayList();
- }
-
- public boolean isActive() {
- if (rules.size() == 0)
- return true;
-
- boolean isAllowed = false;
- for (JarRule rule : rules)
- if (rule.isApplicable())
- isAllowed = rule.isAllowed();
-
- return isAllowed;
- }
-
- public File getFile() {
- if (file == null) {
- String searchPath = Util.minecraftLibraries.getAbsolutePath() + "/";
- String[] pathSplit = name.split(":");
- pathSplit[0] = pathSplit[0].replace('.', '/');
- for (int i = 0; i < pathSplit.length; i++)
- searchPath += pathSplit[i] + "/";
- File searchPathFile = new File(searchPath);
- if (!searchPathFile.exists()) {
- Log.w("Failed attempt to load library at: " + searchPathFile);
- return null;
- }
-
- File[] libraryFiles = searchPathFile.listFiles();
- for (int i = 0; i < libraryFiles.length; i++) {
- String extension = "";
- String fileName = libraryFiles[i].getName();
- int q = fileName.lastIndexOf('.');
- if (q > 0)
- extension = fileName.substring(q+1);
- if (extension.equals("jar"))
- file = libraryFiles[i];
- }
- if (file == null)
- Log.w("Attempted to search for file at path: " + searchPath + " but found nothing. Skipping.");
- }
- return file;
- }
-}
diff --git a/src/amidst/json/JarProfile.java b/src/amidst/json/JarProfile.java
deleted file mode 100644
index d3d21bbd9..000000000
--- a/src/amidst/json/JarProfile.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package amidst.json;
-
-import java.util.ArrayList;
-
-public class JarProfile {
- public String id, time, releaseTime, type, minecraftArguments;
- public ArrayList libraries = new ArrayList();
-
- public JarProfile() {
- }
-}
diff --git a/src/amidst/json/JarRule.java b/src/amidst/json/JarRule.java
deleted file mode 100644
index 0a398b403..000000000
--- a/src/amidst/json/JarRule.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package amidst.json;
-
-public class JarRule {
- public String action;
- public RuleOs os = new RuleOs("any");
-
- public JarRule() {
- }
- public boolean isApplicable() {
- return os.check();
- }
- public boolean isAllowed() {
- return action.equals("allow");
- }
-}
diff --git a/src/amidst/json/LauncherProfile.java b/src/amidst/json/LauncherProfile.java
deleted file mode 100644
index 99c6d3634..000000000
--- a/src/amidst/json/LauncherProfile.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package amidst.json;
-
-import java.util.HashMap;
-
-public class LauncherProfile {
- public HashMap profiles;
- public String selectedProfile;
- public String clientToken;
-}
diff --git a/src/amidst/json/Resolution.java b/src/amidst/json/Resolution.java
deleted file mode 100644
index 05d9e656f..000000000
--- a/src/amidst/json/Resolution.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package amidst.json;
-
-public class Resolution {
- public String width, height;
-}
diff --git a/src/amidst/json/RuleOs.java b/src/amidst/json/RuleOs.java
deleted file mode 100644
index fa7f36eca..000000000
--- a/src/amidst/json/RuleOs.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.json;
-
-import amidst.Util;
-
-public class RuleOs {
- public String name;
- public RuleOs() {
-
- }
- public RuleOs(String name) {
- this.name = name;
- }
- public boolean check() {
- if (name.equals("any"))
- return true;
- if (name.equals(Util.getOs()))
- return true;
- return false;
- }
-}
diff --git a/src/amidst/logging/FileLogger.java b/src/amidst/logging/FileLogger.java
deleted file mode 100644
index efeca1f79..000000000
--- a/src/amidst/logging/FileLogger.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package amidst.logging;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-public class FileLogger extends Thread implements LogListener {
- private File file;
- private boolean enabled = true;
- private ConcurrentLinkedQueue logQueue = new ConcurrentLinkedQueue();
-
- public FileLogger(File file) {
- this.file = file;
- if (!file.exists()) {
- try {
- enabled = file.createNewFile();
- if (!enabled)
- Log.w("Unable to create new file at: " + file + " disabling logging to file. (No exception thrown)");
- } catch (IOException e) {
- Log.w("Unable to create new file at: " + file + " disabling logging to file.");
- e.printStackTrace();
- enabled = false;
- }
- } else if (file.isDirectory()) {
- Log.w("Unable to log at path: " + file + " because location is a directory.");
- enabled = false;
- }
- write("log", "New FileLogger started.");
- start();
- }
- @Override
- public void debug(Object... o) {
- write("debug", o);
- }
-
- @Override
- public void info(Object... o) {
- write("info", o);
- }
-
- @Override
- public void warning(Object... o) {
- write("warning", o);
- }
-
- @Override
- public void error(Object... o) {
- write("error", o);
- }
-
-
- @Override
- public void crash(Throwable e, String exceptionText, String message) {
- write("crash", message);
- if (exceptionText.length() > 0)
- write("crash", exceptionText);
- }
-
-
- private void write(String tag, Object... msgs) {
- StringBuilder stringBuilder = new StringBuilder(new Timestamp(new Date().getTime()).toString()).append(" [").append(tag).append("] ");
- for (int i = 0; i < msgs.length; i++) {
- stringBuilder.append(msgs[i]);
- stringBuilder.append((i < msgs.length - 1) ? " " : "\r\n");
- }
- logQueue.add(stringBuilder.toString());
- }
-
- @Override
- public void run() {
- while (enabled) {
- if (logQueue.size() != 0) {
- StringBuilder stringBuilder = new StringBuilder();
- while (logQueue.size() != 0)
- stringBuilder.append(logQueue.poll());
-
- if (file.exists() && file.isFile()) {
- FileWriter writer = null;
- try {
- writer = new FileWriter(file, true);
- writer.append(stringBuilder.toString());
- } catch (IOException e) {
- Log.w("Unable to write to log file.");
- e.printStackTrace();
- } finally {
- try {
- if (writer != null)
- writer.close();
- } catch (IOException e) {
- Log.w("Unable to close writer for log file.");
- e.printStackTrace();
- }
- }
- }
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- }
- }
-}
diff --git a/src/amidst/logging/Log.java b/src/amidst/logging/Log.java
deleted file mode 100644
index 4ec79ee91..000000000
--- a/src/amidst/logging/Log.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package amidst.logging;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashMap;
-import javax.swing.JOptionPane;
-
-import MoF.FinderWindow;
-import amidst.gui.CrashDialog;
-
-public class Log {
- private static Object logLock = new Object();
- private static HashMap listeners = new HashMap();
- public static boolean isUsingAlerts = true;
- public static boolean isShowingDebug = true;
-
- static {
- addListener("master", new LogRecorder());
- }
-
- public static void addListener(String name, LogListener listener) {
- synchronized (logLock) {
- listeners.put(name, listener);
- }
- }
- public static void removeListener(String name) {
- synchronized (logLock) {
- listeners.remove(name);
- }
- }
- public static void printTraceStack(Throwable e) {
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- e.printStackTrace(printWriter);
- String exceptionText = stringWriter.toString();
- w(exceptionText);
- }
-
- public static void i(Object... s) {
- synchronized (logLock) {
- printWithTag("info", s);
- if (listeners.size() != 0)
- for (LogListener listener : listeners.values())
- listener.info(s);
- }
- }
- public static void debug(Object... s) {
- if (!isShowingDebug)
- return;
- synchronized (logLock) {
- printWithTag("debug", s);
- if (listeners.size() != 0)
- for (LogListener listener : listeners.values())
- listener.debug(s);
- }
- }
- public static void w(Object... s) {
- synchronized (logLock) {
- printWithTag("warning", s);
- if (listeners.size() != 0)
- for (LogListener listener : listeners.values())
- listener.warning(s);
- }
- }
-
- public static void e(Object... s) {
- synchronized (logLock) {
- printWithTag("error", s);
- if (isUsingAlerts)
- JOptionPane.showMessageDialog(null, s, "Error", JOptionPane.ERROR_MESSAGE);
- if (listeners.size() != 0)
- for (LogListener listener : listeners.values())
- listener.error(s);
- }
- }
-
- public static void crash(String message) {
- crash(null, message);
- }
- public static void crash(Throwable e, String message) {
- synchronized (logLock) {
- printWithTag("crash", message);
- String exceptionText = "";
- if (e != null) {
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- e.printStackTrace(printWriter);
- exceptionText = stringWriter.toString();
- printWithTag("crash", exceptionText);
- }
-
- if (listeners.size() != 0)
- for (LogListener listener : listeners.values())
- listener.crash(e, exceptionText, message);
-
-
- new CrashDialog(message);
- if (FinderWindow.instance != null)
- FinderWindow.instance.dispose();
- //System.exit(0);
- }
- }
-
- private static void printWithTag(String tag, Object... msgs) {
- System.out.print("[" + tag + "] ");
- for (int i = 0; i < msgs.length; i++) {
- System.out.print(msgs[i]);
- System.out.print((i < msgs.length - 1) ? " " : "\n");
- }
- }
-}
diff --git a/src/amidst/logging/LogListener.java b/src/amidst/logging/LogListener.java
deleted file mode 100644
index ec74ec84f..000000000
--- a/src/amidst/logging/LogListener.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package amidst.logging;
-
-public interface LogListener {
- public void debug(Object... o);
- public void info(Object... o);
- public void warning(Object... o);
- public void error(Object... o);
- public void crash(Throwable e, String exceptionText, String message);
-}
diff --git a/src/amidst/logging/LogRecorder.java b/src/amidst/logging/LogRecorder.java
deleted file mode 100644
index 6b46edf4f..000000000
--- a/src/amidst/logging/LogRecorder.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package amidst.logging;
-
-public class LogRecorder implements LogListener {
- private static StringBuffer buffer = new StringBuffer();
-
- @Override
- public void debug(Object... o) {
- write("debug", o);
- }
-
- @Override
- public void info(Object... o) {
- write("info", o);
- }
-
- @Override
- public void warning(Object... o) {
- write("warning", o);
- }
-
- @Override
- public void error(Object... o) {
- write("error", o);
- }
-
-
- @Override
- public void crash(Throwable e, String exceptionText, String message) {
- write("crash", message);
- if (exceptionText.length() > 0)
- write("crash", exceptionText);
- }
-
- private static void write(String tag, Object... msgs) {
- buffer.append("[" + tag + "] ");
- for (int i = 0; i < msgs.length; i++)
- buffer.append(msgs[i] + ((i < msgs.length - 1) ? " " : "\n"));
- }
-
- public static String getContents() {
- return buffer.toString();
- }
-}
diff --git a/src/amidst/map/ByteArrayCache.java b/src/amidst/map/ByteArrayCache.java
deleted file mode 100644
index 094424f7b..000000000
--- a/src/amidst/map/ByteArrayCache.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package amidst.map;
-
-import java.util.Vector;
-
-import amidst.logging.Log;
-
-public class ByteArrayCache extends CacheManager {
- public static final int CACHE_SIZE = 32, CACHE_SHIFT = 5;
- public static final int HEADER_SIZE = (CACHE_SIZE*CACHE_SIZE) >> 3;
- public static final int CACHE_MAX_SIZE = CACHE_SIZE*CACHE_SIZE; // TODO : Change name to CACHE_LENGTH ?
-
- private int maxUnits;
- private byte unitSize;
-
- private Vector cacheMap;
-
- private byte[] byteCache;
-
- public ByteArrayCache(byte unitSize, int maxUnits) {
- cacheMap = new Vector();
- this.unitSize = unitSize;
- this.maxUnits = maxUnits;
- byteCache = new byte[unitSize*maxUnits];
- }
-
- @Override
- public void save(Fragment frag) {
-
- }
-
- @Override
- public void load(Fragment frag, int layerID) {
- long keyX = frag.getFragmentX() >> CACHE_SHIFT;
- long keyY = frag.getFragmentY() >> CACHE_SHIFT;
- long key = (keyX << 32) | (keyY & 0xFFFFFFFFL);
-
- ByteArrayHub hub = getHub(key);
- if (hub == null) {
- hub = new ByteArrayHub(key, unitSize, maxUnits, cachePath);
- Log.i("Loading [X:" + keyX + " Y:" + keyY + " KEY:" + key + "]"); // TODO : Remove
- cacheMap.add(hub);
- }
-
- int subKeyX = Math.abs(frag.getFragmentX()) % CACHE_SIZE;
- int subKeyY = Math.abs(frag.getFragmentY()) % CACHE_SIZE;
- int subKey = (subKeyX << CACHE_SHIFT) + subKeyY;
- //Log.i("FragX:" + frag.getFragmentX() + " FragY:" + frag.getFragmentY() + " |keyX:" + keyX + " keyY:" + keyY + " key:" + key + "| X:" + subKeyX + " Y:" + subKeyY + " Key:" + subKey + " TKey:" + hub.getKey());
- byte[] tempData = null;
- if (hub.exists(subKey)) {
- tempData = hub.get(subKey);
- } else {
- //tempData = (byte[]) ((NativeJavaArray)PluginManager.call(funcSave, frag)).unwrap();
- hub.put(subKey, tempData);
- }
- //PluginManager.call(funcLoad, frag, tempData, layerID);
-
- hub.activeFragments++;
- }
-
- @Override
- public void unload(Fragment frag) {
- long keyX = frag.getFragmentX() >> CACHE_SHIFT;
- long keyY = frag.getFragmentY() >> CACHE_SHIFT;
- long key = (keyX << 32) | (keyY & 0xFFFFFFFFL);
- ByteArrayHub hub = getHub(key);
-
- hub.activeFragments--;
- //Log.i(masterCount);
- if (hub.activeFragments == 0) {
- Log.i("Unloading [X:" + keyX + " Y:" + keyY + " KEY:" + key + "]"); // TODO : Remove
- hub.unload();
- cacheMap.remove(hub);
- }
-
- }
- private ByteArrayHub getHub(long key) {
- for (ByteArrayHub hub : cacheMap) {
- if (hub.getKey() == key)
- return hub;
- }
- return null;
- }
-
- // JS Shortcut
- // TODO : Add more?
-
- public byte[] intToCachedBytes(int[] data) {
- for (int i = 0; i < byteCache.length; i++) {
- byteCache[i] = (byte) data[i];
- }
- return byteCache;
- }
-
-}
diff --git a/src/amidst/map/ByteArrayHub.java b/src/amidst/map/ByteArrayHub.java
deleted file mode 100644
index 7c03f21b0..000000000
--- a/src/amidst/map/ByteArrayHub.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package amidst.map;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-public class ByteArrayHub {
- private File path;
- private long key;
- private byte unitSize;
- private int maxUnits;
- private int dataHop;
- public int activeFragments = 0;
-
- private byte[] data;
- private byte[] returnCache;
-
- private int unitOffset;
-
- public ByteArrayHub(long key, byte unitSize, int maxUnits, File basePath) {
- this.unitSize = unitSize;
- this.maxUnits = maxUnits;
- this.key = key;
-
- unitOffset = maxUnits*unitSize;
-
- path = new File(basePath, Long.toHexString(key).toUpperCase() + ".acache");
- data = new byte[unitOffset*ByteArrayCache.CACHE_MAX_SIZE + ByteArrayCache.HEADER_SIZE];
- returnCache = new byte[unitSize*maxUnits];
- if (path.exists()) {
- GZIPInputStream inStream;
- try {
- inStream = new GZIPInputStream(new FileInputStream(path));
- byte[] readBuffer = new byte[1024];
- int len;
- int offset = 0;
- while ((len = inStream.read(readBuffer)) != -1) {
- System.arraycopy(readBuffer, 0, data, offset, len);
- offset += len;
- }
- //Log.i("@@@@@ " + inStream.read(data));
- inStream.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- public boolean exists(int id) {
- return (((data[id >> 3] >> (id % 8)) & 0x1) == 0x1);
- }
- public byte[] get(int id) {
- System.arraycopy(data, ByteArrayCache.HEADER_SIZE + unitOffset*id, returnCache, 0, unitOffset);
- return returnCache;
- }
- public void put(int id, byte[] indata) {
- System.arraycopy(indata, 0, data, ByteArrayCache.HEADER_SIZE + unitOffset*id, unitOffset);
- data[id >> 3] |= 0x1 << (id % 8);
- }
-
- public void unload() {
- try {
- BufferedOutputStream outStream = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(path)));
- outStream.write(data, 0, data.length);
- outStream.flush();
- outStream.close();
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public long getKey() {
- return key;
- }
-
-}
diff --git a/src/amidst/map/CacheManager.java b/src/amidst/map/CacheManager.java
deleted file mode 100644
index 2094c2c3a..000000000
--- a/src/amidst/map/CacheManager.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package amidst.map;
-
-import java.io.File;
-
-import amidst.Util;
-
-public abstract class CacheManager {
- protected File cachePath;
-
- public CacheManager() {}
-
- public void setCachePath(String name) {
- cachePath = Util.getTempDir(name);
- }
-
- public abstract void save(Fragment frag);
- public abstract void load(Fragment frag, int layerID);
- public abstract void unload(Fragment frag);
-}
diff --git a/src/amidst/map/Fragment.java b/src/amidst/map/Fragment.java
deleted file mode 100644
index 618534e35..000000000
--- a/src/amidst/map/Fragment.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package amidst.map;
-
-import java.awt.AlphaComposite;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-
-import amidst.Options;
-import amidst.logging.Log;
-import amidst.minecraft.MinecraftUtil;
-
-public class Fragment {
- public static final int SIZE = 512, SIZE_SHIFT = 9, MAX_OBJECTS_PER_FRAGMENT = 32, BIOME_SIZE = SIZE >> 2;
- private static AffineTransform drawMatrix = new AffineTransform();
- public int blockX, blockY;
-
- public short[] biomeData = new short[BIOME_SIZE * BIOME_SIZE];
-
- private ImageLayer[] imageLayers;
- private LiveLayer[] liveLayers;
- private IconLayer[] iconLayers;
-
- private Object loadLock = new Object();
-
- private BufferedImage[] images;
- public MapObject[] objects;
- public int objectsLength = 0;
-
- private float alpha = 0.0f;
-
- public boolean isActive = false;
- public boolean isLoaded = false;
-
- public Fragment nextFragment = null, prevFragment = null;
- public boolean hasNext = false;
-
- public boolean endOfLine = false;
-
- private static int[] dataCache = new int[SIZE*SIZE];
-
- public Fragment(ImageLayer... layers) {
- this(layers, null, null);
- }
- public Fragment(ImageLayer[] imageLayers, LiveLayer[] liveLayers, IconLayer[] iconLayers) {
- this.imageLayers = imageLayers;
- this.liveLayers = liveLayers;
- images = new BufferedImage[imageLayers.length];
- for (int i = 0; i < imageLayers.length; i++)
- images[imageLayers[i].getLayerId()] = new BufferedImage(imageLayers[i].size, imageLayers[i].size, BufferedImage.TYPE_INT_ARGB);
- this.iconLayers = iconLayers;
- objects = new MapObject[MAX_OBJECTS_PER_FRAGMENT];
- }
-
- public void load() {
- synchronized (loadLock) {
- if (isLoaded)
- Log.w("This should never happen!");
- int[] data = MinecraftUtil.getBiomeData(blockX >> 2, blockY >> 2, BIOME_SIZE, BIOME_SIZE, true);
- for (int i = 0; i < BIOME_SIZE * BIOME_SIZE; i++)
- biomeData[i] = (short)data[i];
- for (int i = 0; i < imageLayers.length; i++)
- imageLayers[i].load(this);
- for (int i = 0; i < iconLayers.length; i++)
- iconLayers[i].generateMapObjects(this);
- alpha = Options.instance.mapFading.get()?0.0f:1.0f;
- isLoaded = true;
- }
- }
-
- public void recycle() {
- isActive = false;
- isLoaded = false;
- }
-
- public void clearData() {
- for (IconLayer layer : iconLayers)
- layer.clearMapObjects(this);
- isLoaded = false;
- }
-
- public void clear() {
- for (IconLayer layer : iconLayers)
- layer.clearMapObjects(this);
- hasNext = false;
- endOfLine = false;
- isActive = true;
- }
-
- public void drawLiveLayers(float time, Graphics2D g, AffineTransform mat) {
- for (int i = 0; i < liveLayers.length; i++) {
- if (liveLayers[i].isVisible()) {
- liveLayers[i].drawLive(this, g, mat);
- }
- }
-
- }
- public void drawImageLayers(float time, Graphics2D g, AffineTransform mat) {
- if (!isLoaded)
- return;
-
- alpha = Math.min(1.0f, time*3.0f + alpha);
- for (int i = 0; i < images.length; i++) {
- if (imageLayers[i].isVisible()) {
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha * imageLayers[i].getAlpha()));
-
-
- // TOOD: FIX THIS
- g.setTransform(imageLayers[i].getScaledMatrix(mat));
- if (g.getTransform().getScaleX() < 1.0f)
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- else
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
- g.drawImage(images[i], 0, 0, null);
- }
- }
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
- }
-
- public void drawObjects(Graphics2D g, AffineTransform inMatrix) {
- if (alpha != 1.0f)
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
-
- for (int i = 0; i < objectsLength; i++) {
- if (objects[i].parentLayer.isVisible()) {
- drawMatrix.setTransform(inMatrix);
- drawMatrix.translate(objects[i].x, objects[i].y);
- double invZoom = 1.0 / objects[i].parentLayer.map.getZoom();
- drawMatrix.scale(invZoom, invZoom);
- g.setTransform(drawMatrix);
-
- g.drawImage(objects[i].getImage(),
- -(objects[i].getWidth() >> 1),
- -(objects[i].getHeight() >> 1),
- objects[i].getWidth(),
- objects[i].getHeight(),
- null);
- }
- }
- if (alpha != 1.0f)
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
- }
-
- public void addObject(MapObject object) {
- object.rx = object.x + this.blockX;
- object.ry = object.y + this.blockY;
- if (objectsLength >= objects.length) {
- MapObject[] tempObjects = new MapObject[objects.length << 1];
- for (int i = 0; i < objects.length; i++)
- tempObjects[i] = objects[i];
- objects = tempObjects;
- }
- objects[objectsLength] = object;
- objectsLength++;
- }
-
- public void setImageData(int layerId, int[] data) {
- images[layerId].setRGB(0, 0, imageLayers[layerId].size, imageLayers[layerId].size, data, 0, imageLayers[layerId].size);
- }
-
-
- public int getBlockX() {
- return blockX;
- }
- public int getBlockY() {
- return blockY;
- }
- public int getChunkX() {
- return blockX >> 4;
- }
- public int getChunkY() {
- return blockY >> 4;
- }
- public int getFragmentX() {
- return blockX >> SIZE_SHIFT;
- }
- public int getFragmentY() {
- return blockY >> SIZE_SHIFT;
- }
-
- public void setNext(Fragment frag) {
- nextFragment = frag;
- frag.prevFragment = this;
- hasNext = true;
- }
-
- public void remove() {
- if (hasNext)
- prevFragment.setNext(nextFragment);
- else
- prevFragment.hasNext = false;
- }
-
-
- public static int[] getIntArray() {
- return dataCache;
- }
-
- public void removeObject(MapObjectPlayer player) {
- for (int i = 0; i < objectsLength; i++) {
- if (objects[i] == player) {
- objects[i] = objects[objectsLength - 1];
- objectsLength--;
- }
- }
- }
- public BufferedImage getBufferedImage(int layer) {
- return images[layer];
- }
- public void reset() {
- objectsLength = 0;
- isActive = false;
- isLoaded = false;
-
- nextFragment = null;
- prevFragment = null;
- hasNext = false;
-
- endOfLine = false;
- }
- public void repaint() {
- synchronized (loadLock) {
- if (isLoaded)
- for (int i = 0; i < imageLayers.length; i++)
- imageLayers[i].load(this);
- }
- }
-
- public void repaintImageLayer(int id) {
- synchronized (loadLock) {
- if (isLoaded)
- imageLayers[id].load(this);
- }
- }
-}
diff --git a/src/amidst/map/FragmentManager.java b/src/amidst/map/FragmentManager.java
deleted file mode 100644
index b45b970ac..000000000
--- a/src/amidst/map/FragmentManager.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package amidst.map;
-
-import java.util.Collections;
-import java.util.Stack;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import amidst.logging.Log;
-
-public class FragmentManager implements Runnable {
- private int cacheSize = 1024;
-
- private Thread currentThread;
- private boolean running = true;
-
- private Fragment[] fragmentCache;
- private ConcurrentLinkedQueue fragmentQueue;
- private ConcurrentLinkedQueue requestQueue;
- private ConcurrentLinkedQueue recycleQueue;
- private int sleepTick = 0;
-
- private Object queueLock = new Object();
-
- private Stack layerList;
-
- private ImageLayer[] imageLayers;
- private IconLayer[] iconLayers;
- private LiveLayer[] liveLayers;
-
- public FragmentManager(ImageLayer[] imageLayers, LiveLayer[] liveLayers, IconLayer[] iconLayers) {
- fragmentQueue = new ConcurrentLinkedQueue();
- requestQueue = new ConcurrentLinkedQueue();
- recycleQueue = new ConcurrentLinkedQueue();
- layerList = new Stack();
- Collections.addAll(layerList, imageLayers);
-
- fragmentCache = new Fragment[cacheSize];
- for (int i = 0; i < imageLayers.length; i++)
- imageLayers[i].setLayerId(i);
- for (int i = 0; i < cacheSize; i++) {
- fragmentCache[i] = new Fragment(imageLayers, liveLayers, iconLayers);
- fragmentQueue.offer(fragmentCache[i]);
- }
- this.imageLayers = imageLayers;
- this.iconLayers = iconLayers;
- this.liveLayers = liveLayers;
- }
- public void updateLayers(float time) {
- for (ImageLayer layer : imageLayers)
- layer.update(time);
- for (LiveLayer layer : liveLayers)
- layer.update(time);
- for (IconLayer layer : iconLayers)
- layer.update(time);
- }
-
- public void reset() {
- running = false;
- try {
- currentThread.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- recycleQueue.clear();
- requestQueue.clear();
- fragmentQueue.clear();
- for (int i = 0; i < cacheSize; i++) {
- fragmentCache[i].reset();
- fragmentQueue.offer(fragmentCache[i]);
- }
- }
-
- private void increaseFragmentCache() {
- Fragment[] newFragments = new Fragment[cacheSize << 1];
- for (int i = 0; i < cacheSize; i++) {
- newFragments[i] = fragmentCache[i];
- fragmentCache[i] = null;
- }
- for (int i = cacheSize; i < cacheSize << 1; i++) {
- newFragments[i] = new Fragment(imageLayers, liveLayers, iconLayers);
- fragmentQueue.offer(newFragments[i]);
- }
- fragmentCache = newFragments;
- Log.i("FragmentManager cache size increased from " + cacheSize + " to " + (cacheSize << 1));
- cacheSize <<= 1;
- System.gc();
- }
-
- public void repaintFragment(Fragment frag) {
- synchronized (queueLock) {
- frag.repaint();
- }
- }
- public Fragment requestFragment(int x, int y) {
- if (!running)
- return null;
- Fragment frag = null;
- while ((frag = fragmentQueue.poll()) == null)
- increaseFragmentCache();
-
- frag.clear();
- frag.blockX = x;
- frag.blockY = y;
- frag.isActive = true;
- requestQueue.offer(frag);
- return frag;
- }
-
- public void returnFragment(Fragment frag) {
- recycleQueue.offer(frag);
- }
-
- @Override
- public void run() {
- currentThread.setPriority(Thread.MIN_PRIORITY);
-
- while (running) {
- if(!requestQueue.isEmpty() || !recycleQueue.isEmpty()) {
- if (!requestQueue.isEmpty()) {
- synchronized (queueLock) {
- Fragment frag = requestQueue.poll();
- if (frag.isActive && !frag.isLoaded) {
- frag.load();
- sleepTick++;
- if (sleepTick == 10) {
- sleepTick = 0;
- try {
- Thread.sleep(1L);
- } catch (InterruptedException ignored) {}
- }
- }
- }
- }
-
- while (!recycleQueue.isEmpty()) {
- synchronized (queueLock) {
- Fragment frag = recycleQueue.poll();
- frag.recycle();
- fragmentQueue.offer(frag);
- }
- }
- } else {
- sleepTick = 0;
- try {
- Thread.sleep(2L);
- } catch (InterruptedException ignored) {}
- }
- }
-
- }
-
- public void setMap(Map map) {
- for (ImageLayer layer : imageLayers) {
- layer.setMap(map);
- layer.reload();
- }
-
- for (LiveLayer layer : liveLayers) {
- layer.setMap(map);
- layer.reload();
- }
-
- for (IconLayer layer : iconLayers) {
- layer.setMap(map);
- layer.reload();
- }
-
- currentThread = new Thread(this);
-
- running = true;
- currentThread.start();
- }
-
- public int getCacheSize() {
- return cacheSize;
- }
- public int getFreeFragmentQueueSize() {
- return fragmentQueue.size();
- }
- public int getRecycleQueueSize() {
- return recycleQueue.size();
- }
- public int getRequestQueueSize() {
- return requestQueue.size();
- }
- public void repaintFragmentLayer(Fragment frag, int id) {
- synchronized (queueLock) {
- frag.repaintImageLayer(id);
- }
- }
-}
diff --git a/src/amidst/map/IconLayer.java b/src/amidst/map/IconLayer.java
deleted file mode 100644
index 7a17a2072..000000000
--- a/src/amidst/map/IconLayer.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package amidst.map;
-
-
-public class IconLayer extends Layer {
- public IconLayer() {
- }
-
- public void generateMapObjects(Fragment frag) {
-
- }
-
- public void clearMapObjects(Fragment frag) {
- frag.objectsLength = 0;
- }
-}
diff --git a/src/amidst/map/ImageLayer.java b/src/amidst/map/ImageLayer.java
deleted file mode 100644
index 189a03e4b..000000000
--- a/src/amidst/map/ImageLayer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package amidst.map;
-
-import java.awt.geom.AffineTransform;
-
-import amidst.logging.Log;
-
-public abstract class ImageLayer extends Layer {
- protected float alpha = 1.0f;
- protected double scale;
- protected int size;
- private AffineTransform cachedScalingMatrix = new AffineTransform();
- protected int layerId;
-
- private int[] defaultData;
-
- public ImageLayer(int size) {
- this.size = size;
- defaultData = new int[size*size];
- scale = Fragment.SIZE/(double)size;
- for (int i = 0; i < defaultData.length; i++)
- defaultData[i] = 0x00000000;
- }
-
- public int[] getDefaultData() {
- return defaultData;
- }
-
- public void load(Fragment frag) {
- drawToCache(frag);
- }
-
- public AffineTransform getMatrix(AffineTransform inMat) {
- cachedScalingMatrix.setTransform(inMat);
- return cachedScalingMatrix;
- }
- public AffineTransform getScaledMatrix(AffineTransform inMat) {
- cachedScalingMatrix.setTransform(inMat);
- cachedScalingMatrix.scale(scale, scale);
- return cachedScalingMatrix;
- }
-
- public float getAlpha() {
- return alpha;
- }
- public int getLayerId() {
- return layerId;
- }
- public void setLayerId(int id) {
- layerId = id;
- }
- public abstract void drawToCache(Fragment fragment);
-}
-
diff --git a/src/amidst/map/Layer.java b/src/amidst/map/Layer.java
deleted file mode 100644
index d1db95bc8..000000000
--- a/src/amidst/map/Layer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package amidst.map;
-
-public class Layer {
- protected Map map;
-
- public void update(float time) {
-
- }
-
-
- public void setMap(Map map) {
- this.map = map;
- }
- public Map getMap() {
- return map;
- }
- public boolean isVisible() {
- return true;
- }
-
- public void reload() {
-
- }
-}
diff --git a/src/amidst/map/LiveLayer.java b/src/amidst/map/LiveLayer.java
deleted file mode 100644
index 8356e2e7a..000000000
--- a/src/amidst/map/LiveLayer.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package amidst.map;
-
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-
-public abstract class LiveLayer extends Layer {
- public LiveLayer() {
-
- }
- public abstract void drawLive(Fragment fragment, Graphics2D g, AffineTransform mat);
-}
diff --git a/src/amidst/map/Map.java b/src/amidst/map/Map.java
deleted file mode 100644
index 88985cee0..000000000
--- a/src/amidst/map/Map.java
+++ /dev/null
@@ -1,410 +0,0 @@
-package amidst.map;
-
-import java.awt.*;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-
-import amidst.logging.Log;
-import amidst.map.layers.BiomeLayer;
-
-public class Map {
- public static Map instance = null;
- private static final boolean START = true, END = false;
- private FragmentManager fragmentManager;
-
- private Fragment startNode = new Fragment();
-
- private double scale = 0.25;
- private Point2D.Double start;
-
- public int tileWidth, tileHeight;
- public int width = 1, height = 1;
-
- private final Object resizeLock = new Object(), drawLock = new Object();
- private AffineTransform mat;
-
- private boolean firstDraw = true;
-
-
-
- // TODO : This must be changed with the removal of ChunkManager
- public Map(FragmentManager fragmentManager) {
- this.fragmentManager = fragmentManager;
- fragmentManager.setMap(this);
- mat = new AffineTransform();
-
- start = new Point2D.Double();
- addStart(0, 0);
-
- instance = this;
- }
-
- public void resetImageLayer(int id) {
- Fragment frag = startNode;
- while (frag.hasNext) {
- frag = frag.nextFragment;
- fragmentManager.repaintFragmentLayer(frag, id);
- }
- }
- public void resetFragments() {
- Fragment frag = startNode;
- while (frag.hasNext) {
- frag = frag.nextFragment;
- fragmentManager.repaintFragment(frag);
- }
- }
-
- public void draw(Graphics2D g, float time) {
- AffineTransform originalTransform = g.getTransform();
- if (firstDraw) {
- firstDraw = false;
- centerOn(0, 0);
- }
-
- synchronized (drawLock) {
- int size = (int) (Fragment.SIZE * scale);
- int w = width / size + 2;
- int h = height / size + 2;
-
- while (tileWidth < w) addColumn(END);
- while (tileWidth > w) removeColumn(END);
- while (tileHeight < h) addRow(END);
- while (tileHeight > h) removeRow(END);
-
- while (start.x > 0) { start.x -= size; addColumn(START); removeColumn(END); }
- while (start.x < -size) { start.x += size; addColumn(END); removeColumn(START); }
- while (start.y > 0) { start.y -= size; addRow(START); removeRow(END); }
- while (start.y < -size) { start.y += size; addRow(END); removeRow(START); }
-
- Fragment frag = startNode;
- size = Fragment.SIZE;
- if (frag.hasNext) {
- mat.setToIdentity();
- mat.concatenate(originalTransform);
- mat.translate(start.x, start.y);
- mat.scale(scale, scale);
- while (frag.hasNext) {
- frag = frag.nextFragment;
- frag.drawImageLayers(time, g, mat);
- mat.translate(size, 0);
- if (frag.endOfLine)
- mat.translate(-size * w, size);
- }
- }
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
- fragmentManager.updateLayers(time);
- frag = startNode;
- if (frag.hasNext) {
- mat.setToIdentity();
- mat.concatenate(originalTransform);
- mat.translate(start.x, start.y);
- mat.scale(scale, scale);
- while (frag.hasNext) {
- frag = frag.nextFragment;
- frag.drawLiveLayers(time, g, mat);
- mat.translate(size, 0);
- if (frag.endOfLine)
- mat.translate(-size * w, size);
- }
- }
-
- frag = startNode;
- if (frag.hasNext) {
- mat.setToIdentity();
- mat.concatenate(originalTransform);
- mat.translate(start.x, start.y);
- mat.scale(scale, scale);
- while (frag.hasNext) {
- frag = frag.nextFragment;
- frag.drawObjects(g, mat);
- mat.translate(size, 0);
- if (frag.endOfLine)
- mat.translate(-size * w, size);
- }
- }
-
- g.setTransform(originalTransform);
- }
- }
- public void addStart(int x, int y) {
- synchronized (resizeLock) {
- Fragment start = fragmentManager.requestFragment(x, y);
- start.endOfLine = true;
- startNode.setNext(start);
- tileWidth = 1;
- tileHeight = 1;
- }
- }
-
- public void addColumn(boolean start) {
- synchronized (resizeLock) {
- int x = 0;
- Fragment frag = startNode;
- if (start) {
- x = frag.nextFragment.blockX - Fragment.SIZE;
- Fragment newFrag = fragmentManager.requestFragment(x, frag.nextFragment.blockY);
- newFrag.setNext(startNode.nextFragment);
- startNode.setNext(newFrag);
- }
- while (frag.hasNext) {
- frag = frag.nextFragment;
- if (frag.endOfLine) {
- if (start) {
- if (frag.hasNext) {
- Fragment newFrag = fragmentManager.requestFragment(x, frag.blockY + Fragment.SIZE);
- newFrag.setNext(frag.nextFragment);
- frag.setNext(newFrag);
- frag = newFrag;
- }
- } else {
- Fragment newFrag = fragmentManager.requestFragment(frag.blockX + Fragment.SIZE, frag.blockY);
-
- if (frag.hasNext) {
- newFrag.setNext(frag.nextFragment);
- }
- newFrag.endOfLine = true;
- frag.endOfLine = false;
- frag.setNext(newFrag);
- frag = newFrag;
-
- }
- }
- }
- tileWidth++;
- }
- }
- public void removeRow(boolean start) {
- synchronized (resizeLock) {
- if (start) {
- for (int i = 0; i < tileWidth; i++) {
- Fragment frag = startNode.nextFragment;
- frag.remove();
- fragmentManager.returnFragment(frag);
- }
- } else {
- Fragment frag = startNode;
- while (frag.hasNext)
- frag = frag.nextFragment;
- for (int i = 0; i < tileWidth; i++) {
- frag.remove();
- fragmentManager.returnFragment(frag);
- frag = frag.prevFragment;
- }
- }
- tileHeight--;
- }
- }
- public void addRow(boolean start) {
- synchronized (resizeLock) {
- Fragment frag = startNode;
- int y;
- if (start) {
- frag = startNode.nextFragment;
- y = frag.blockY - Fragment.SIZE;
- } else {
- while (frag.hasNext)
- frag = frag.nextFragment;
- y = frag.blockY + Fragment.SIZE;
- }
-
- tileHeight++;
- Fragment newFrag = fragmentManager.requestFragment(startNode.nextFragment.blockX, y);
- Fragment chainFrag = newFrag;
- for (int i = 1; i < tileWidth; i++) {
- Fragment tempFrag = fragmentManager.requestFragment(chainFrag.blockX + Fragment.SIZE, chainFrag.blockY);
- chainFrag.setNext(tempFrag);
- chainFrag = tempFrag;
- if (i == (tileWidth - 1))
- chainFrag.endOfLine = true;
- }
- if (start) {
- chainFrag.setNext(frag);
- startNode.setNext(newFrag);
- } else {
- frag.setNext(newFrag);
- }
- }
- }
- public void removeColumn(boolean start) {
- synchronized (resizeLock) {
- Fragment frag = startNode;
- if (start) {
- fragmentManager.returnFragment(frag.nextFragment);
- startNode.nextFragment.remove();
- }
- while (frag.hasNext) {
- frag = frag.nextFragment;
- if (frag.endOfLine) {
- if (start) {
- if (frag.hasNext) {
- Fragment tempFrag = frag.nextFragment;
- tempFrag.remove();
- fragmentManager.returnFragment(tempFrag);
- }
- } else {
- frag.prevFragment.endOfLine = true;
- frag.remove();
- fragmentManager.returnFragment(frag);
- frag = frag.prevFragment;
- }
- }
- }
- tileWidth--;
- }
- }
-
- public void moveBy(Point2D.Double speed) {
- moveBy(speed.x, speed.y);
- }
-
- public void moveBy(double x, double y) {
- start.x += x;
- start.y += y;
- }
-
- public void centerOn(long x, long y) {
- long fragOffsetX = x % Fragment.SIZE;
- long fragOffsetY = y % Fragment.SIZE;
- long startX = x - fragOffsetX;
- long startY = y - fragOffsetY;
- synchronized (drawLock) {
- while (tileHeight > 1) removeRow(false);
- while (tileWidth > 1) removeColumn(false);
- Fragment frag = startNode.nextFragment;
- frag.remove();
- fragmentManager.returnFragment(frag);
- // TODO: Support longs?
- double offsetX = width >> 1;
- double offsetY = height >> 1;
-
- offsetX -= (fragOffsetX)*scale;
- offsetY -= (fragOffsetY)*scale;
-
- start.x = offsetX;
- start.y = offsetY;
-
- addStart((int)startX, (int)startY);
- }
- }
-
- public void setZoom(double scale) {
- this.scale = scale;
- }
-
- public double getZoom() {
- return scale;
- }
-
- public Point2D.Double getScaled(double oldScale, double newScale, Point p) {
- double baseX = p.x - start.x;
- double scaledX = baseX - (baseX / oldScale) * newScale;
-
- double baseY = p.y - start.y;
- double scaledY = baseY - (baseY / oldScale) * newScale;
-
- return new Point2D.Double(scaledX, scaledY);
- }
-
- public void dispose() {
- synchronized (drawLock) {
- fragmentManager.reset();
- }
- }
-
- public Fragment getFragmentAt(Point position) {
- Fragment frag = startNode;
- Point cornerPosition = new Point(position.x >> Fragment.SIZE_SHIFT, position.y >> Fragment.SIZE_SHIFT);
- Point fragmentPosition = new Point();
- while (frag.hasNext) {
- frag = frag.nextFragment;
- fragmentPosition.x = frag.getFragmentX();
- fragmentPosition.y = frag.getFragmentY();
- if (cornerPosition.equals(fragmentPosition))
- return frag;
- }
- return null;
- }
-
- public MapObject getObjectAt(Point position, double maxRange) {
- double x = start.x;
- double y = start.y;
- MapObject closestObject = null;
- double closestDistance = maxRange;
- Fragment frag = startNode;
- int size = (int) (Fragment.SIZE * scale);
- while (frag.hasNext) {
- frag = frag.nextFragment;
- for (int i = 0; i < frag.objectsLength; i ++) {
- if (frag.objects[i].parentLayer.isVisible()) {
- Point objPosition = frag.objects[i].getLocation();
- objPosition.x *= scale;
- objPosition.y *= scale;
- objPosition.x += x;
- objPosition.y += y;
-
- double distance = objPosition.distance(position);
- if (distance < closestDistance) {
- closestDistance = distance;
- closestObject = frag.objects[i];
- }
- }
- }
- x += size;
- if (frag.endOfLine) {
- x = start.x;
- y += size;
- }
- }
- return closestObject;
- }
-
- public Point screenToLocal(Point inPoint) {
- Point point = inPoint.getLocation();
-
- point.x -= start.x;
- point.y -= start.y;
-
- // TODO: int -> double -> int = bad?
- point.x /= scale;
- point.y /= scale;
-
- point.x += startNode.nextFragment.blockX;
- point.y += startNode.nextFragment.blockY;
-
- return point;
- }
- public String getBiomeNameAt(Point point) {
- Fragment frag = startNode;
- while (frag.hasNext) {
- frag = frag.nextFragment;
- if ((frag.blockX <= point.x) &&
- (frag.blockY <= point.y) &&
- (frag.blockX + Fragment.SIZE > point.x) &&
- (frag.blockY + Fragment.SIZE > point.y)) {
- int x = point.x - frag.blockX;
- int y = point.y - frag.blockY;
-
- return BiomeLayer.getBiomeNameForFragment(frag, x, y);
- }
- }
- return "Unknown";
- }
-
- public String getBiomeAliasAt(Point point) {
- Fragment frag = startNode;
- while (frag.hasNext) {
- frag = frag.nextFragment;
- if ((frag.blockX <= point.x) &&
- (frag.blockY <= point.y) &&
- (frag.blockX + Fragment.SIZE > point.x) &&
- (frag.blockY + Fragment.SIZE > point.y)) {
- int x = point.x - frag.blockX;
- int y = point.y - frag.blockY;
-
- return BiomeLayer.getBiomeAliasForFragment(frag, x, y);
- }
- }
- return "Unknown";
- }
-
-}
diff --git a/src/amidst/map/MapMarkers.java b/src/amidst/map/MapMarkers.java
deleted file mode 100644
index 1a421c0a3..000000000
--- a/src/amidst/map/MapMarkers.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package amidst.map;
-
-import amidst.resources.ResourceLoader;
-
-import java.awt.image.BufferedImage;
-
-/** Contains information about all possible Map Markers.
- * Map objects use either its or their own icon
- * TODO: link to test.amidst.map object class
- */
-public enum MapMarkers {
- NETHER_FORTRESS,
- PLAYER,
- SLIME,
- STRONGHOLD,
- JUNGLE,
- DESERT,
- VILLAGE,
- SPAWN,
- WITCH,
- OCEAN_MONUMENT;
-
- public final BufferedImage image;
-
- private MapMarkers() {
- String fileName = this.toString().toLowerCase() + ".png";
- image = ResourceLoader.getImage(fileName);
- }
-}
diff --git a/src/amidst/map/MapObject.java b/src/amidst/map/MapObject.java
deleted file mode 100644
index 371bd5170..000000000
--- a/src/amidst/map/MapObject.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package amidst.map;
-import amidst.Options;
-import amidst.map.MapMarkers;
-
-import java.awt.Point;
-import java.awt.image.BufferedImage;
-
-public class MapObject extends Point {
- public MapMarkers type;
- public int rx, ry;
- public double localScale = 1.0;
- @Deprecated
- public double tempDist = 0;
- public IconLayer parentLayer;
-
- public MapObject(MapMarkers eType, int x, int y) {
- super(x, y);
- type = eType;
- }
-
- public String getName() {
- return type.toString();
- }
-
- public int getWidth() {
- return (int)(type.image.getWidth() * localScale);
- }
- public int getHeight() {
- return (int)(type.image.getHeight() * localScale);
- }
-
- public BufferedImage getImage() {
- return type.image;
- }
-
- public boolean isSelectable() {
- return Options.instance.showVillages.isSelected();
- }
-
- public MapObject setParent(IconLayer layer) {
- parentLayer = layer;
- return this;
- }
-}
diff --git a/src/amidst/map/MapObjectDesertTemple.java b/src/amidst/map/MapObjectDesertTemple.java
deleted file mode 100644
index 3380ac2ca..000000000
--- a/src/amidst/map/MapObjectDesertTemple.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectDesertTemple extends MapObject {
- public MapObjectDesertTemple(int eX, int eY) {
- super(MapMarkers.DESERT, eX, eY);
- }
-}
diff --git a/src/amidst/map/MapObjectJungleTemple.java b/src/amidst/map/MapObjectJungleTemple.java
deleted file mode 100644
index 1d53986a3..000000000
--- a/src/amidst/map/MapObjectJungleTemple.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectJungleTemple extends MapObject {
- public MapObjectJungleTemple(int eX, int eY) {
- super(MapMarkers.JUNGLE, eX, eY);
- }
-}
diff --git a/src/amidst/map/MapObjectNether.java b/src/amidst/map/MapObjectNether.java
deleted file mode 100644
index ef408c7c7..000000000
--- a/src/amidst/map/MapObjectNether.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectNether extends MapObject {
- public MapObjectNether(int eX, int eY) {
- super(MapMarkers.NETHER_FORTRESS, eX, eY);
- }
-}
diff --git a/src/amidst/map/MapObjectOceanMonument.java b/src/amidst/map/MapObjectOceanMonument.java
deleted file mode 100644
index 61710e0d4..000000000
--- a/src/amidst/map/MapObjectOceanMonument.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectOceanMonument extends MapObject {
- public MapObjectOceanMonument(int eX, int eY) {
- super(MapMarkers.OCEAN_MONUMENT, eX, eY);
- }
-}
diff --git a/src/amidst/map/MapObjectPlayer.java b/src/amidst/map/MapObjectPlayer.java
deleted file mode 100644
index 6cc44b92a..000000000
--- a/src/amidst/map/MapObjectPlayer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package amidst.map;
-
-import java.awt.image.BufferedImage;
-
-public class MapObjectPlayer extends MapObject {
- public String name;
- public boolean needSave;
- private BufferedImage marker;
- public int globalX, globalY;
- public Fragment parentFragment = null;
-
- public MapObjectPlayer(String name, int x, int y) {
- super(MapMarkers.PLAYER,
- ((x < 0)?Fragment.SIZE:0) + x % Fragment.SIZE,
- ((y < 0)?Fragment.SIZE:0) + y % Fragment.SIZE);
- globalX = x;
- globalY = y;
- marker = type.image;
- needSave = false;
- this.name = name;
- }
-
-
- @Override
- public int getWidth() {
- return (int)(marker.getWidth()*localScale);
- }
- @Override
- public int getHeight() {
- return (int)(marker.getHeight()*localScale);
- }
- public void setPosition(int x, int y) {
- this.globalX = x;
- this.globalY = y;
- this.x = ((x < 0)?Fragment.SIZE:0) + x % Fragment.SIZE;
- this.y = ((y < 0)?Fragment.SIZE:0) + y % Fragment.SIZE;
- needSave = true;
- }
-
- @Override
- public BufferedImage getImage() {
- return marker;
- }
-
- public void setMarker(BufferedImage img) {
- this.marker = img;
- }
- @Override
- public String getName() {
- return name;
- }
- @Override
- public String toString() {
- return "Player \"" + name + "\" at (" + x + ", " + y + ")";
- }
-}
diff --git a/src/amidst/map/MapObjectSpawn.java b/src/amidst/map/MapObjectSpawn.java
deleted file mode 100644
index 4fc9963ea..000000000
--- a/src/amidst/map/MapObjectSpawn.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package amidst.map;
-
-/** Used mainly to be override its toString method for use in choices
- */
-public class MapObjectSpawn extends MapObject {
- public int globalX, globalY;
- public MapObjectSpawn(int x, int y) {
- super(MapMarkers.SPAWN,
- ((x < 0)?Fragment.SIZE:0) + x % Fragment.SIZE,
- ((y < 0)?Fragment.SIZE:0) + y % Fragment.SIZE);
-
- globalX = x;
- globalY = y;
- }
-
- @Override
- public String toString() {
- return "Spawn point at (" + x + ", " + y + ")";
- }
-}
diff --git a/src/amidst/map/MapObjectStronghold.java b/src/amidst/map/MapObjectStronghold.java
deleted file mode 100644
index cd7b8bd37..000000000
--- a/src/amidst/map/MapObjectStronghold.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package amidst.map;
-
-/** Used mainly to be override its toString method for use in choices
- */
-public class MapObjectStronghold extends MapObject {
- public MapObjectStronghold(int x, int y) {
- super(MapMarkers.STRONGHOLD, x, y);
- }
-
- @Override
- public String toString() {
- return "Stronghold at (" + x + ", " + y + ")";
- }
-}
diff --git a/src/amidst/map/MapObjectVillage.java b/src/amidst/map/MapObjectVillage.java
deleted file mode 100644
index f51ecccfc..000000000
--- a/src/amidst/map/MapObjectVillage.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectVillage extends MapObject {
- public MapObjectVillage(int eX, int eY) {
- super(MapMarkers.VILLAGE, eX, eY);
- }
-}
\ No newline at end of file
diff --git a/src/amidst/map/MapObjectWitchHut.java b/src/amidst/map/MapObjectWitchHut.java
deleted file mode 100644
index 126900947..000000000
--- a/src/amidst/map/MapObjectWitchHut.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.map;
-
-public class MapObjectWitchHut extends MapObject {
- public MapObjectWitchHut(int eX, int eY) {
- super(MapMarkers.WITCH, eX, eY);
- }
-}
diff --git a/src/amidst/map/layers/BiomeLayer.java b/src/amidst/map/layers/BiomeLayer.java
deleted file mode 100644
index 572e3ae5c..000000000
--- a/src/amidst/map/layers/BiomeLayer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package amidst.map.layers;
-
-import MoF.MapViewer;
-import amidst.Options;
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.map.Fragment;
-import amidst.map.ImageLayer;
-import amidst.minecraft.Biome;
-
-public class BiomeLayer extends ImageLayer {
- public static BiomeLayer instance;
- protected static int size = Fragment.SIZE >> 2;
-
- protected boolean[] selectedBiomes = new boolean[Biome.biomes.length];
- private boolean inHighlightMode = false;
-
- public BiomeLayer() {
- super(size);
- instance = this;
- deselectAllBiomes();
- }
-
- public void selectAllBiomes() {
- setSelectedAllBiomes(true);
- }
- public void deselectAllBiomes() {
- setSelectedAllBiomes(false);
- }
-
- public void selectBiome(int id) {
- setSelected(id, true);
- }
- public void deselectBiome(int id) {
- setSelected(id, false);
- }
-
- public void setHighlightMode(boolean enabled) {
- inHighlightMode = enabled;
- }
-
- public void toggleBiomeSelect(int id) {
- setSelected(id, !selectedBiomes[id]);
- }
- public void setSelected(int id, boolean value) {
- selectedBiomes[id] = value;
- }
-
- public void setSelectedAllBiomes(boolean value) {
- for (int i = 0; i < selectedBiomes.length; i++)
- selectedBiomes[i] = value;
- }
-
- @Override
- public void drawToCache(Fragment fragment) {
- int[] dataCache = Fragment.getIntArray();
- if (inHighlightMode) {
- for (int i = 0; i < size*size; i++)
- if (!selectedBiomes[fragment.biomeData[i]])
- dataCache[i] = Util.deselectColor(Biome.biomes[fragment.biomeData[i]].color);
- else
- dataCache[i] = Biome.biomes[fragment.biomeData[i]].color;
- } else {
- for (int i = 0; i < size*size; i++)
- dataCache[i] = Biome.biomes[fragment.biomeData[i]].color;
- }
-
-
- fragment.setImageData(layerId, dataCache);
- }
-
- public static int getBiomeForFragment(Fragment frag, int blockX, int blockY) {
- return frag.biomeData[(blockY >> 2) * Fragment.BIOME_SIZE + (blockX >> 2)];
- }
-
- public static String getBiomeNameForFragment(Fragment frag, int blockX, int blockY) {
- return Biome.biomes[getBiomeForFragment(frag, blockX, blockY)].name;
- }
- public static String getBiomeAliasForFragment(Fragment frag, int blockX, int blockY) {
- return Options.instance.biomeColorProfile.getAliasForId(getBiomeForFragment(frag, blockX, blockY));
- }
-
- public boolean isBiomeSelected(int id) {
- return selectedBiomes[id];
- }
-}
diff --git a/src/amidst/map/layers/GridLayer.java b/src/amidst/map/layers/GridLayer.java
deleted file mode 100644
index 45148a5f9..000000000
--- a/src/amidst/map/layers/GridLayer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package amidst.map.layers;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.LiveLayer;
-
-
-public class GridLayer extends LiveLayer {
- private static Font drawFont = new Font("arial", Font.BOLD, 16);
- private static StringBuffer textBuffer = new StringBuffer(128);
- private static char[] textCache = new char[128];
-
- public GridLayer() {
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showGrid.get();
- }
- @Override
- public void drawLive(Fragment fragment, Graphics2D g, AffineTransform inMat) {
- g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- AffineTransform mat = new AffineTransform(inMat);
-
- textBuffer.setLength(0);
- textBuffer.append(fragment.getChunkX() << 4);
- textBuffer.append(", ");
- textBuffer.append(fragment.getChunkY() << 4);
-
- textBuffer.getChars(0, textBuffer.length(), textCache, 0);
-
- int stride = (int)(.25/map.getZoom());
-
-
-
- g.setColor(Color.black);
- g.setTransform(mat);
- int gridX = (fragment.getFragmentX() % (stride + 1));
- int gridY = (fragment.getFragmentY() % (stride + 1));
- if (gridY == 0)
- g.drawLine(0, 0, Fragment.SIZE, 0);
- if (gridY == stride)
- g.drawLine(0, Fragment.SIZE, Fragment.SIZE, Fragment.SIZE);
- if (gridX == 0)
- g.drawLine(0, 0, 0, Fragment.SIZE);
- if (gridX == stride)
- g.drawLine(Fragment.SIZE, 0, Fragment.SIZE, Fragment.SIZE);
-
- if (gridX != 0)
- return;
- if (gridY != 0)
- return;
- double invZoom = 1.0 / map.getZoom();
- mat.scale(invZoom, invZoom);
- g.setTransform(mat);
- g.setFont(drawFont);
- g.drawChars(textCache, 0, textBuffer.length(), 12, 17);
- g.drawChars(textCache, 0, textBuffer.length(), 8, 17);
- g.drawChars(textCache, 0, textBuffer.length(), 10, 19);
- g.drawChars(textCache, 0, textBuffer.length(), 10, 15);
-
- // This makes the text outline a bit thicker, but seems unneeded.
- //g.drawChars(textCache, 0, textBuffer.length(), 12, 15);
- //g.drawChars(textCache, 0, textBuffer.length(), 12, 19);
- //g.drawChars(textCache, 0, textBuffer.length(), 8, 15);
- //g.drawChars(textCache, 0, textBuffer.length(), 8, 19);
-
- g.setColor(Color.white);
- g.drawChars(textCache, 0, textBuffer.length(), 10, 17);
-
- g.setTransform(inMat);
- }
-
-}
diff --git a/src/amidst/map/layers/NetherFortressLayer.java b/src/amidst/map/layers/NetherFortressLayer.java
deleted file mode 100644
index 24c54443a..000000000
--- a/src/amidst/map/layers/NetherFortressLayer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package amidst.map.layers;
-
-import java.util.Random;
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectNether;
-
-public class NetherFortressLayer extends IconLayer {
- private Random random = new Random();
-
- public NetherFortressLayer() {
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showNetherFortresses.get();
- }
- @Override
- public void generateMapObjects(Fragment frag) {
- int size = Fragment.SIZE >> 4;
- for (int x = 0; x < size; x++) {
- for (int y = 0; y < size; y++) {
- int chunkX = x + frag.getChunkX();
- int chunkY = y + frag.getChunkY();
- if (checkChunk(chunkX, chunkY)) {
- frag.addObject(new MapObjectNether(x << 4, y << 4).setParent(this));
- }
- }
- }
- }
-
-
- public boolean checkChunk(int chunkX, int chunkY) {
- int i = chunkX >> 4;
- int j = chunkY >> 4;
-
- random.setSeed(i ^ j << 4 ^ Options.instance.seed);
- random.nextInt();
-
- if (random.nextInt(3) != 0) {
- return false;
- }
- if (chunkX != (i << 4) + 4 + random.nextInt(8)) {
- return false;
- }
-
- return chunkY == (j << 4) + 4 + random.nextInt(8);
- }
-}
diff --git a/src/amidst/map/layers/OceanMonumentLayer.java b/src/amidst/map/layers/OceanMonumentLayer.java
deleted file mode 100644
index 8327ca048..000000000
--- a/src/amidst/map/layers/OceanMonumentLayer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package amidst.map.layers;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectOceanMonument;
-import amidst.map.MapObjectVillage;
-import amidst.minecraft.Biome;
-import amidst.minecraft.MinecraftUtil;
-
-public class OceanMonumentLayer extends IconLayer {
-
- public static List validBiomes = Arrays.asList(
- new Biome[] {
- Biome.deepOcean,
- Biome.deepOceanM, // Not sure if the extended biomes count
- }
- );
- public static List validSurroundingBiomes = Arrays.asList(
- new Biome[] {
- Biome.ocean,
- Biome.deepOcean,
- Biome.frozenOcean,
- Biome.river,
- Biome.frozenRiver,
- // Not sure if the extended biomes count
- Biome.oceanM,
- Biome.deepOceanM,
- Biome.frozenOceanM,
- Biome.riverM,
- Biome.frozenRiverM,
- }
- );
-
- private Random random = new Random();
-
- public OceanMonumentLayer() {
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showOceanMonuments.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- int size = Fragment.SIZE >> 4;
- for (int x = 0; x < size; x++) {
- for (int y = 0; y < size; y++) {
- int chunkX = x + frag.getChunkX();
- int chunkY = y + frag.getChunkY();
- if (checkChunk(chunkX, chunkY)) {
- frag.addObject(new MapObjectOceanMonument(x << 4, y << 4).setParent(this));
- }
- }
- }
- }
-
- /** puts the World Random seed to a specific state dependent on the inputs */
- public void setRandomSeed(int a, int b, int structure_magic_number)
- {
- long positionSeed = (long)a * 341873128712L + (long)b * 132897987541L + Options.instance.seed + (long)structure_magic_number;
- random.setSeed(positionSeed);
- }
-
-
- public boolean checkChunk(int chunkX, int chunkY) {
-
- boolean result = false;
-
- byte maxDistanceBetweenScatteredFeatures = 32;
- byte minDistanceBetweenScatteredFeatures = 5;
- int structureSize = 29;
- int structureMagicNumber = 10387313; // 10387313 is the magic salt for ocean monuments
-
- int chunkXadj = chunkX;
- int chunkYadj = chunkY;
- if (chunkXadj < 0) chunkXadj -= maxDistanceBetweenScatteredFeatures - 1;
- if (chunkYadj < 0) chunkYadj -= maxDistanceBetweenScatteredFeatures - 1;
-
- int a = chunkXadj / maxDistanceBetweenScatteredFeatures;
- int b = chunkYadj / maxDistanceBetweenScatteredFeatures;
-
- setRandomSeed(a, b, structureMagicNumber);
-
- int distanceRange = maxDistanceBetweenScatteredFeatures - minDistanceBetweenScatteredFeatures;
- a *= maxDistanceBetweenScatteredFeatures;
- b *= maxDistanceBetweenScatteredFeatures;
- a += (random.nextInt(distanceRange) + random.nextInt(distanceRange)) / 2;
- b += (random.nextInt(distanceRange) + random.nextInt(distanceRange)) / 2;
-
- if ((chunkX == a) && (chunkY == b)) {
-
- // Note that getBiomeAt() is full-resolution biome data, while isValidBiome() is calculated using
- // quarter-resolution biome data. This is identical to how Minecraft calculates it.
- result =
- MinecraftUtil.getBiomeAt( chunkX * 16 + 8, chunkY * 16 + 8) == Biome.deepOcean &&
- MinecraftUtil.isValidBiome(chunkX * 16 + 8, chunkY * 16 + 8, structureSize, validSurroundingBiomes);
- }
- return result;
- }
-}
diff --git a/src/amidst/map/layers/PlayerLayer.java b/src/amidst/map/layers/PlayerLayer.java
deleted file mode 100644
index d5045db58..000000000
--- a/src/amidst/map/layers/PlayerLayer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package amidst.map.layers;
-
-import java.util.List;
-import MoF.SaveLoader;
-import MoF.SkinManager;
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectPlayer;
-
-public class PlayerLayer extends IconLayer {
- public SaveLoader saveLoader;
- public static SkinManager skinManager = new SkinManager();
- public boolean isEnabled;
- static {
- skinManager.start();
- }
- public PlayerLayer() {
-
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showPlayers.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- if (!isEnabled) return;
- List players = saveLoader.getPlayers();
- for (MapObjectPlayer player : players) {
- if ((player.globalX >= frag.blockX) &&
- (player.globalX < frag.blockX + Fragment.SIZE) &&
- (player.globalY >= frag.blockY) &&
- (player.globalY < frag.blockY + Fragment.SIZE)) {
- player.parentLayer = this;
- player.parentFragment = frag;
- frag.addObject(player);
- }
- }
- }
-
- @Override
- public void clearMapObjects(Fragment frag) {
- for (int i = 0; i < frag.objectsLength; i++) {
- if (frag.objects[i] instanceof MapObjectPlayer)
- ((MapObjectPlayer)frag.objects[i]).parentFragment = null;
-
- }
- super.clearMapObjects(frag);
-
- }
- public void setPlayers(SaveLoader save) {
- saveLoader = save;
-
- for (MapObjectPlayer player : saveLoader.getPlayers())
- skinManager.addPlayer(player);
- }
-}
diff --git a/src/amidst/map/layers/SlimeLayer.java b/src/amidst/map/layers/SlimeLayer.java
deleted file mode 100644
index 08332db42..000000000
--- a/src/amidst/map/layers/SlimeLayer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package amidst.map.layers;
-
-import java.util.Random;
-
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.ImageLayer;
-
-public class SlimeLayer extends ImageLayer {
- private static int size = Fragment.SIZE >> 4;
- private Random random = new Random();
- public SlimeLayer() {
- super(size);
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showSlimeChunks.get();
- }
-
- @Override
- public void drawToCache(Fragment fragment) {
- 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(Options.instance.seed +
- xPosition * xPosition * 0x4c1906 +
- xPosition * 0x5ac0db +
- yPosition * yPosition * 0x4307a7L +
- yPosition * 0x5f24f ^ 0x3ad8025f);
-
- dataCache[y * size + x] = (random.nextInt(10) == 0) ? 0xA0FF00FF : 0x00000000;
- }
- }
-
- fragment.setImageData(layerId, dataCache);
- }
-
-}
diff --git a/src/amidst/map/layers/SpawnLayer.java b/src/amidst/map/layers/SpawnLayer.java
deleted file mode 100644
index 0cd011335..000000000
--- a/src/amidst/map/layers/SpawnLayer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package amidst.map.layers;
-
-import java.awt.Point;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Random;
-
-import amidst.Options;
-import amidst.logging.Log;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectSpawn;
-import amidst.minecraft.Biome;
-import amidst.minecraft.MinecraftUtil;
-
-public class SpawnLayer extends IconLayer {
- private MapObjectSpawn spawnObject;
- public static final ArrayList validBiomes = new ArrayList(Arrays.asList(
- Biome.forest,
- Biome.plains,
- Biome.taiga,
- Biome.taigaHills,
- Biome.forestHills,
- Biome.jungle,
- Biome.jungleHills
- ));
-
- public SpawnLayer() {
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showSpawn.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- if ((spawnObject.globalX >= frag.blockX) &&
- (spawnObject.globalX < frag.blockX + Fragment.SIZE) &&
- (spawnObject.globalY >= frag.blockY) &&
- (spawnObject.globalY < frag.blockY + Fragment.SIZE)) {
- spawnObject.parentLayer = this;
- frag.addObject(spawnObject);
- }
- }
-
- private Point getSpawnPosition() {
- Random random = new Random(Options.instance.seed);
- Point location = MinecraftUtil.findValidLocation(0, 0, 256, validBiomes, random);
- int x = 0;
- int y = 0;
- if (location != null) {
- x = location.x;
- y = location.y;
- } else {
- Log.debug("Unable to find spawn biome.");
- }
-
- return new Point(x, y);
- }
-
- @Override
- public void reload() {
- Point spawnCenter = getSpawnPosition();
- spawnObject = new MapObjectSpawn(spawnCenter.x, spawnCenter.y);
- }
-
-}
diff --git a/src/amidst/map/layers/StrongholdLayer.java b/src/amidst/map/layers/StrongholdLayer.java
deleted file mode 100644
index fd588d23f..000000000
--- a/src/amidst/map/layers/StrongholdLayer.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package amidst.map.layers;
-
-import java.awt.Point;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectStronghold;
-import amidst.minecraft.Biome;
-import amidst.minecraft.MinecraftUtil;
-import amidst.version.VersionInfo;
-
-public class StrongholdLayer extends IconLayer {
- public static StrongholdLayer instance;
-
- private static final Biome[] biomesDefault = {
- Biome.desert,
- Biome.forest,
- Biome.extremeHills,
- Biome.swampland
- };
- private static final Biome[] biomes1_0 = {
- Biome.desert,
- Biome.forest,
- Biome.extremeHills,
- Biome.swampland,
- Biome.taiga,
- Biome.icePlains,
- Biome.iceMountains
- };
- private static final Biome[] biomes1_1 = {
- Biome.desert,
- Biome.forest,
- Biome.extremeHills,
- Biome.swampland,
- Biome.taiga,
- Biome.icePlains,
- Biome.iceMountains,
- Biome.desertHills,
- Biome.forestHills,
- Biome.extremeHillsEdge
- };
- private static final Biome[] biomes12w03a = {
- Biome.desert,
- Biome.forest,
- Biome.extremeHills,
- Biome.swampland,
- Biome.taiga,
- Biome.icePlains,
- Biome.iceMountains,
- Biome.desertHills,
- Biome.forestHills,
- Biome.extremeHillsEdge,
- Biome.jungle,
- Biome.jungleHills
- };
-
- private MapObjectStronghold[] strongholds = new MapObjectStronghold[3];
-
- public StrongholdLayer() {
- instance = this;
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showStrongholds.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- int size = Fragment.SIZE >> 4;
- for (int x = 0; x < size; x++) {
- for (int y = 0; y < size; y++) {
- int chunkX = x + frag.getChunkX();
- int chunkY = y + frag.getChunkY();
- if (checkChunk(chunkX, chunkY)) { // TODO: This does not need a per-chunk test!
- // FIXME: Possible use of checkChunk causing negative icons to be misaligned!
- frag.addObject(new MapObjectStronghold(x << 4, y << 4).setParent(this));
- }
- }
- }
- }
-
- public void findStrongholds() {
- Random random = new Random();
- random.setSeed(Options.instance.seed);
-
-
- // TODO: Replace this system!
- Biome[] validBiomes = biomesDefault;
- if (MinecraftUtil.getVersion() == VersionInfo.V1_9pre6 || MinecraftUtil.getVersion() == VersionInfo.V1_0)
- validBiomes = biomes1_0;
- if (MinecraftUtil.getVersion() == VersionInfo.V1_1)
- validBiomes = biomes1_1;
- if (MinecraftUtil.getVersion().isAtLeast(VersionInfo.V12w03a))
- validBiomes = biomes12w03a;
-
- List biomeArrayList = Arrays.asList(validBiomes);
-
- if (MinecraftUtil.getVersion().isAtLeast(VersionInfo.V13w36a)) {
- biomeArrayList = new ArrayList();
- for (int i = 0; i < Biome.biomes.length; i++) {
- if ((Biome.biomes[i] != null) && (Biome.biomes[i].type.value1 > 0f)) {
- biomeArrayList.add(Biome.biomes[i]);
- }
- }
- }
-
- double angle = random.nextDouble() * 3.141592653589793D * 2.0D;
- for (int i = 0; i < 3; i++) {
- double distance = (1.25D + random.nextDouble()) * 32.0D;
- int x = (int)Math.round(Math.cos(angle) * distance);
- int y = (int)Math.round(Math.sin(angle) * distance);
-
-
-
- Point strongholdLocation = MinecraftUtil.findValidLocation((x << 4) + 8, (y << 4) + 8, 112, biomeArrayList, random);
- if (strongholdLocation != null) {
- x = strongholdLocation.x >> 4;
- y = strongholdLocation.y >> 4;
- }
- strongholds[i] = new MapObjectStronghold((x << 4), (y << 4));
- angle += 6.283185307179586D / 3.0D;
- }
- }
-
- public boolean checkChunk(int chunkX, int chunkY) {
- for (int i = 0; i < 3; i++) {
- int strongholdChunkX = strongholds[i].x >> 4;
- int strongholdChunkY = strongholds[i].y >> 4;
- if ((strongholdChunkX == chunkX) && (strongholdChunkY == chunkY))
- return true;
- }
- return false;
- }
-
- public MapObjectStronghold[] getStrongholds() {
- return strongholds;
- }
-
- @Override
- public void reload() {
- findStrongholds();
- }
-}
diff --git a/src/amidst/map/layers/TempleLayer.java b/src/amidst/map/layers/TempleLayer.java
deleted file mode 100644
index 68d50d4eb..000000000
--- a/src/amidst/map/layers/TempleLayer.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package amidst.map.layers;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-import amidst.Options;
-import amidst.logging.Log;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectDesertTemple;
-import amidst.map.MapObjectJungleTemple;
-import amidst.map.MapObjectWitchHut;
-import amidst.minecraft.Biome;
-import amidst.minecraft.MinecraftUtil;
-import amidst.version.VersionInfo;
-
-public class TempleLayer extends IconLayer {
- public static List validBiomes;
- private Random random = new Random();
-
- public TempleLayer() {
- validBiomes = getValidBiomes();
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showTemples.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- int size = Fragment.SIZE >> 4;
- for (int x = 0; x < size; x++) {
- for (int y = 0; y < size; y++) {
- int chunkX = x + frag.getChunkX();
- int chunkY = y + frag.getChunkY();
- Biome chunkBiome = checkChunk(chunkX, chunkY);
- if (chunkBiome != null) {
-
- if (chunkBiome == Biome.swampland) {
- frag.addObject(new MapObjectWitchHut(x << 4, y << 4).setParent(this));
- } else if (chunkBiome.name.contains("Jungle")) {
- frag.addObject(new MapObjectJungleTemple(x << 4, y << 4).setParent(this));
- } else if (chunkBiome.name.contains("Desert")) {
- frag.addObject(new MapObjectDesertTemple(x << 4, y << 4).setParent(this));
- } else {
- Log.e("No known structure for this biome type. checkChunk() may be faulting.");
- }
- }
- }
- }
- }
-
- public List getValidBiomes() {
- Biome[] validBiomes;
-
- if (MinecraftUtil.getVersion().isAtLeast(VersionInfo.V1_4_2)) {
- validBiomes = new Biome[] {
- Biome.desert,
- Biome.desertHills,
- Biome.jungle,
- Biome.jungleHills,
- Biome.swampland
- };
- } else if (MinecraftUtil.getVersion().isAtLeast(VersionInfo.V12w22a)) {
- validBiomes = new Biome[] {
- Biome.desert,
- Biome.desertHills,
- Biome.jungle
- };
- } else {
- validBiomes = new Biome[] {
- Biome.desert,
- Biome.desertHills
- };
- }
-
- return Arrays.asList(validBiomes);
- }
-
- /**
- * @return null if there is no structure in the chunk, otherwise
- * returns the biome (from validBiomes) that determines the type
- * of structure.
- */
- public Biome checkChunk(int chunkX, int chunkY) {
-
- Biome result = null;
-
- int maxDistanceBetweenScatteredFeatures = 32;
- int minDistanceBetweenScatteredFeatures = 8;
-
- int k = chunkX;
- int m = chunkY;
- if (chunkX < 0) chunkX -= maxDistanceBetweenScatteredFeatures - 1;
- if (chunkY < 0) chunkY -= maxDistanceBetweenScatteredFeatures - 1;
-
- int n = chunkX / maxDistanceBetweenScatteredFeatures;
- int i1 = chunkY / maxDistanceBetweenScatteredFeatures;
- long l1 = n * 341873128712L + i1 * 132897987541L + Options.instance.seed + 14357617;
- random.setSeed(l1);
- n *= maxDistanceBetweenScatteredFeatures;
- i1 *= maxDistanceBetweenScatteredFeatures;
- n += random.nextInt(maxDistanceBetweenScatteredFeatures - minDistanceBetweenScatteredFeatures);
- i1 += random.nextInt(maxDistanceBetweenScatteredFeatures - minDistanceBetweenScatteredFeatures);
-
- if (k == n && m == i1) {
- // This is a potential feature biome
-
- // Since the structure-size that would be passed to MinecraftUtil.isValidBiome()
- // is 0, we can use MinecraftUtil.getBiomeAt() here instead, which tells us what kind of
- // structure it is.
- Biome chunkBiome = MinecraftUtil.getBiomeAt(k * 16 + 8, m * 16 + 8);
- if (validBiomes.contains(chunkBiome)) result = chunkBiome;
- }
- return result;
- }
-}
diff --git a/src/amidst/map/layers/VillageLayer.java b/src/amidst/map/layers/VillageLayer.java
deleted file mode 100644
index 8b7eb245b..000000000
--- a/src/amidst/map/layers/VillageLayer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package amidst.map.layers;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-import amidst.Options;
-import amidst.map.Fragment;
-import amidst.map.IconLayer;
-import amidst.map.MapObjectVillage;
-import amidst.minecraft.Biome;
-import amidst.minecraft.MinecraftUtil;
-
-public class VillageLayer extends IconLayer {
- public static List validBiomes = Arrays.asList(new Biome[] { Biome.plains, Biome.desert, Biome.savanna});
- private Random random = new Random();
-
- public VillageLayer() {
- }
-
- @Override
- public boolean isVisible() {
- return Options.instance.showVillages.get();
- }
-
- @Override
- public void generateMapObjects(Fragment frag) {
- int size = Fragment.SIZE >> 4;
- for (int x = 0; x < size; x++) {
- for (int y = 0; y < size; y++) {
- int chunkX = x + frag.getChunkX();
- int chunkY = y + frag.getChunkY();
- if (checkChunk(chunkX, chunkY)) {
- frag.addObject(new MapObjectVillage(x << 4, y << 4).setParent(this));
- }
- }
- }
- }
-
-
- public boolean checkChunk(int chunkX, int chunkY) {
- byte villageParam1 = 32;
- byte villageParam2 = 8;
-
- int k = chunkX;
- int m = chunkY;
- if (chunkX < 0) chunkX -= villageParam1 - 1;
- if (chunkY < 0) chunkY -= villageParam1 - 1;
-
- int n = chunkX / villageParam1;
- int i1 = chunkY / villageParam1;
-
- long positionSeed = n * 341873128712L + i1 * 132897987541L + Options.instance.seed + 10387312L;
- random.setSeed(positionSeed);
-
-
-
- n *= villageParam1;
- i1 *= villageParam1;
- n += random.nextInt(villageParam1 - villageParam2);
- i1 += random.nextInt(villageParam1 - villageParam2);
- chunkX = k;
- chunkY = m;
- if ((chunkX == n) && (chunkY == i1))
- return MinecraftUtil.isValidBiome(chunkX * 16 + 8, chunkY * 16 + 8, 0, validBiomes);
-
- return false;
- }
-}
diff --git a/src/amidst/map/widget/BiomeToggleWidget.java b/src/amidst/map/widget/BiomeToggleWidget.java
deleted file mode 100644
index 3f85a8dad..000000000
--- a/src/amidst/map/widget/BiomeToggleWidget.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-
-import amidst.map.layers.BiomeLayer;
-import amidst.resources.ResourceLoader;
-import MoF.MapViewer;
-
-public class BiomeToggleWidget extends PanelWidget {
- private static BufferedImage highlighterIcon = ResourceLoader.getImage("highlighter.png");
- public static boolean isBiomeWidgetVisible = false;
- public BiomeToggleWidget(MapViewer mapViewer) {
- super(mapViewer);
- setDimensions(36, 36);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- super.draw(g2d, time);
- g2d.drawImage(highlighterIcon, x, y, 36, 36, null);
- }
-
- @Override
- public boolean onMousePressed(int x, int y) {
- isBiomeWidgetVisible = !isBiomeWidgetVisible;
- BiomeLayer.instance.setHighlightMode(isBiomeWidgetVisible);
- (new Thread(new Runnable() {
- @Override
- public void run() {
- map.resetImageLayer(BiomeLayer.instance.getLayerId());
- }
- })).start();
- return true;
- }
-}
diff --git a/src/amidst/map/widget/BiomeWidget.java b/src/amidst/map/widget/BiomeWidget.java
deleted file mode 100644
index 4aa0647d9..000000000
--- a/src/amidst/map/widget/BiomeWidget.java
+++ /dev/null
@@ -1,215 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Color;
-import java.awt.FontMetrics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.ArrayList;
-
-import amidst.logging.Log;
-import amidst.map.layers.BiomeLayer;
-import amidst.minecraft.Biome;
-import MoF.MapViewer;
-
-public class BiomeWidget extends PanelWidget {
- private static BiomeWidget instance;
- private static Color innerBoxBgColor = new Color(0.3f, 0.3f, 0.3f, 0.3f);
- private static Color biomeBgColor1 = new Color(0.8f, 0.8f, 0.8f, 0.2f);
- private static Color biomeBgColor2 = new Color(0.6f, 0.6f, 0.6f, 0.2f);
- private static Color biomeLitBgColor1 = new Color(0.8f, 0.8f, 1.0f, 0.7f);
- private static Color biomeLitBgColor2 = new Color(0.6f, 0.6f, 0.8f, 0.7f);
- private static Color innerBoxBorderColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
- private static Color scrollbarColor = new Color(0.6f, 0.6f, 0.6f, 0.8f);
- private static Color scrollbarLitColor = new Color(0.6f, 0.6f, 0.8f, 0.8f);
- private static Color selectButtonColor = new Color(0.6f, 0.6f, 0.8f, 1.0f);
-
- private ArrayList biomes = new ArrayList();
- private int maxNameWidth = 0;
- private Rectangle innerBox = new Rectangle(0, 0, 1, 1);
-
- private int biomeListHeight;
- private int biomeListYOffset = 0;
- private boolean scrollbarVisible = false;
- private boolean scrollbarGrabbed = false;
- private int scrollbarHeight = 0, scrollbarWidth = 10, scrollbarY = 0, mouseYOnGrab = 0, scrollbarYOnGrab;
-
- public BiomeWidget(MapViewer mapViewer) {
- super(mapViewer);
-
- FontMetrics fontMetrics = mapViewer.getFontMetrics(textFont);
- for (int i = 0; i < Biome.biomes.length; i++) {
- if (Biome.biomes[i] != null) {
- biomes.add(Biome.biomes[i]);
- maxNameWidth = Math.max(fontMetrics.stringWidth(Biome.biomes[i].name), maxNameWidth);
- }
- }
- biomeListHeight = biomes.size() * 16;
- setDimensions(250, 400);
- y = 100;
- forceVisibility(false);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- x = mapViewer.getWidth() - width;
- super.draw(g2d, time);
- g2d.setColor(textColor);
- g2d.setFont(textFont);
- g2d.drawString("Highlight Biomes", x + 10, y + 20);
-
- innerBox.x = x + 8;
- innerBox.y = y + 30;
- innerBox.width = width - 16;
- innerBox.height = height - 58;
-
- biomeListYOffset = Math.min(0, Math.max(-biomeListHeight + innerBox.height, biomeListYOffset));
-
- if (biomeListHeight > innerBox.height) {
- innerBox.width -= scrollbarWidth;
- scrollbarVisible = true;
- } else {
- scrollbarVisible = false;
- }
-
- g2d.setColor(innerBoxBgColor);
- g2d.fillRect(innerBox.x, innerBox.y, innerBox.width, innerBox.height);
- g2d.setColor(innerBoxBorderColor);
- g2d.drawRect(innerBox.x - 1, innerBox.y - 1, innerBox.width + 1 + (scrollbarVisible?scrollbarWidth:0), innerBox.height + 1);
- g2d.setClip(innerBox);
-
- for (int i = 0; i < biomes.size(); i++) {
- Biome biome = biomes.get(i);
- if (BiomeLayer.instance.isBiomeSelected(biome.index))
- g2d.setColor(((i % 2) == 1)?biomeLitBgColor1:biomeLitBgColor2);
- else
- g2d.setColor(((i % 2) == 1)?biomeBgColor1:biomeBgColor2);
- g2d.fillRect(innerBox.x, innerBox.y + i * 16 + biomeListYOffset,innerBox.width, 16);
- g2d.setColor(new Color(biome.color));
- g2d.fillRect(innerBox.x, innerBox.y + i*16 + biomeListYOffset, 20, 16);
- g2d.setColor(Color.white);
- g2d.drawString(biome.name, innerBox.x + 25, innerBox.y + 13 + i*16 + biomeListYOffset);
- }
-
-
- g2d.setClip(null);
-
- if (scrollbarVisible) {
- float boxHeight = innerBox.height;
- float listHeight = biomeListHeight;
-
- if (scrollbarGrabbed) {
- Point mouse = mapViewer.getMousePosition();
- if (mouse != null) {
- int tempScrollbarY = - scrollbarYOnGrab - (mouse.y - mouseYOnGrab);
- biomeListYOffset = (int)((listHeight/boxHeight) * tempScrollbarY);
- biomeListYOffset = Math.min(0, Math.max(-biomeListHeight + innerBox.height, biomeListYOffset));
- } else {
- scrollbarGrabbed = false;
- }
- }
-
- float yOffset = -biomeListYOffset;
-
- scrollbarY = (int) ((yOffset/listHeight) * boxHeight);
- scrollbarHeight = (int) (Math.ceil(boxHeight * (boxHeight/listHeight)));
- g2d.setColor(scrollbarGrabbed?scrollbarLitColor:scrollbarColor);
- g2d.fillRect(innerBox.x + innerBox.width, innerBox.y + scrollbarY, scrollbarWidth, scrollbarHeight);
- }
-
-
- g2d.setColor(Color.white);
- g2d.drawString("Select:", x + 8, y + height - 10);
- g2d.setColor(selectButtonColor);
- g2d.drawString("All Special None", x + 120, y + height - 10);
-
- }
-
- @Override
- public boolean onMouseWheelMoved(int mouseX, int mouseY, int notches) {
- if ((mouseX > innerBox.x - x) &&
- (mouseX < innerBox.x - x + innerBox.width) &&
- (mouseY > innerBox.y - y) &&
- (mouseY < innerBox.y - y + innerBox.height)) {
- biomeListYOffset = Math.min(0, Math.max(-biomeListHeight + innerBox.height, biomeListYOffset - notches * 35));
- }
- return true;
- }
-
- @Override
- public void onMouseReleased() {
- scrollbarGrabbed = false;
- }
-
- @Override
- public boolean onMousePressed(int mouseX, int mouseY) {
- if (scrollbarVisible) {
- if ((mouseX > innerBox.x - x + innerBox.width) &&
- (mouseX < innerBox.x - x + innerBox.width + scrollbarWidth) &&
- (mouseY > innerBox.y - y + scrollbarY) &&
- (mouseY < innerBox.y - y + scrollbarY + scrollbarHeight)) {
-
- mouseYOnGrab = mouseY + y;
- scrollbarYOnGrab = scrollbarY;
- scrollbarGrabbed = true;
- }
- }
-
- boolean needsRedraw = false;
- if ((mouseX > innerBox.x - x) &&
- (mouseX < innerBox.x - x + innerBox.width) &&
- (mouseY > innerBox.y - y) &&
- (mouseY < innerBox.y - y + innerBox.height)) {
- int id = (mouseY - (innerBox.y - y) - biomeListYOffset) / 16;
- if (id < biomes.size()) {
- BiomeLayer.instance.toggleBiomeSelect(biomes.get(id).index);
- needsRedraw = true;
- }
- }
-
- // TODO: These values are temporarly hard coded for the sake of a fast release
- if ((mouseY > height - 25) && (mouseY < height - 9)) {
- if ((mouseX > 117) && (mouseX < 139)) {
- BiomeLayer.instance.selectAllBiomes();
- needsRedraw = true;
- } else if ((mouseX > 143) && (mouseX < 197)) {
- for (int i = 128; i < Biome.biomes.length; i++)
- if (Biome.biomes[i] != null)
- BiomeLayer.instance.selectBiome(i);
- needsRedraw = true;
- } else if ((mouseX > 203) && (mouseX < 242)) {
- BiomeLayer.instance.deselectAllBiomes();
- needsRedraw = true;
- }
- }
- if (needsRedraw) {
- (new Thread(new Runnable() {
- @Override
- public void run() {
- map.resetImageLayer(BiomeLayer.instance.getLayerId());
- }
- })).start();
- }
- return true;
- }
-
- @Override
- public boolean onVisibilityCheck() {
- height = Math.max(200, mapViewer.getHeight() - 200);
- return BiomeToggleWidget.isBiomeWidgetVisible & (height > 200);
- }
-
- private void setMapViewer(MapViewer mapViewer) {
- this.mapViewer = mapViewer;
- this.map = mapViewer.getMap();
- scrollbarGrabbed = false;
- }
-
- public static BiomeWidget get(MapViewer mapViewer) {
- if (instance == null)
- instance = new BiomeWidget(mapViewer);
- else
- instance.setMapViewer(mapViewer);
- return instance;
- }
-}
diff --git a/src/amidst/map/widget/CursorInformationWidget.java b/src/amidst/map/widget/CursorInformationWidget.java
deleted file mode 100644
index 4a198ca0b..000000000
--- a/src/amidst/map/widget/CursorInformationWidget.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-import java.awt.Point;
-
-import MoF.MapViewer;
-
-public class CursorInformationWidget extends PanelWidget {
- private String message = "";
-
- public CursorInformationWidget(MapViewer mapViewer) {
- super(mapViewer);
- setDimensions(20, 30);
- forceVisibility(false);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- Point mouseLocation = null;
- if ((mouseLocation = mapViewer.getMousePosition()) != null) {
- mouseLocation = map.screenToLocal(mouseLocation);
- String biomeName = map.getBiomeAliasAt(mouseLocation);
- message = biomeName + " [ " + mouseLocation.x + ", " + mouseLocation.y + " ]";
- }
- int stringWidth = mapViewer.getFontMetrics().stringWidth(message);
- setWidth(stringWidth + 20);
- super.draw(g2d, time);
-
- g2d.setColor(textColor);
- g2d.drawString(message, x + 10, y + 20);
- }
-
- @Override
- protected boolean onVisibilityCheck() {
- return (mapViewer.getMousePosition() != null);
- }
-}
diff --git a/src/amidst/map/widget/DebugWidget.java b/src/amidst/map/widget/DebugWidget.java
deleted file mode 100644
index 15d8b97a0..000000000
--- a/src/amidst/map/widget/DebugWidget.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-import java.util.ArrayList;
-
-import MoF.MapViewer;
-import amidst.Options;
-import amidst.map.FragmentManager;
-
-public class DebugWidget extends PanelWidget {
- public DebugWidget(MapViewer mapViewer) {
- super(mapViewer);
- forceVisibility(onVisibilityCheck());
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- FragmentManager fragmentManager = mapViewer.getFragmentManager();
- ArrayList panelText = new ArrayList();
- panelText.add("Fragment Manager:");
- panelText.add("Pool Size: " + fragmentManager.getCacheSize());
- panelText.add("Free Queue Size: " + fragmentManager.getFreeFragmentQueueSize());
- panelText.add("Request Queue Size: " + fragmentManager.getRequestQueueSize());
- panelText.add("Recycle Queue Size: " + fragmentManager.getRecycleQueueSize());
- panelText.add("");
- panelText.add("Map Viewer:");
- panelText.add("Map Size: " + map.tileWidth + "x" + map.tileHeight + " [" + (map.tileWidth * map.tileHeight) + "]");
-
- int width = 0, height;
- for (int i = 0; i < panelText.size(); i++) {
- int textWidth = mapViewer.getFontMetrics().stringWidth(panelText.get(i));
- if (textWidth > width)
- width = textWidth;
- }
-
- width += 20;
- height = panelText.size() * 20 + 10;
-
- setDimensions(width, height);
- super.draw(g2d, time);
-
- g2d.setColor(textColor);
- for (int i = 0; i < panelText.size(); i++)
- g2d.drawString(panelText.get(i), x + 10, y + 20 + i*20);
- }
-
- @Override
- protected boolean onVisibilityCheck() {
- return Options.instance.showDebug.get();
- }
-}
diff --git a/src/amidst/map/widget/FpsWidget.java b/src/amidst/map/widget/FpsWidget.java
deleted file mode 100644
index 197bac045..000000000
--- a/src/amidst/map/widget/FpsWidget.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-
-import MoF.MapViewer;
-import amidst.Options;
-import amidst.utilties.FramerateTimer;
-
-public class FpsWidget extends PanelWidget {
- private FramerateTimer fps = new FramerateTimer(2);
- public FpsWidget(MapViewer mapViewer) {
- super(mapViewer);
- setDimensions(20, 30);
- forceVisibility(onVisibilityCheck());
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- String framerate = fps.toString();
- setWidth(mapViewer.getFontMetrics().stringWidth(framerate) + 20);
- super.draw(g2d, time);
-
- fps.tick();
- g2d.setColor(textColor);
- g2d.drawString(framerate, x + 10, y + 20);
- }
-
- @Override
- protected boolean onVisibilityCheck() {
- return Options.instance.showFPS.get();
- }
-}
diff --git a/src/amidst/map/widget/PanelWidget.java b/src/amidst/map/widget/PanelWidget.java
deleted file mode 100644
index ac0d26b05..000000000
--- a/src/amidst/map/widget/PanelWidget.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.Stroke;
-import java.awt.image.BufferedImage;
-
-import amidst.resources.ResourceLoader;
-import MoF.MapViewer;
-
-public class PanelWidget extends Widget {
- private static BufferedImage
- dropShadowBottomLeft = ResourceLoader.getImage("dropshadow/outer_bottom_left.png"),
- dropShadowBottomRight = ResourceLoader.getImage("dropshadow/outer_bottom_right.png"),
- dropShadowTopLeft = ResourceLoader.getImage("dropshadow/outer_top_left.png"),
- dropShadowTopRight = ResourceLoader.getImage("dropshadow/outer_top_right.png"),
- dropShadowBottom = ResourceLoader.getImage("dropshadow/outer_bottom.png"),
- dropShadowTop = ResourceLoader.getImage("dropshadow/outer_top.png"),
- dropShadowLeft = ResourceLoader.getImage("dropshadow/outer_left.png"),
- dropShadowRight = ResourceLoader.getImage("dropshadow/outer_right.png");
- public enum CornerAnchorPoint {
- TOP_LEFT,
- TOP_RIGHT,
- BOTTOM_LEFT,
- BOTTOM_RIGHT,
- BOTTOM_CENTER,
- CENTER,
- NONE
- }
- protected Color textColor = new Color(1f, 1f, 1f);
- protected Color panelColor = new Color(0.15f, 0.15f, 0.15f, 0.8f);
- protected Font textFont = new Font("arial", Font.BOLD, 15);
- protected Stroke lineStroke1 = new BasicStroke(1);
- protected Stroke lineStroke2 = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
- protected CornerAnchorPoint anchor = CornerAnchorPoint.NONE;
- protected int xPadding = 10, yPadding = 10;
-
- protected float alpha = 1.0f, targetAlpha = 1.0f;
- protected boolean isFading = false;
- protected boolean targetVisibility = true;
-
- public PanelWidget(MapViewer mapViewer) {
- super(mapViewer);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- targetAlpha = targetVisibility?1.0f:0.0f;
- if (alpha < targetAlpha)
- alpha = Math.min(targetAlpha, alpha + time*4.0f);
- else if (alpha > targetAlpha)
- alpha = Math.max(targetAlpha, alpha - time*4.0f);
- isFading = (alpha != targetAlpha);
-
- updatePosition();
- g2d.setColor(panelColor);
- g2d.drawImage(dropShadowTopLeft, x - 10, y - 10, null);
- g2d.drawImage(dropShadowTopRight, x + width, y - 10, null);
- g2d.drawImage(dropShadowBottomLeft, x - 10, y + height, null);
- g2d.drawImage(dropShadowBottomRight, x + width, y + height, null);
-
- g2d.drawImage(dropShadowTop, x, y - 10, width, 10, null);
- g2d.drawImage(dropShadowBottom, x, y + height, width, 10, null);
- g2d.drawImage(dropShadowLeft, x - 10, y, 10, height, null);
- g2d.drawImage(dropShadowRight, x + width, y, 10, height, null);
-
- g2d.fillRect(x, y, width, height);
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
- public void setHeight(int height) {
- this.height = height;
- }
-
- public void setDimensions(int width, int height) {
- this.width = width;
- this.height = height;
- }
-
- protected void updatePosition() {
- switch (anchor) {
- case TOP_LEFT:
- x = xPadding;
- y = yPadding;
- break;
- case BOTTOM_LEFT:
- x = xPadding;
- y = mapViewer.getHeight() - (height + yPadding);
- break;
- case BOTTOM_RIGHT:
- x = mapViewer.getWidth() - (width + xPadding);
- y = mapViewer.getHeight() - (height + yPadding);
- break;
- case BOTTOM_CENTER:
- x = (mapViewer.getWidth() >> 1) - (width >> 1);
- y = mapViewer.getHeight() - (height + yPadding);
- break;
- case TOP_RIGHT:
- x = mapViewer.getWidth() - (width + xPadding);
- y = yPadding;
- break;
- case CENTER:
- x = (mapViewer.getWidth() >> 1) - (width >> 1);
- y = (mapViewer.getHeight() >> 1) - (height >> 1);
- break;
- case NONE:
- break;
- }
- }
-
- @Override
- public boolean isVisible() {
- boolean value = (visible && targetVisibility) || isFading;
- targetVisibility = onVisibilityCheck();
- return value;
- }
-
- protected boolean onVisibilityCheck() {
- return visible;
- }
-
- public void forceVisibility(boolean value) {
- targetVisibility = value;
- isFading = false;
- targetAlpha = value?1.0f:0.0f;
- alpha = value?1.0f:0.0f;
- }
-
- @Override
- public float getAlpha() {
- return alpha;
- }
-
- public PanelWidget setAnchorPoint(CornerAnchorPoint anchor) {
- this.anchor = anchor;
- return this;
- }
-}
diff --git a/src/amidst/map/widget/ScaleWidget.java b/src/amidst/map/widget/ScaleWidget.java
deleted file mode 100644
index 0daedbfce..000000000
--- a/src/amidst/map/widget/ScaleWidget.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-
-import amidst.Options;
-import MoF.MapViewer;
-
-public class ScaleWidget extends PanelWidget {
-
- public static int cScaleLengthMax_px = 200;
- public static int cMargin = 8;
-
- public ScaleWidget(MapViewer mapViewer) {
- super(mapViewer);
- setDimensions(100, 34);
- forceVisibility(false);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
-
- int scaleBlocks = scaleLength_blocks();
- int scaleWidth_px = (int)(scaleBlocks * map.getZoom());
-
- String message = scaleBlocks + " blocks";
-
- int stringWidth = mapViewer.getFontMetrics().stringWidth(message);
- setWidth(Math.max(scaleWidth_px, stringWidth) + (cMargin * 2));
- super.draw(g2d, time);
-
- g2d.setColor(textColor);
- g2d.setFont(textFont);
- g2d.drawString(message, x + 1 + ((width - stringWidth) >> 1), y + 18);
-
- g2d.setColor(Color.white);
-
- g2d.setStroke(lineStroke2);
- g2d.drawLine(x + cMargin, y + 26, x + cMargin + scaleWidth_px, y + 26);
- g2d.setStroke(lineStroke1);
- g2d.drawLine(x + cMargin, y + 23, x + cMargin, y + 28);
- g2d.drawLine(x + cMargin + scaleWidth_px, y + 23, x + cMargin + scaleWidth_px, y + 28);
- }
-
- @Override
- protected boolean onVisibilityCheck() {
- return Options.instance.showScale.get();
- }
-
- private int scaleLength_blocks() {
-
- double scale = map.getZoom();
-
- int result = 1000;
- if(result * scale > cScaleLengthMax_px) {
- result = 500;
- if(result * scale > cScaleLengthMax_px) {
- result = 200;
- if(result * scale > cScaleLengthMax_px) {
- result = 100;
- }
- }
- }
-
- return result;
- }
-}
diff --git a/src/amidst/map/widget/SeedWidget.java b/src/amidst/map/widget/SeedWidget.java
deleted file mode 100644
index cf6d5099c..000000000
--- a/src/amidst/map/widget/SeedWidget.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-
-import MoF.MapViewer;
-import amidst.Options;
-
-public class SeedWidget extends PanelWidget {
- public SeedWidget(MapViewer mapViewer) {
- super(mapViewer);
- setDimensions(20, 30);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- setWidth(mapViewer.getFontMetrics().stringWidth(Options.instance.getSeedMessage()) + 20);
- super.draw(g2d, time);
- g2d.setColor(textColor);
- g2d.drawString(Options.instance.getSeedMessage(), x + 10, y + 20);
- }
-}
diff --git a/src/amidst/map/widget/SelectedObjectWidget.java b/src/amidst/map/widget/SelectedObjectWidget.java
deleted file mode 100644
index 7006cc0ba..000000000
--- a/src/amidst/map/widget/SelectedObjectWidget.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-
-import amidst.map.MapObject;
-import MoF.MapViewer;
-
-public class SelectedObjectWidget extends PanelWidget {
- private String message = "";
- private BufferedImage icon;
-
- public SelectedObjectWidget(MapViewer mapViewer) {
- super(mapViewer);
- yPadding += 40;
- setDimensions(20, 35);
- forceVisibility(false);
- }
-
- @Override
- public void draw(Graphics2D g2d, float time) {
- if (targetVisibility) {
- MapObject selectedObject = mapViewer.getSelectedObject();
- message = selectedObject.getName() + " [" + selectedObject.rx + ", " + selectedObject.ry + "]";
- icon = selectedObject.getImage();
- }
-
- setWidth(45 + mapViewer.getFontMetrics().stringWidth(message));
- super.draw(g2d, time);
-
- g2d.setColor(textColor);
- double imgWidth = icon.getWidth();
- double imgHeight = icon.getHeight();
- double ratio = imgWidth/imgHeight;
-
- g2d.drawImage(icon, x + 5, y + 5, (int)(25.*ratio), 25, null);
- g2d.drawString(message, x + 35, y + 23);
- }
-
- @Override
- protected boolean onVisibilityCheck() {
- return (mapViewer.getSelectedObject() != null);
- }
-}
diff --git a/src/amidst/map/widget/Widget.java b/src/amidst/map/widget/Widget.java
deleted file mode 100644
index 3b259cd72..000000000
--- a/src/amidst/map/widget/Widget.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package amidst.map.widget;
-
-import java.awt.Graphics2D;
-
-import MoF.MapViewer;
-import amidst.map.Map;
-
-public class Widget {
- protected MapViewer mapViewer;
- protected Map map;
-
- protected int x, y, width, height;
- protected boolean visible = true;
-
- public Widget(MapViewer mapViewer) {
- this.mapViewer = mapViewer;
- this.map = mapViewer.getMap();
- }
-
- public void draw(Graphics2D g2d, float time) {
-
- }
- public boolean onClick(int x, int y) {
- return true;
- }
-
- public boolean onMouseWheelMoved(int x, int y, int rotation) {
- return false;
- }
-
- public int getX() {
- return x;
- }
- public int getY() {
- return y;
- }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
-
- public boolean isVisible() {
- return visible;
- }
- public void setVisibility(boolean value) {
- visible = value;
- }
-
- public float getAlpha() {
- return 1.0f;
- }
-
- public boolean onMousePressed(int x, int y) {
- return true;
- }
-
- public void onMouseReleased() {
- }
-}
diff --git a/src/amidst/minecraft/Biome.java b/src/amidst/minecraft/Biome.java
deleted file mode 100644
index f718a65c9..000000000
--- a/src/amidst/minecraft/Biome.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package amidst.minecraft;
-
-import java.util.HashMap;
-
-import amidst.Util;
-
-public class Biome {
- public static final HashMap biomeMap = new HashMap();
- public static final BiomeType typeA = new BiomeType(0.1F, 0.2F);
- public static final BiomeType typeB = new BiomeType(-0.5F, 0.0F);
- public static final BiomeType typeC = new BiomeType(-1.0F, 0.1F);
- public static final BiomeType typeD = new BiomeType(-1.8F, 0.1F);
- public static final BiomeType typeE = new BiomeType(0.125F, 0.05F);
- public static final BiomeType typeF = new BiomeType(0.2F, 0.2F);
- public static final BiomeType typeG = new BiomeType(0.45F, 0.3F);
- public static final BiomeType typeH = new BiomeType(1.5F, 0.025F);
- public static final BiomeType typeI = new BiomeType(1.0F, 0.5F);
- public static final BiomeType typeJ = new BiomeType(0.0F, 0.025F);
- public static final BiomeType typeK = new BiomeType(0.1F, 0.8F);
- public static final BiomeType typeL = new BiomeType(0.2F, 0.3F);
- public static final BiomeType typeM = new BiomeType(-0.2F, 0.1F);
-
- public static final Biome[] biomes = new Biome[256];
- public static final Biome ocean = new Biome("Ocean", 0, Util.makeColor(0, 0, 112), typeC);
- public static final Biome plains = new Biome("Plains", 1, Util.makeColor(141, 179, 96), typeA);
- public static final Biome desert = new Biome("Desert", 2, Util.makeColor(250, 148, 24), typeE);
- public static final Biome extremeHills = new Biome("Extreme Hills", 3, Util.makeColor(96, 96, 96), typeI);
- public static final Biome forest = new Biome("Forest", 4, Util.makeColor(5, 102, 33), typeA);
- public static final Biome taiga = new Biome("Taiga", 5, Util.makeColor(11, 102, 89), typeF);
- public static final Biome swampland = new Biome("Swampland", 6, Util.makeColor(7, 249, 178), typeM);
- public static final Biome river = new Biome("River", 7, Util.makeColor(0, 0, 255), typeB);
- public static final Biome hell = new Biome("Hell", 8, Util.makeColor(255, 0, 0), typeA);
- public static final Biome sky = new Biome("Sky", 9, Util.makeColor(128, 128, 255), typeA);
- public static final Biome frozenOcean = new Biome("Frozen Ocean", 10, Util.makeColor(144, 144, 160), typeC);
- public static final Biome frozenRiver = new Biome("Frozen River", 11, Util.makeColor(160, 160, 255), typeB);
- public static final Biome icePlains = new Biome("Ice Plains", 12, Util.makeColor(255, 255, 255), typeE);
- public static final Biome iceMountains = new Biome("Ice Mountains", 13, Util.makeColor(160, 160, 160), typeG);
- public static final Biome mushroomIsland = new Biome("Mushroom Island", 14, Util.makeColor(255, 0, 255), typeL);
- public static final Biome mushroomIslandShore = new Biome("Mushroom Island Shore", 15, Util.makeColor(160, 0, 255), typeJ);
- public static final Biome beach = new Biome("Beach", 16, Util.makeColor(250, 222, 85), typeJ);
- public static final Biome desertHills = new Biome("Desert Hills", 17, Util.makeColor(210, 95, 18), typeG);
- public static final Biome forestHills = new Biome("Forest Hills", 18, Util.makeColor(34, 85, 28), typeG);
- public static final Biome taigaHills = new Biome("Taiga Hills", 19, Util.makeColor(22, 57, 51), typeG);
- public static final Biome extremeHillsEdge = new Biome("Extreme Hills Edge", 20, Util.makeColor(114, 120, 154), typeI.getExtreme());
- public static final Biome jungle = new Biome("Jungle", 21, Util.makeColor(83, 123, 9), typeA);
- public static final Biome jungleHills = new Biome("Jungle Hills", 22, Util.makeColor(44, 66, 5), typeG);
- public static final Biome jungleEdge = new Biome("Jungle Edge", 23, Util.makeColor(98, 139, 23), typeA);
- public static final Biome deepOcean = new Biome("Deep Ocean", 24, Util.makeColor(0, 0, 48), typeD);
- public static final Biome stoneBeach = new Biome("Stone Beach", 25, Util.makeColor(162, 162, 132), typeK);
- public static final Biome coldBeach = new Biome("Cold Beach", 26, Util.makeColor(250, 240, 192), typeJ);
- public static final Biome birchForest = new Biome("Birch Forest", 27, Util.makeColor(48, 116, 68), typeA);
- public static final Biome birchForestHills = new Biome("Birch Forest Hills", 28, Util.makeColor(31, 95, 50), typeG);
- public static final Biome roofedForest = new Biome("Roofed Forest", 29, Util.makeColor(64, 81, 26), typeA);
- public static final Biome coldTaiga = new Biome("Cold Taiga", 30, Util.makeColor(49, 85, 74), typeF);
- public static final Biome coldTaigaHills = new Biome("Cold Taiga Hills", 31, Util.makeColor(36, 63, 54), typeG);
- public static final Biome megaTaiga = new Biome("Mega Taiga", 32, Util.makeColor(89, 102, 81), typeF);
- public static final Biome megaTaigaHills = new Biome("Mega Taiga Hills", 33, Util.makeColor(69, 79, 62), typeG);
- public static final Biome extremeHillsPlus = new Biome("Extreme Hills+", 34, Util.makeColor(80, 112, 80), typeI);
- public static final Biome savanna = new Biome("Savanna", 35, Util.makeColor(189, 178, 95), typeE);
- public static final Biome savannaPlateau = new Biome("Savanna Plateau", 36, Util.makeColor(167, 157, 100), typeH);
- public static final Biome mesa = new Biome("Mesa", 37, Util.makeColor(217, 69, 21), typeA);
- public static final Biome mesaPlateauF = new Biome("Mesa Plateau F", 38, Util.makeColor(176, 151, 101), typeH);
- public static final Biome mesaPlateau = new Biome("Mesa Plateau", 39, Util.makeColor(202, 140, 101), typeH);
-
-
- public static final Biome oceanM = new Biome("Ocean M", 128, Util.makeColor(0, 0, 112));
- public static final Biome sunflowerPlains = new Biome("Sunflower Plains", 129, Util.makeColor(141, 179, 96));
- public static final Biome desertM = new Biome("Desert M", 130, Util.makeColor(250, 148, 24));
- public static final Biome extremeHillsM = new Biome("Extreme Hills M", 131, Util.makeColor(96, 96, 96));
- public static final Biome flowerForest = new Biome("Flower Forest", 132, Util.makeColor(5, 102, 33));
- public static final Biome taigaM = new Biome("Taiga M", 133, Util.makeColor(11, 102, 89));
- public static final Biome swamplandM = new Biome("Swampland M", 134, Util.makeColor(7, 249, 178));
- public static final Biome riverM = new Biome("River M", 135, Util.makeColor(0, 0, 255));
- public static final Biome hellM = new Biome("Hell M", 136, Util.makeColor(255, 0, 0));
- public static final Biome skyM = new Biome("Sky M", 137, Util.makeColor(128, 128, 255));
- public static final Biome frozenOceanM = new Biome("Frozen Ocean M", 138, Util.makeColor(144, 144, 160));
- public static final Biome frozenRiverM = new Biome("Frozen River M", 139, Util.makeColor(160, 160, 255));
- public static final Biome icePlainsSpikes = new Biome("Ice Plains Spikes", 140, Util.makeColor(140, 180, 180));
- public static final Biome iceMountainsM = new Biome("Ice Mountains M", 141, Util.makeColor(160, 160, 160));
- public static final Biome mushroomIslandM = new Biome("Mushroom Island M", 142, Util.makeColor(255, 0, 255));
- public static final Biome mushroomIslandShoreM = new Biome("Mushroom Island Shore M", 143, Util.makeColor(160, 0, 255));
- public static final Biome beachM = new Biome("Beach M", 144, Util.makeColor(250, 222, 85));
- public static final Biome desertHillsM = new Biome("Desert Hills M", 145, Util.makeColor(210, 95, 18));
- public static final Biome forestHillsM = new Biome("Forest Hills M", 146, Util.makeColor(34, 85, 28));
- public static final Biome taigaHillsM = new Biome("Taiga Hills M", 147, Util.makeColor(22, 57, 51));
- public static final Biome extremeHillsEdgeM = new Biome("Extreme Hills Edge M", 148, Util.makeColor(114, 120, 154));
- public static final Biome jungleM = new Biome("Jungle M", 149, Util.makeColor(83, 123, 9));
- public static final Biome jungleHillsM = new Biome("Jungle Hills M", 150, Util.makeColor(44, 66, 5));
- public static final Biome jungleEdgeM = new Biome("Jungle Edge M", 151, Util.makeColor(98, 139, 23));
- public static final Biome deepOceanM = new Biome("Deep Ocean M", 152, Util.makeColor(0, 0, 48));
- public static final Biome stoneBeachM = new Biome("Stone Beach M", 153, Util.makeColor(162, 162, 132));
- public static final Biome coldBeachM = new Biome("Cold Beach M", 154, Util.makeColor(250, 240, 192));
- public static final Biome birchForestM = new Biome("Birch Forest M", 155, Util.makeColor(48, 116, 68));
- public static final Biome birchForestHillsM = new Biome("Birch Forest Hills M", 156, Util.makeColor(31, 95, 50));
- public static final Biome roofedForestM = new Biome("Roofed Forest M", 157, Util.makeColor(64, 81, 26));
- public static final Biome coldTaigaM = new Biome("Cold Taiga M", 158, Util.makeColor(49, 85, 74));
- public static final Biome coldTaigaHillsM = new Biome("Cold Taiga Hills M", 159, Util.makeColor(36, 63, 54));
- public static final Biome megaSpruceTaiga = new Biome("Mega Spruce Taiga", 160, Util.makeColor(89, 102, 81));
- public static final Biome megaSpurceTaigaHills = new Biome("Mega Spruce Taiga (Hills)",161, Util.makeColor(69, 79, 62));
- public static final Biome extremeHillsPlusM = new Biome("Extreme Hills+ M", 162, Util.makeColor(80, 112, 80));
- public static final Biome savannaM = new Biome("Savanna M", 163, Util.makeColor(189, 178, 95));
- public static final Biome savannaPlateauM = new Biome("Savanna Plateau M", 164, Util.makeColor(167, 157, 100));
- public static final Biome mesaBryce = new Biome("Mesa (Bryce)", 165, Util.makeColor(217, 69, 21));
- public static final Biome mesaPlateauFM = new Biome("Mesa Plateau F M", 166, Util.makeColor(176, 151, 101));
- public static final Biome mesaPlateauM = new Biome("Mesa Plateau M", 167, Util.makeColor(202, 140, 101));
-
-
- public String name;
- public int index;
- public int color;
- public BiomeType type;
-
- public Biome(String name, int index, int color, boolean remote) {
- biomes[index] = this;
- this.name = name;
- this.index = index;
- this.color = color;
- this.type = typeC;
- biomeMap.put(name, this);
- }
-
- public Biome(String name, int index, int color) {
- this(name, index, color, biomes[index - 128].type.getRare());
- }
- public Biome(String name, int index, int color, BiomeType type) {
- biomes[index] = this;
- this.name = name;
- this.index = index;
- this.color = color;
- this.type = type;
- biomeMap.put(name, this);
-
- if (index >= 128)
- this.color = Util.lightenColor(color, 40);
- }
-
- @Override
- public String toString() {
- return "[Biome " + name + "]";
- }
-
- public static int indexFromName(String name) {
- Biome biome = biomeMap.get(name);
- if (biome != null)
- return biome.index;
- return -1;
- }
-
- public static final class BiomeType { // TODO: Rename once we figure out what this actually is!
- public float value1, value2;
- public BiomeType(float value1, float value2) {
- this.value1 = value1;
- this.value2 = value2;
- }
-
- public BiomeType getExtreme() {
- return new BiomeType(value1 * 0.8F, value2 * 0.6F);
- }
- public BiomeType getRare(){
- return new BiomeType(value1 + 0.1F, value2 + 0.2F);
- }
- }
-
-}
diff --git a/src/amidst/minecraft/DeobfuscationData.java b/src/amidst/minecraft/DeobfuscationData.java
deleted file mode 100644
index 7ab9d8706..000000000
--- a/src/amidst/minecraft/DeobfuscationData.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package amidst.minecraft;
-
-public class DeobfuscationData {
- public static final int[] intCache = new int[] {0x11, 0x01, 0x00, 0xB3, 0x00, -1, 0xBB, 0x00, -1, 0x59, 0xB7, 0x00, -1, 0xB3, 0x00, -1, 0xBB, 0x00, -1, 0x59, 0xB7, 0x00, -1, 0xB3, 0x00, -1, 0xBB, 0x00, -1, 0x59, 0xB7, 0x00, -1, 0xB3, 0x00, -1, 0xBB, 0x00, -1, 0x59, 0xB7, 0x00, -1, 0xB3, 0x00, -1, 0xB1};
-}
diff --git a/src/amidst/minecraft/IMinecraftInterface.java b/src/amidst/minecraft/IMinecraftInterface.java
deleted file mode 100644
index 9fe50f651..000000000
--- a/src/amidst/minecraft/IMinecraftInterface.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package amidst.minecraft;
-
-import amidst.version.VersionInfo;
-
-/**
- * Acts as an additional layer of abstraction for interfacing with Minecraft.
- * This allows for other sources of data other than direct reflection against a loaded jar of Minecraft.
- */
-public interface IMinecraftInterface {
- /**
- * @param useQuarterResolutionMap
- * Minecraft calculates biomes at quarter-resolution, then noisily interpolates the biome-map up to
- * 1:1 resolution when needed, set useQuarterResolutionMap to true to read from the quarter-resolution
- * map, or false to read values that have been interpolated up to full resolution.
- *
- * When useQuarterResolutionMap is true, the x, y, width, and height paramaters must all
- * correspond to a quarter of the Minecraft block coordinates/sizes you wish to obtain the
- * biome data for.
- *
- * AMIDST displays the quarter-resolution biome map, however full resolution is required to
- * determine the position and nature of structures, as the noisy interpolation can change
- * which biome a structure is located in (if the structure is located on a biome boundary).
- */
- public int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolutionMap);
- public void createWorld(long seed, String type, String generatorOptions);
- public VersionInfo getVersion();
-}
diff --git a/src/amidst/minecraft/LocalMinecraftInterface.java b/src/amidst/minecraft/LocalMinecraftInterface.java
deleted file mode 100644
index 1a260c009..000000000
--- a/src/amidst/minecraft/LocalMinecraftInterface.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package amidst.minecraft;
-
-import java.lang.reflect.Field;
-
-import amidst.logging.Log;
-import amidst.version.VersionInfo;
-import MoF.SaveLoader.Type;
-
-public class LocalMinecraftInterface implements IMinecraftInterface {
- private Minecraft minecraft;
- /**
- * A GenLayer instance, at quarter scale to the final biome layer
- * (i.e. both axis are divided by 4).
- * Minecraft calculates biomes at quarter-resolution, then noisily interpolates
- * the biome-map up to 1:1 resolution when needed, this is the biome GenLayer
- * before it is interpolated.
- */
- private MinecraftObject biomeGen;
- /**
- * A GenLayer instance, the biome layer. (1:1 scale)
- * Minecraft calculates biomes at quarter-resolution, then noisily interpolates
- * the biome-map up to 1:1 resolution when needed, this is the interpolated
- * biome GenLayer.
- */
- private MinecraftObject biomeGen_fullResolution;
-
- public LocalMinecraftInterface(Minecraft minecraft) {
- this.minecraft = minecraft;
- }
-
- @Override
- public int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolutionMap) {
- minecraft.getClassByName("IntCache").callFunction("resetIntCache");
- return (int[])(useQuarterResolutionMap ? biomeGen : biomeGen_fullResolution).callFunction("getInts", x, y, width, height);
- }
-
- @Override
- public void createWorld(long seed, String typeName, String generatorOptions) {
- Log.debug("Attempting to create world with seed: " + seed + ", type: " + typeName + ", and the following generator options:");
- Log.debug(generatorOptions);
-
- // Minecraft 1.8 and higher require block initialization to be called before creating a biome generator.
- MinecraftClass blockInit;
- if ((blockInit = minecraft.getClassByName("BlockInit")) != null)
- blockInit.callFunction("initialize");
-
- Type type = Type.fromMixedCase(typeName);
- MinecraftClass genLayerClass = minecraft.getClassByName("GenLayer");
- MinecraftClass worldTypeClass = minecraft.getClassByName("WorldType");
- Object[] genLayers = null;
- if (worldTypeClass == null) {
- genLayers = (Object[])genLayerClass.callFunction("initializeAllBiomeGenerators", seed);
- } else {
- Object worldType = ((MinecraftObject) worldTypeClass.getValue(type.getValue())).get();
- if (genLayerClass.getMethod("initializeAllBiomeGeneratorsWithParams").exists()) {
- genLayers = (Object[])genLayerClass.callFunction("initializeAllBiomeGeneratorsWithParams", seed, worldType, generatorOptions);
- } else {
- genLayers = (Object[])genLayerClass.callFunction("initializeAllBiomeGenerators", seed, worldType);
- }
-
- }
-
- biomeGen = new MinecraftObject(genLayerClass, genLayers[0]);
- biomeGen_fullResolution = new MinecraftObject(genLayerClass, genLayers[1]);
- }
-
- @Override
- public VersionInfo getVersion() {
- return minecraft.version;
- }
-
-
-}
diff --git a/src/amidst/minecraft/Minecraft.java b/src/amidst/minecraft/Minecraft.java
deleted file mode 100644
index d0ee786d0..000000000
--- a/src/amidst/minecraft/Minecraft.java
+++ /dev/null
@@ -1,396 +0,0 @@
-package amidst.minecraft;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import amidst.Options;
-import amidst.Util;
-import amidst.bytedata.ByteClass;
-import amidst.bytedata.ByteClass.AccessFlags;
-import amidst.bytedata.CCLongMatch;
-import amidst.bytedata.CCMethodPreset;
-import amidst.bytedata.CCMulti;
-import amidst.bytedata.CCPropertyPreset;
-import amidst.bytedata.CCRequire;
-import amidst.bytedata.CCStringMatch;
-import amidst.bytedata.CCWildcardByteSearch;
-import amidst.bytedata.ClassChecker;
-import amidst.json.JarLibrary;
-import amidst.json.JarProfile;
-import amidst.logging.Log;
-import amidst.version.VersionInfo;
-
-public class Minecraft {
- private static final int MAX_CLASSES = 128;
- private Class> mainClass;
- private URLClassLoader classLoader;
- private String versionID;
- private URL urlToJar;
- private File jarFile;
-
- private static ClassChecker[] classChecks = new ClassChecker[] {
- new CCWildcardByteSearch("IntCache", DeobfuscationData.intCache),
- new CCStringMatch("WorldType", "default_1_1"),
- new CCLongMatch("GenLayer", 1000L, 2001L, 2000L),
- new CCStringMatch("IntCache", ", tcache: "),
- (new ClassChecker() {
- @Override
- public void check(Minecraft m, ByteClass bClass) {
- if (bClass.fields.length != 3)
- return;
- int privateStatic = AccessFlags.PRIVATE | AccessFlags.STATIC;
- for (int i = 0; i < 3; i++) {
- if ((bClass.fields[i].accessFlags & privateStatic) != privateStatic)
- return;
- }
-
- if ((bClass.constructorCount == 0) && (bClass.methodCount == 6) && (bClass.searchForUtf("isDebugEnabled"))) {
- m.registerClass("BlockInit", bClass);
- isComplete = true;
- }
- }
- }),
- new CCRequire(
- new CCPropertyPreset(
- "WorldType",
- "a", "types",
- "b", "default",
- "c", "flat",
- "d", "largeBiomes",
- "e", "amplified",
- "g", "default_1_1",
- "f", "customized"
- )
- , "WorldType"),
- new CCRequire(
- new CCMethodPreset(
- "BlockInit",
- "c()", "initialize"
- )
- , "BlockInit"),
- new CCRequire(
- new CCMethodPreset(
- "GenLayer",
- "a(long, @WorldType)", "initializeAllBiomeGenerators",
- "a(long, @WorldType, String)", "initializeAllBiomeGeneratorsWithParams",
- "a(int, int, int, int)", "getInts"
- )
- , "GenLayer"),
- new CCRequire(new CCMulti(
- new CCMethodPreset(
- "IntCache",
- "a(int)", "getIntCache",
- "a()", "resetIntCache",
- "b()", "getInformation"
- ),
- new CCPropertyPreset(
- "IntCache",
- "a", "intCacheSize",
- "b","freeSmallArrays",
- "c","inUseSmallArrays",
- "d","freeLargeArrays",
- "e","inUseLargeArrays"
- )
- ), "IntCache")
- };
- private HashMap byteClassMap;
- private HashMap nameMap;
- private HashMap classMap;
- private Vector byteClassNames;
-
- public String versionId;
- public VersionInfo version = VersionInfo.unknown;
-
- public Minecraft(File jarFile) throws MalformedURLException {
- this.jarFile = jarFile;
- byteClassNames = new Vector();
- byteClassMap = new HashMap(MAX_CLASSES);
- urlToJar = jarFile.toURI().toURL();
-
- Log.i("Reading minecraft.jar...");
- if (!jarFile.exists())
- Log.crash("Attempted to load jar file at: " + jarFile + " but it does not exist.");
- Stack byteClassStack = new Stack();
- try {
- ZipFile jar = new ZipFile(jarFile);
- Enumeration extends ZipEntry> enu = jar.entries();
-
- while (enu.hasMoreElements()) {
- ZipEntry entry = enu.nextElement();
- String currentEntry = entry.getName();
- String[] nameSplit = currentEntry.split("\\.");
- if (!entry.isDirectory() && (nameSplit.length == 2) && (nameSplit[0].indexOf('/') == -1) && nameSplit[1].equals("class")) {
- BufferedInputStream is = new BufferedInputStream(jar.getInputStream(entry));
- if (is.available() < 8000) { // TODO: Double check that this filter won't mess anything up.
- byte[] classData = new byte[is.available()];
- is.read(classData);
- is.close();
- byteClassStack.push(new ByteClass(nameSplit[0], classData));
- }
- }
- }
- jar.close();
- Log.i("Jar load complete.");
- } catch (Exception e) {
- e.printStackTrace();
- Log.crash(e, "Error extracting jar data.");
- }
-
- Log.i("Searching for classes...");
- int checksRemaining = classChecks.length;
- Object[] byteClasses = byteClassStack.toArray();
- boolean[] found = new boolean[byteClasses.length];
- while (checksRemaining != 0) {
- for (int q = 0; q < classChecks.length; q++) {
- for (int i = 0; i < byteClasses.length; i++) {
- if (!found[q]) {
- classChecks[q].check(this, (ByteClass)byteClasses[i]);
- if (classChecks[q].isComplete) {
- Log.debug("Found: " + byteClasses[i] + " as " + classChecks[q].getName() + " | " + classChecks[q].getClass().getSimpleName());
- found[q] = true;
- checksRemaining--;
- }
- // TODO: What is this line, and why is it commented
- //byteClassMap.put(classChecks[q].getName(), classFiles[i].getName().split("\\.")[0]);
- }
- }
- if (!found[q]) {
- classChecks[q].passes--;
- if (classChecks[q].passes == 0) {
- found[q] = true;
- checksRemaining--;
- }
- }
-
-
- }
- }
- Log.i("Class search complete.");
-
- Log.i("Generating version ID...");
- use();
- try {
- use();
- if (classLoader.findResource("net/minecraft/client/Minecraft.class") != null)
- mainClass = classLoader.loadClass("net.minecraft.client.Minecraft");
- else if (classLoader.findResource("net/minecraft/server/MinecraftServer.class") != null)
- mainClass = classLoader.loadClass("net.minecraft.server.MinecraftServer");
- else
- throw new RuntimeException();
- } catch (Exception e) {
- e.printStackTrace(); // TODO: Make this exception far less broad.
- Log.crash(e, "Attempted to load non-minecraft jar, or unable to locate starting point.");
- }
- String typeDump = "";
- Field fields[] = null;
- try {
- fields = mainClass.getDeclaredFields();
- } catch (NoClassDefFoundError e) {
- e.printStackTrace();
- Log.crash(e, "Unable to find critical external class while loading.\nPlease ensure you have the correct Minecraft libraries installed.");
- }
-
- for (int i = 0; i < fields.length; i++) {
- String typeString = fields[i].getType().toString();
- if (typeString.startsWith("class ") && !typeString.contains("."))
- typeDump += typeString.substring(6);
- }
- versionId = typeDump;
- for (VersionInfo v : VersionInfo.values()) {
- if (versionId.equals(v.versionId)) {
- version = v;
- break;
- }
- }
-
- Log.i("Identified Minecraft [" + version.name() + "] with versionID of " + versionId);
- Log.i("Loading classes...");
- nameMap = new HashMap();
- classMap = new HashMap();
-
- for (String name : byteClassNames) {
- ByteClass byteClass = byteClassMap.get(name);
- MinecraftClass minecraftClass = new MinecraftClass(name, byteClass.getClassName());
- minecraftClass.load(this);
- nameMap.put(minecraftClass.getName(), minecraftClass);
- classMap.put(minecraftClass.getClassName(), minecraftClass);
- }
-
- for (MinecraftClass minecraftClass : nameMap.values()) {
- ByteClass byteClass = byteClassMap.get(minecraftClass.getName());
- for (String[] property : byteClass.getProperties())
- minecraftClass.addProperty(new MinecraftProperty(minecraftClass, property[1], property[0]));
- for (String[] method : byteClass.getMethods()) {
- String methodString = obfuscateStringClasses(method[0]);
- methodString = methodString.replaceAll(",INVALID", "").replaceAll("INVALID,","").replaceAll("INVALID", "");
- String methodDeobfName = method[1];
- String methodObfName = methodString.substring(0, methodString.indexOf('('));
- String parameterString = methodString.substring(methodString.indexOf('(') + 1, methodString.indexOf(')'));
-
- if (parameterString.equals("")) {
- minecraftClass.addMethod(new MinecraftMethod(minecraftClass, methodDeobfName, methodObfName));
- } else {
- String[] parameterClasses = parameterString.split(",");
- minecraftClass.addMethod(new MinecraftMethod(minecraftClass, methodDeobfName, methodObfName, parameterClasses));
- }
- }
- for (String[] constructor : byteClass.getConstructors()) {
- String methodString = obfuscateStringClasses(constructor[0]).replaceAll(",INVALID", "").replaceAll("INVALID,","").replaceAll("INVALID", "");
- String methodDeobfName = constructor[1];
- String methodObfName = methodString.substring(0, methodString.indexOf('('));
- String parameterString = methodString.substring(methodString.indexOf('(') + 1, methodString.indexOf(')'));
-
- if (parameterString.equals("")) {
- minecraftClass.addMethod(new MinecraftMethod(minecraftClass, methodDeobfName, methodObfName));
- } else {
- String[] parameterClasses = parameterString.split(",");
- minecraftClass.addMethod(new MinecraftMethod(minecraftClass, methodDeobfName, methodObfName, parameterClasses));
- }
- }
- }
- Log.i("Classes loaded.");
- Log.i("Minecraft load complete.");
- }
- private String obfuscateStringClasses(String inString) {
- inString = inString.replaceAll(" ", "");
- Pattern cPattern = Pattern.compile("@[A-Za-z]+");
- Matcher cMatcher = cPattern.matcher(inString);
- String tempOutput = inString;
- while (cMatcher.find()) {
- String match = inString.substring(cMatcher.start(), cMatcher.end());
- ByteClass byteClass = getByteClass(match.substring(1));
- if (byteClass != null) {
- tempOutput = tempOutput.replaceAll(match, byteClass.getClassName());
- } else {
- tempOutput = tempOutput.replaceAll(match, "INVALID");
- }
- cMatcher = cPattern.matcher(tempOutput);
- }
- return tempOutput;
- }
-
-
- public URL getPath() {
- return urlToJar;
- }
-
- private Stack getLibraries(File jsonFile) {
- Log.i("Loading libraries.");
- Stack libraries = new Stack();
- JarProfile profile = null;
- try {
- profile = Util.readObject(jsonFile, JarProfile.class);
- } catch (IOException e) {
- Log.w("Invalid jar profile loaded. Library loading will be skipped. (Path: " + jsonFile + ")");
- return libraries;
- }
-
- for (int i = 0; i < profile.libraries.size(); i++) {
- JarLibrary library = profile.libraries.get(i);
- if (library.isActive() && library.getFile() != null && library.getFile().exists()) {
- try {
- libraries.add(library.getFile().toURI().toURL());
- Log.i("Found library: " + library.getFile());
- } catch (MalformedURLException e) {
- Log.w("Unable to convert library file to URL with path: " + library.getFile());
- e.printStackTrace();
- }
- } else {
- Log.i("Skipping library: " + library.name);
- }
- }
-
- return libraries;
- }
-
- /*
- * This was the old search-and-add-all libraries method. This may still be useful
- * if the user doesn't have a json file, or mojang changes the format.
- *
- private Stack getLibraries(File path, Stack urls) {
- File[] files = path.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- getLibraries(files[i], urls);
- } else {
- try {
- Log.i("Found library: " + files[i]);
- urls.push(files[i].toURI().toURL());
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- }
- return urls;
- }
- */
-
- public void use() {
- File librariesJson = Options.instance.minecraftJson == null ?
- new File(jarFile.getPath().replace(".jar", ".json"))
- : new File(Options.instance.minecraftJson);
- if (librariesJson.exists()) {
- Stack libraries = getLibraries(librariesJson);
- URL[] libraryArray = new URL[libraries.size() + 1];
- libraries.toArray(libraryArray);
- libraryArray[libraries.size()] = urlToJar;
- classLoader = new URLClassLoader(libraryArray);
- } else {
- Log.i("Unable to find Minecraft library JSON at: " + librariesJson + ". Skipping.");
- classLoader = new URLClassLoader(new URL[] { urlToJar });
- }
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- public String getVersionID() {
- return versionID;
- }
- public MinecraftClass getClassByName(String name) {
- return nameMap.get(name);
- }
- public URLClassLoader getClassLoader() {
- return classLoader;
- }
- public Class> loadClass(String name) {
- try {
- return classLoader.loadClass(name);
- } catch (ClassNotFoundException e) {
- Log.crash(e, "Error loading a class (" + name + ")");
- e.printStackTrace();
- }
- return null;
- }
- public MinecraftClass getClassByType(String name) {
- return classMap.get(name);
-
-
-
- }
- public void registerClass(String publicName, ByteClass bClass) {
- if (byteClassMap.get(publicName)==null) {
- byteClassMap.put(publicName, bClass);
- byteClassNames.add(publicName);
- }
- }
- public ByteClass getByteClass(String name) {
- return byteClassMap.get(name);
- }
-
- public IMinecraftInterface createInterface() {
- return new LocalMinecraftInterface(this);
- }
-
-}
diff --git a/src/amidst/minecraft/MinecraftClass.java b/src/amidst/minecraft/MinecraftClass.java
deleted file mode 100644
index 5e5b3a509..000000000
--- a/src/amidst/minecraft/MinecraftClass.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package amidst.minecraft;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-
-
-public class MinecraftClass {
- private String name, className;
- private HashMap methods;
- private Class> clazz;
- private HashMap propertiesByName;
- private HashMap propertiesByObfName;
- private HashMap methodsByName;
- private HashMap methodsByObfName;
- private HashMap constructorByName;
- private Constructor>[] constructors;
- private Minecraft minecraft;
- public MinecraftClass(String name, String className) {
- this.name = name;
- this.className = className;
- methods = new HashMap();
- propertiesByName = new HashMap();
- propertiesByObfName = new HashMap();
- methodsByName = new HashMap();
- methodsByObfName = new HashMap();
- constructorByName = new HashMap();
- }
- public String getName() {
- return name;
- }
- public void load(Minecraft mc) {
- minecraft = mc;
- clazz = minecraft.loadClass(className);
- }
- public String getClassName() {
- return className;
- }
- public Class> getClazz() {
- return clazz;
- }
- public void addProperty(MinecraftProperty property) {
- property.load(minecraft, this);
- propertiesByName.put(property.getName(), property);
- propertiesByObfName.put(property.getInternalName(), property);
- }
- public Object getValue(String name) {
- MinecraftProperty prop = propertiesByName.get(name);
- return prop.getStaticValue();
- }
- public Object callFunction(String name, Object... args) {
- return methodsByName.get(name).callStatic(args);
- }
- public Object callFunction(String name, MinecraftObject obj, Object... args) {
- return methodsByName.get(name).call(obj, args);
- }
- public void addMethod(MinecraftMethod method) {
- method.load(minecraft, this);
- methodsByName.put(method.getName(), method);
- methodsByObfName.put(method.getInternalName(), method);
- }
- public void addConstructor(MinecraftConstructor constructor) {
- constructor.load(minecraft, this);
- constructorByName.put(constructor.getName(), constructor);
- }
- public String toString() {
- return className;
- }
- public MinecraftObject newInstance(String constructor, Object... param) {
- return constructorByName.get(constructor).getNew(param);
- }
- public MinecraftConstructor getConstructor(String name) {
- return constructorByName.get(name);
- }
- public Object getValue(String propertyName, MinecraftObject minecraftObject) {
- return propertiesByName.get(propertyName).getValue(minecraftObject);
- }
- public MinecraftMethod getMethod(String name) {
- return methodsByName.get(name);
- }
-}
diff --git a/src/amidst/minecraft/MinecraftConstructor.java b/src/amidst/minecraft/MinecraftConstructor.java
deleted file mode 100644
index 1ecb15b6b..000000000
--- a/src/amidst/minecraft/MinecraftConstructor.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package amidst.minecraft;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-
-import amidst.logging.Log;
-
-
-public class MinecraftConstructor {
- private MinecraftClass parent;
- private Minecraft minecraft;
- private Class>[] paramClasses;
- private String[] paramNames;
- private boolean hasParameters;
- private Constructor> constructor;
- private String name;
- private static HashMap> primitives;
- static {
- primitives = new HashMap>();
- primitives.put("byte", byte.class);
- primitives.put("int", int.class);
- primitives.put("float", float.class);
- primitives.put("short", short.class);
- primitives.put("long", long.class);
- primitives.put("double", double.class);
- primitives.put("boolean", boolean.class);
- primitives.put("char", char.class);
- primitives.put("String", String.class);
- }
- public MinecraftConstructor(MinecraftClass parent, String name) {
- this.parent = parent;
- hasParameters = false;
- this.name = name;
- paramClasses = new Class>[] {};
- }
- public MinecraftConstructor(MinecraftClass parent, String name, String... args) {
- this.parent = parent;
- paramNames = args;
- paramClasses = new Class>[paramNames.length];
- hasParameters = true;
- this.name = name;
- }
- public void load(Minecraft mc, MinecraftClass mcClass) {
- minecraft = mc;
- Class> clazz = mcClass.getClazz();
- int i = 0;
- try {
- if (hasParameters) {
- for (; i < paramNames.length; i++) {
- paramClasses[i] = primitives.get(paramNames[i]);
- if (paramClasses[i] == null) {
- if (paramNames[i].charAt(0) == '@') {
-
- } else {
- paramClasses[i] = Class.forName(paramNames[i], true, minecraft.getClassLoader());
- }
- }
-
- }
- }
-
- constructor = clazz.getConstructor(paramClasses);
- constructor.setAccessible(true);
- } catch (ClassNotFoundException e) {
- Log.crash(e, "Unabled to find class for constructor. (" + paramNames[i] + ") on (" + mcClass.getName() + " / " + mcClass.getClassName() + ")");
- e.printStackTrace();
- } catch (SecurityException e) {
- Log.crash(e, "SecurityException on (" + mcClass.getName() + " / " + mcClass.getClassName() + ") contructor (" + name + ")");
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- Log.crash(e, "Unable to find class constructor (" + mcClass.getName() + " / " + mcClass.getClassName() + ") (" + name + ")");
- e.printStackTrace();
- }
- }
- public MinecraftObject getNew(Object... param) {
- return new MinecraftObject(parent, call(param));
- }
- private Object call(Object... param) {
- try {
- return constructor.newInstance(param);
- } catch (IllegalArgumentException e) { // TODO : Add error text
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
-
- e.printStackTrace();
-
- }
- return null;
- }
- public Object getParentName() {
- return parent.getName();
- }
- public String getName() {
- return name;
- }
- public Class>[] getParameters() {
- return paramClasses;
- }
- @Override
- public String toString() {
- return "[Constructor " + name +" of class " + parent.getName() + "]";
- }
-}
diff --git a/src/amidst/minecraft/MinecraftMethod.java b/src/amidst/minecraft/MinecraftMethod.java
deleted file mode 100644
index 4a3af4c25..000000000
--- a/src/amidst/minecraft/MinecraftMethod.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package amidst.minecraft;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import amidst.logging.Log;
-
-public class MinecraftMethod {
- private MinecraftClass parent;
- private Minecraft minecraft;
- private Class>[] paramClasses;
- private String[] paramNames;
- private boolean hasParameters;
- private Method method;
- private String name, internalName;
- private MinecraftClass returnType;
- private boolean isMinecraftClass = false;
- private boolean loadFailed = false;
-
- private static HashMap> primitives;
- static {
- primitives = new HashMap>();
- primitives.put("byte", byte.class);
- primitives.put("int", int.class);
- primitives.put("float", float.class);
- primitives.put("short", short.class);
- primitives.put("long", long.class);
- primitives.put("double", double.class);
- primitives.put("boolean", boolean.class);
- primitives.put("char", char.class);
- primitives.put("String", String.class);
- }
- public MinecraftMethod(MinecraftClass parent, String name, String methodName) {
- this.parent = parent;
- hasParameters = false;
- this.name = name;
- internalName = methodName;
- paramClasses = new Class>[] {};
- }
- public MinecraftMethod(MinecraftClass parent, String name, String methodName, String... args) {
- this.parent = parent;
- paramNames = args;
- paramClasses = new Class>[paramNames.length];
- hasParameters = true;
- this.name = name;
- internalName = methodName;
- }
- public void load(Minecraft mc, MinecraftClass mcClass) {
- minecraft = mc;
- Class> clazz = mcClass.getClazz();
- int i = 0;
- try {
- if (hasParameters) {
- for (; i < paramNames.length; i++) {
- paramClasses[i] = primitives.get(paramNames[i]);
- if (paramClasses[i] == null)
- paramClasses[i] = mc.getClassLoader().loadClass(paramNames[i]); // TODO: Does this cause duplicate loads?
- }
- }
-
- method = clazz.getDeclaredMethod(internalName, paramClasses);
- method.setAccessible(true);
- String methodType = method.getReturnType().getName();
- if (methodType.contains(".")) {
- String[] typeSplit = methodType.split("\\.");
- methodType = typeSplit[typeSplit.length-1];
- }
- returnType = minecraft.getClassByType(methodType);
- if (returnType == null)
- isMinecraftClass = false;
- } catch (ClassNotFoundException e) {
- loadFailed = true;
- Log.w(e, "Unabled to find class for parameter. (" + paramNames[i] + ") on (" + mcClass.getName() + " / " + mcClass.getClassName() + ")");
- e.printStackTrace();
- } catch (SecurityException e) {
- loadFailed = true;
- Log.w(e, "SecurityException on (" + mcClass.getName() + " / " + mcClass.getClassName() + ") method (" + name + " / " + internalName +")");
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- loadFailed = true;
- Log.w(e, "Unable to find class method (" + mcClass.getName() + " / " + mcClass.getClassName() + ") (" + name + " / " + internalName +")");
- e.printStackTrace();
- }
- }
- public Object callStatic(Object... param) {
- Object value = call((Object)null, param);
- if (isMinecraftClass) {
- return new MinecraftObject(returnType, value);
- }
- return value;
- }
- public Object call(MinecraftObject obj, Object... param) {
- Object value = call(obj.get(), param);
- if (isMinecraftClass)
- return new MinecraftObject(returnType, value);
- return value;
- }
- private Object call(Object obj, Object... param) {
- try {
- return method.invoke(obj, param);
- } catch (IllegalArgumentException e) { // TODO : Add error text
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return null;
- }
- public Object getParentName() {
- return parent.getName();
- }
- public String getInternalName() {
- return internalName;
- }
- public String getName() {
- return name;
- }
- public boolean exists() {
- return !loadFailed;
- }
-}
diff --git a/src/amidst/minecraft/MinecraftObject.java b/src/amidst/minecraft/MinecraftObject.java
deleted file mode 100644
index 6cb8d882b..000000000
--- a/src/amidst/minecraft/MinecraftObject.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package amidst.minecraft;
-
-public class MinecraftObject {
- private MinecraftClass type;
- private Object value;
- public MinecraftObject(MinecraftClass type, Object value) {
- this.type = type;
- this.value = value;
- }
- public MinecraftObject(Minecraft mc, Object value) {
- this.type = mc.getClassByType(value.getClass().getCanonicalName());
- this.value = value;
- }
- public Object get() {
- return value;
- }
-
- public Object callFunction(String funcName, Object... args) {
- return type.callFunction(funcName, this, args);
- }
-
- public Object getValue(String propertyName) {
- return type.getValue(propertyName, this);
- }
-}
diff --git a/src/amidst/minecraft/MinecraftProperty.java b/src/amidst/minecraft/MinecraftProperty.java
deleted file mode 100644
index dcafc8656..000000000
--- a/src/amidst/minecraft/MinecraftProperty.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package amidst.minecraft;
-
-import java.lang.reflect.Field;
-
-import amidst.logging.Log;
-
-public class MinecraftProperty {
- private String name, internalName;
- private MinecraftClass parent;
- private Field property;
- private boolean isMinecraftClass = true;
- private MinecraftClass type;
- public MinecraftProperty(MinecraftClass parent, String name, String propertyName) {
- this.parent = parent;
- this.name = name;
- this.internalName = propertyName;
- }
-
-
-
- @Override
- public String toString() {
- return "[Method " + name +" (" + internalName +") of class " + parent.getName() + "]";
- }
-
-
-
- public String getName() {
- return name;
- }
-
- public String getInternalName() {
- return internalName;
- }
- public void setValue(Object obj, Object val) {
- try {
- property.set(obj, val);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- public void load(Minecraft mc, MinecraftClass mcClass) {
- Class> clazz = mcClass.getClazz();
- try {
- property = clazz.getDeclaredField(internalName);
- String propType = property.getType().getName();
- if (propType.contains(".")) {
- String[] typeSplit = propType.split("\\.");
- propType = typeSplit[typeSplit.length-1];
- }
- type = mc.getClassByType(propType);
- if (type == null)
- isMinecraftClass = false;
- property.setAccessible(true);
- } catch (SecurityException e) {
- Log.crash(e, "SecurityException on (" + mcClass.getName() + " / " + mcClass.getClassName() + ") property (" + name + " / " + internalName +")");
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- Log.crash(e, "Unable to find class property (" + mcClass.getName() + " / " + mcClass.getClassName() + ") (" + name + " / " + internalName +")");
- e.printStackTrace();
- }
- }
-
- public Object getValue(MinecraftObject mcObject) {
- Object object = mcObject.get();
- Object value = getValue(object);
- if (isMinecraftClass)
- return new MinecraftObject(type, value);
- return value;
- }
- public Object getStaticValue() {
- Object value = getValue((Object)null);
- if (isMinecraftClass) {
- return new MinecraftObject(type, value);
- }
- return value;
- }
- private Object getValue(Object obj) {
- try {
- return property.get(obj);
- } catch (IllegalArgumentException e) { // TODO : Add error text.
- e.printStackTrace();
- Log.crash(e, "Error [IllegalArgumentException] loading property (" + toString() + ")");
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- Log.crash(e, "Error [IllegalAccessException] loading property (" + toString() + ")");
- }
- return null;
- }
-
- public String getParentName() {
- return parent.getName();
- }
-}
diff --git a/src/amidst/minecraft/MinecraftUtil.java b/src/amidst/minecraft/MinecraftUtil.java
deleted file mode 100644
index e5893eb69..000000000
--- a/src/amidst/minecraft/MinecraftUtil.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package amidst.minecraft;
-
-import java.awt.Point;
-import java.util.List;
-import java.util.Random;
-
-import amidst.logging.Log;
-import amidst.version.VersionInfo;
-
-public class MinecraftUtil {
- private static IMinecraftInterface minecraftInterface;
-
- /** Returns a copy of the biome data (threadsafe). */
- public static int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolutionMap) {
- return minecraftInterface.getBiomeData(x, y, width, height, useQuarterResolutionMap);
- }
-
- public static Point findValidLocation(int searchX, int searchY, int size, List paramList, Random random) {
- // TODO: Find out if we should useQuarterResolutionMap or not
- // TODO: Clean up this code
- int x1 = searchX - size >> 2;
- int y1 = searchY - size >> 2;
- int x2 = searchX + size >> 2;
- int y2 = searchY + size >> 2;
-
- int width = x2 - x1 + 1;
- int height = y2 - y1 + 1;
- int[] arrayOfInt = getBiomeData(x1, y1, width, height, true);
- Point location = null;
- int numberOfValidFound = 0;
- for (int i = 0; i < width*height; i++) {
- int x = x1 + i % width << 2;
- int y = y1 + i / width << 2;
- if (arrayOfInt[i] > Biome.biomes.length)
- Log.crash("Unsupported biome type detected");
- Biome localBiome = Biome.biomes[arrayOfInt[i]];
- if ((!paramList.contains(localBiome)) || ((location != null) && (random.nextInt(numberOfValidFound + 1) != 0)))
- continue;
- location = new Point(x, y);
- numberOfValidFound++;
- }
-
- return location;
- }
-
- /**
- * Gets the biome located at the block-coordinates.
- * This is not a fast routine, it was added for rare things like
- * accurately testing structures.
- * (uses the 1:1 scale biome-map)
- * @return Assume this may return null.
- */
- public static Biome getBiomeAt(int x, int y) {
-
- int[] arrayOfInt = getBiomeData(x, y, 1, 1, false);
- return Biome.biomes[arrayOfInt[0] & 0xFF];
- }
-
- public static boolean isValidBiome(int x, int y, int size, List validBiomes) {
- int x1 = x - size >> 2;
- int y1 = y - size >> 2;
- int x2 = x + size >> 2;
- int y2 = y + size >> 2;
-
- int width = x2 - x1 + 1;
- int height = y2 - y1 + 1;
-
- int[] arrayOfInt = getBiomeData(x1, y1, width, height, true);
- for (int i = 0; i < width * height; i++) {
- Biome localBiome = Biome.biomes[arrayOfInt[i]];
- if (!validBiomes.contains(localBiome)) return false;
- }
- return true;
- }
-
- public static void createWorld(long seed, String type) {
- minecraftInterface.createWorld(seed, type, "");
- }
-
- public static void createWorld(long seed, String type, String generatorOptions) {
- minecraftInterface.createWorld(seed, type, generatorOptions);
- }
-
- public static void setBiomeInterface(IMinecraftInterface biomeInterface) {
- MinecraftUtil.minecraftInterface = biomeInterface;
- }
- public static VersionInfo getVersion() {
- return minecraftInterface.getVersion();
- }
-
- public static boolean hasInterface() {
- return minecraftInterface != null;
- }
-}
diff --git a/src/amidst/minecraft/remote/NetBiome.java b/src/amidst/minecraft/remote/NetBiome.java
deleted file mode 100644
index c4090a6c8..000000000
--- a/src/amidst/minecraft/remote/NetBiome.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package amidst.minecraft.remote;
-
-public class NetBiome {
- public int id, color;
- public String name;
- public NetBiome() {
-
- }
- public NetBiome(int id, String name, int color) {
- this.id = id;
- this.name = name;
- this.color = color;
- }
-}
diff --git a/src/amidst/minecraft/remote/NetCreateWorldRequest.java b/src/amidst/minecraft/remote/NetCreateWorldRequest.java
deleted file mode 100644
index 01ff9eaa1..000000000
--- a/src/amidst/minecraft/remote/NetCreateWorldRequest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package amidst.minecraft.remote;
-
-public class NetCreateWorldRequest {
- public long seed;
- public NetCreateWorldRequest() {
-
- }
- public NetCreateWorldRequest(long seed) {
- this.seed = seed;
- }
-}
diff --git a/src/amidst/minecraft/remote/NetGetBiomeDataRequest.java b/src/amidst/minecraft/remote/NetGetBiomeDataRequest.java
deleted file mode 100644
index a4bb6e8b5..000000000
--- a/src/amidst/minecraft/remote/NetGetBiomeDataRequest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package amidst.minecraft.remote;
-
-public class NetGetBiomeDataRequest {
- public int x, y, width, height;
- public boolean useQuarterResolutionMap;
- public NetGetBiomeDataRequest() {
-
- }
- public NetGetBiomeDataRequest(int x, int y, int width, int height, boolean useQuarterResolutionMap) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- this.useQuarterResolutionMap = useQuarterResolutionMap;
- }
-}
diff --git a/src/amidst/minecraft/remote/NetGetBiomeDataResult.java b/src/amidst/minecraft/remote/NetGetBiomeDataResult.java
deleted file mode 100644
index 05d84748a..000000000
--- a/src/amidst/minecraft/remote/NetGetBiomeDataResult.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package amidst.minecraft.remote;
-
-public class NetGetBiomeDataResult {
- public int[] data;
- public NetGetBiomeDataResult() {
-
- }
- public NetGetBiomeDataResult(int[] data) {
- this.data = data;
- }
-}
diff --git a/src/amidst/minecraft/remote/NetInfoRequest.java b/src/amidst/minecraft/remote/NetInfoRequest.java
deleted file mode 100644
index 6eedc8a99..000000000
--- a/src/amidst/minecraft/remote/NetInfoRequest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package amidst.minecraft.remote;
-
-public class NetInfoRequest {
- public NetInfoRequest() {
-
- }
-}
diff --git a/src/amidst/minecraft/remote/RemoteMinecraft.java b/src/amidst/minecraft/remote/RemoteMinecraft.java
deleted file mode 100644
index 9fac1f0c3..000000000
--- a/src/amidst/minecraft/remote/RemoteMinecraft.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package amidst.minecraft.remote;
-
-import java.io.IOException;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryonet.Client;
-import com.esotericsoftware.kryonet.Connection;
-import com.esotericsoftware.kryonet.Listener;
-
-import amidst.minecraft.Biome;
-import amidst.minecraft.IMinecraftInterface;
-import amidst.version.VersionInfo;
-
-public class RemoteMinecraft implements IMinecraftInterface {
- Client client;
- static NetGetBiomeDataResult currentResults = null;
-
- public RemoteMinecraft(String address) {
- client = new Client(65536, 65536);
- Kryo kryo = client.getKryo();
- kryo.register(NetCreateWorldRequest.class);
- kryo.register(NetGetBiomeDataRequest.class);
- kryo.register(NetGetBiomeDataResult.class);
- kryo.register(NetBiome.class);
- kryo.register(NetBiome[].class);
- kryo.register(NetInfoRequest.class);
- kryo.register(int[].class);
-
- client.addListener(new Listener() {
- @Override
- public void received(Connection connection, Object object) {
- if (object instanceof NetGetBiomeDataResult) {
- currentResults = (NetGetBiomeDataResult)object;
- //Log.i("Received NetGetBiomeDataResult: " + currentResults);
- } else if (object instanceof NetBiome[]) {
- NetBiome[] biomes = (NetBiome[])object;
- for (int i = 0; i < biomes.length; i++) {
- if (biomes[i] != null) {
- new Biome(biomes[i].name, biomes[i].id, biomes[i].color | 0xFF000000, true);
- }
- }
- }
- }
- });
-
- client.start();
- try {
- client.connect(5000, address, 54580, 54580);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- client.sendTCP(new NetInfoRequest());
-
- }
-
- @Override
- public int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolutionMap) {
- //Log.i("Send NetGetBiomeDataRequest");
- client.sendTCP(new NetGetBiomeDataRequest(x, y, width, height, useQuarterResolutionMap));
- while (currentResults == null) {
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- //Log.i("Passed to getBiomeData");
- int[] data = currentResults.data;
- currentResults = null;
- return data;
- }
-
- @Override
- public void createWorld(long seed, String type, String generatorOptions) {
- client.sendTCP(new NetCreateWorldRequest(seed));
- }
-
- @Override
- public VersionInfo getVersion() {
- return VersionInfo.unknown;
- }
-}
diff --git a/src/amidst/preferences/BiomeColorProfile.java b/src/amidst/preferences/BiomeColorProfile.java
deleted file mode 100644
index b6c11ce37..000000000
--- a/src/amidst/preferences/BiomeColorProfile.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package amidst.preferences;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import com.google.gson.JsonSyntaxException;
-
-import amidst.Options;
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.minecraft.Biome;
-
-public class BiomeColorProfile {
- private class BiomeColor {
- public String alias;
- public int r = 0;
- public int g = 0;
- public int b = 0;
- public BiomeColor(int rgb) {
- r = (rgb >> 16) & 0xFF;
- g = (rgb >> 8) & 0xFF;
- b = (rgb) & 0xFF;
- }
- public int toColorInt() {
- return Util.makeColor(r, g, b);
- }
- }
- public static boolean isEnabled = false;
-
- public HashMap colorMap = new HashMap();
- public int colorArray[] = new int[Biome.biomes.length];
- public String[] nameArray = new String[Biome.biomes.length];
- public String name;
- public String shortcut;
-
- public BiomeColorProfile() {
- name = "default";
- for (int i = 0; i < Biome.biomes.length; i++) {
- if (Biome.biomes[i] != null) {
- colorMap.put(Biome.biomes[i].name, new BiomeColor(Biome.biomes[i].color));
- }
- }
- }
-
- public void fillColorArray() {
- for (Map.Entry pairs : colorMap.entrySet()) {
- int index = Biome.indexFromName(pairs.getKey());
- if (index != -1) {
- colorArray[index] = pairs.getValue().toColorInt();
- nameArray[index] = (pairs.getValue().alias != null)?pairs.getValue().alias:Biome.biomes[index].name;
- } else {
- Log.i("Failed to find biome for: " + pairs.getKey() + " in profile: " + name);
- }
- }
- }
-
- public boolean save(File path) {
- String output = "";
- output += "{ \"name\":\"" + name + "\", \"colorMap\":[\r\n";
-
- for (Map.Entry pairs : colorMap.entrySet()) {
- output += "[ \"" + pairs.getKey() + "\", { ";
- output += "\"r\":" + pairs.getValue().r + ", ";
- output += "\"g\":" + pairs.getValue().g + ", ";
- output += "\"b\":" + pairs.getValue().b + " } ],\r\n";
- }
- output = output.substring(0, output.length() - 3);
-
- output += " ] }\r\n";
- BufferedWriter writer = null;
- try {
- writer = new BufferedWriter(new FileWriter(path));
- writer.write(output);
- writer.close();
- return true;
- } catch ( IOException e) {
- try {
- if (writer != null)
- writer.close();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- return false;
- }
-
- public void activate() {
- Options.instance.biomeColorProfile = this;
- Log.i("Biome color profile activated.");
- for (int i = 0; i < Biome.biomes.length; i++) {
- if (Biome.biomes[i] != null) {
- Biome.biomes[i].color = colorArray[i];
- }
- }
- if (amidst.map.Map.instance != null)
- amidst.map.Map.instance.resetFragments();
- }
-
-
- public static void scan() {
- Log.i("Searching for biome color profiles.");
- File colorProfileFolder = new File("./biome");
-
- if (!colorProfileFolder.exists() || !colorProfileFolder.isDirectory()) {
- Log.i("Unable to find biome color profile folder.");
- return;
- }
-
- File defaultProfileFile = new File("./biome/default.json");
- if (!defaultProfileFile.exists())
- if (!Options.instance.biomeColorProfile.save(defaultProfileFile))
- Log.i("Attempted to save default biome color profile, but encountered an error.");
-
- /*
- File[] colorProfiles = colorProfileFolder.listFiles();
- for (int i = 0; i < colorProfiles.length; i++) {
- if (colorProfiles[i].exists() && colorProfiles[i].isFile()) {
- try {
- BiomeColorProfile profile = Util.readObject(colorProfiles[i], BiomeColorProfile.class);
- profile.fillColorArray();
- profiles.add(profile);
- } catch (FileNotFoundException e) {
- Log.i("Unable to load file: " + colorProfiles[i]);
- }
- }
- }*/
- isEnabled = true;
- }
-
- public static BiomeColorProfile createFromFile(File file) {
- BiomeColorProfile profile = null;
- if (file.exists() && file.isFile()) {
- try {
- profile = Util.readObject(file, BiomeColorProfile.class);
- profile.fillColorArray();
- } catch (JsonSyntaxException e) {
- Log.w("Unable to load file: " + file);
- e.printStackTrace();
- } catch (IOException e) {
- Log.i("Unable to load file: " + file);
- }
- }
- return profile;
- }
-
- public String getAliasForId(int id) {
- if (nameArray[id] != null)
- return nameArray[id];
- return Biome.biomes[id].name;
- }
-}
diff --git a/src/amidst/preferences/BooleanPrefModel.java b/src/amidst/preferences/BooleanPrefModel.java
deleted file mode 100644
index babc35a7e..000000000
--- a/src/amidst/preferences/BooleanPrefModel.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package amidst.preferences;
-
-import javax.swing.JToggleButton.ToggleButtonModel;
-import java.util.prefs.Preferences;
-
-public class BooleanPrefModel extends ToggleButtonModel implements PrefModel {
- private static final long serialVersionUID = -2291122955784916836L;
-
- private final String key;
- private final Preferences pref;
-
- public BooleanPrefModel(Preferences pref, String key, boolean selected) {
- super();
- this.pref = pref;
- this.key = key;
- set(pref.getBoolean(key, selected));
- }
-
- @Override
- public String getKey() {
- return key;
- }
-
- @Override
- public Boolean get() {
- assert pref.get(key, null) != null && pref.getBoolean(key, false) == super.isSelected();
- return super.isSelected();
- }
-
- @Override
- public boolean isSelected() {
- return get();
- }
-
- @Override
- public void set(Boolean value) {
- super.setSelected(value);
- pref.putBoolean(key, value);
- }
-
- @Override
- public void setSelected(boolean value) {
- set(value);
- }
-}
diff --git a/src/amidst/preferences/FilePrefModel.java b/src/amidst/preferences/FilePrefModel.java
deleted file mode 100644
index c345c2526..000000000
--- a/src/amidst/preferences/FilePrefModel.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package amidst.preferences;
-import java.io.File;
-import java.io.IOException;
-import java.util.prefs.Preferences;
-
-/** Autosaving File model
- */
-public class FilePrefModel implements PrefModel {
- private final String key;
- private final Preferences pref;
-
- public FilePrefModel(Preferences pref, String key, File init) {
- super();
- this.pref = pref;
- this.key = key;
- if (pref.get(key, null) == null)
- set(init);
- }
-
- @Override
- public String getKey() {
- return key;
- }
-
- @Override
- public File get() {
- String path = pref.get(key, null);
- assert path != null;
- return new File(path);
- }
-
- @Override
- public void set(File value) {
- try {
- pref.put(key, value.getCanonicalPath());
- } catch (IOException ignored) {
- pref.put(key, value.getPath());
- }
- }
-}
\ No newline at end of file
diff --git a/src/amidst/preferences/PrefModel.java b/src/amidst/preferences/PrefModel.java
deleted file mode 100644
index 608caa4dc..000000000
--- a/src/amidst/preferences/PrefModel.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package amidst.preferences;
-
-import java.io.IOException;
-
-/** Backed by a Preferences instance, saves and loads its value from and to it.
- * TODO: test the fuck out of this
- */
-public interface PrefModel {
- String getKey();
-
- public T get();
- public void set(T value) throws IOException;
-}
diff --git a/src/amidst/preferences/SelectPrefModel.java b/src/amidst/preferences/SelectPrefModel.java
deleted file mode 100644
index 334d20803..000000000
--- a/src/amidst/preferences/SelectPrefModel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package amidst.preferences;
-
-import java.util.prefs.Preferences;
-
-import javax.swing.JToggleButton.ToggleButtonModel;
-
-public class SelectPrefModel implements PrefModel {
- public class SelectButtonModel extends ToggleButtonModel {
- private SelectPrefModel model;
- public String name;
- public SelectButtonModel(SelectPrefModel model, String name) {
- this.model = model;
- this.name = name;
- super.setSelected(false);
- }
-
- @Override
- public boolean isSelected() {
- return model.get().equals(name);
- }
-
- @Override
- public void setSelected(boolean value) {
- super.setSelected(value);
- if (value)
- model.set(name);
- }
-
- public String getName() {
- return name;
- }
- }
- private Preferences preferences;
- private String key;
- private String selected;
- private SelectButtonModel buttonModels[];
- public SelectPrefModel(Preferences pref, String key, String selected, String[] names) {
- this.key = key;
- this.preferences = pref;
- this.selected = selected;
- buttonModels = new SelectButtonModel[names.length];
- for (int i = 0; i < buttonModels.length; i++)
- buttonModels[i] = new SelectButtonModel(this, names[i]);
- set(pref.get(key, selected));
-
- }
-
- @Override
- public String getKey() {
- return key;
- }
-
- @Override
- public String get() {
- return selected;
- }
-
- public SelectButtonModel[] getButtonModels() {
- return buttonModels;
- }
-
- @Override
- public void set(String value) {
- preferences.put(key, value);
- selected = value;
- for (int i = 0; i < buttonModels.length; i++)
- if (!value.equals(buttonModels[i].name))
- buttonModels[i].setSelected(false);
- }
-}
diff --git a/src/amidst/preferences/StringPreference.java b/src/amidst/preferences/StringPreference.java
deleted file mode 100644
index d6bf1f0a2..000000000
--- a/src/amidst/preferences/StringPreference.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package amidst.preferences;
-
-import java.util.prefs.Preferences;
-
-public class StringPreference {
- private Preferences preferences;
- private String key;
- private String value;
-
- public StringPreference(Preferences preferences, String key, String defaultValue) {
- this.preferences = preferences;
- this.key = key;
- value = preferences.get(key, defaultValue);
- }
-
- public String get() {
- return value;
- }
-
- public void set(String value) {
- preferences.put(key, value);
- }
-}
diff --git a/src/amidst/resources/ResourceLoader.java b/src/amidst/resources/ResourceLoader.java
deleted file mode 100644
index feff0f7ac..000000000
--- a/src/amidst/resources/ResourceLoader.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package amidst.resources;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-public class ResourceLoader {
- private ResourceLoader() {}
-
- public static URL getResourceURL(String name) {
- // This is also a valid way to load resources, although I'm not sure which is better.
- //return ClassLoader.getSystemClassLoader().getResource("amidst/resources/" + name);
- return ResourceLoader.class.getResource(name);
- }
-
- public static InputStream getResourceStream(String name) {
- return ResourceLoader.class.getResourceAsStream(name);
- }
-
- public static BufferedImage getImage(String name) {
- try {
- return ImageIO.read(getResourceURL(name));
- } catch (IOException e) { //Don't forget to run the tests :)
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/src/amidst/resources/licenses/jgoogleanalytics.txt b/src/amidst/resources/licenses/jgoogleanalytics.txt
deleted file mode 100644
index 3f014a0e7..000000000
--- a/src/amidst/resources/licenses/jgoogleanalytics.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-JGoogleAnalytics is licensed under "Apache License, Version 2.0"
-More information can be found here: http://www.apache.org/licenses/LICENSE-2.0
\ No newline at end of file
diff --git a/src/amidst/resources/licenses/kryonet.txt b/src/amidst/resources/licenses/kryonet.txt
deleted file mode 100644
index 3f6a160c2..000000000
--- a/src/amidst/resources/licenses/kryonet.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2008, Nathan Sweet
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of Esoteric Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/src/amidst/resources/licenses/rhino.txt b/src/amidst/resources/licenses/rhino.txt
deleted file mode 100644
index c0e7c21fb..000000000
--- a/src/amidst/resources/licenses/rhino.txt
+++ /dev/null
@@ -1,375 +0,0 @@
-The majority of Rhino is licensed under the MPL 2.0:
-
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0.
diff --git a/src/amidst/utilties/FramerateTimer.java b/src/amidst/utilties/FramerateTimer.java
deleted file mode 100644
index f24f86f00..000000000
--- a/src/amidst/utilties/FramerateTimer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package amidst.utilties;
-
-public class FramerateTimer {
- private int tickCounter;
- private long lastUpdate;
- private long msPerUpdate;
-
- private float currentFPS = 0.0f;
-
- public FramerateTimer(int updatesPerSecond) {
- msPerUpdate = (long)(1000f * (1f/updatesPerSecond));
- reset();
- }
-
- public void reset() {
- tickCounter = 0;
- lastUpdate = System.currentTimeMillis();
- }
-
- public void tick() {
- tickCounter++;
- long curTime = System.currentTimeMillis();
-
- if (curTime - lastUpdate > msPerUpdate) {
- float timeDifference = curTime - lastUpdate;
-
- timeDifference /= 1000f;
- timeDifference = tickCounter/timeDifference;
-
- currentFPS = timeDifference;
-
- tickCounter = 0;
- lastUpdate = curTime;
-
- }
- }
-
- public float getFramerate() {
- return currentFPS;
- }
-
- @Override
- public String toString() {
- return "FPS: " + String.format("%.1f", currentFPS);
- }
-}
diff --git a/src/amidst/utilties/ProgressListener.java b/src/amidst/utilties/ProgressListener.java
deleted file mode 100644
index 6069ff5b8..000000000
--- a/src/amidst/utilties/ProgressListener.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package amidst.utilties;
-
-public abstract class ProgressListener {
- public abstract void onUpdate(ProgressMeter meter, double value);
- public abstract void onComplete(ProgressMeter meter);
-}
diff --git a/src/amidst/utilties/ProgressMeter.java b/src/amidst/utilties/ProgressMeter.java
deleted file mode 100644
index c822da72f..000000000
--- a/src/amidst/utilties/ProgressMeter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package amidst.utilties;
-
-import java.util.Deque;
-
-public class ProgressMeter {
- public float minimum = 0.0f;
- public float maximum = 1.0f;
- public float progress = 0.0f;
- public boolean isComplete = false;
-
- public Deque listeners;
-
-
- public ProgressMeter() {
-
- }
-
- public void update(float value) {
- progress = value;
- for (ProgressListener listener : listeners)
- listener.onComplete(this);
-
- if (!isComplete) {
- if (progress >= maximum) {
- isComplete = true;
- for (ProgressListener listener : listeners)
- listener.onComplete(this);
- }
- }
- }
-
- public void reset() {
- progress = minimum;
- isComplete = false;
- }
-
- public float getPrecentage() {
- return (progress - minimum) / (maximum - minimum);
- }
-}
diff --git a/src/amidst/version/ILatestVersionListListener.java b/src/amidst/version/ILatestVersionListListener.java
deleted file mode 100644
index 661ceefae..000000000
--- a/src/amidst/version/ILatestVersionListListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package amidst.version;
-
-public interface ILatestVersionListListener {
- public void onLoadStateChange(LatestVersionListEvent event);
-}
diff --git a/src/amidst/version/IProfileUpdateListener.java b/src/amidst/version/IProfileUpdateListener.java
deleted file mode 100644
index faa603d1b..000000000
--- a/src/amidst/version/IProfileUpdateListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package amidst.version;
-
-public interface IProfileUpdateListener {
- public void onProfileUpdate(ProfileUpdateEvent event);
-}
diff --git a/src/amidst/version/LatestVersionList.java b/src/amidst/version/LatestVersionList.java
deleted file mode 100644
index 0120ae54a..000000000
--- a/src/amidst/version/LatestVersionList.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package amidst.version;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.google.gson.JsonSyntaxException;
-
-import amidst.Util;
-import amidst.logging.Log;
-import amidst.resources.ResourceLoader;
-
-public class LatestVersionList {
- public static LatestVersionList instance = new LatestVersionList();
- public static LatestVersionList get() {
- return instance;
- }
- public enum LoadState {
- LOADED,
- LOADING,
- FAILED,
- IDLE
- }
-
- private LoadState loadState = LoadState.IDLE;
-
- private VersionList profile;
-
- private ArrayList loadListeners = new ArrayList();
- private Object listenerLock = new Object();
-
- public LatestVersionList() {
-
- }
-
- public HashMap[] getVersions() {
- return profile.versions;
- }
-
- public void load(boolean threaded) {
- if (threaded) {
- (new Thread(new Runnable() {
- @Override
- public void run() {
- doLoad();
- }
- })).start();
- } else {
- doLoad();
- }
- }
-
- private void doLoad() {
- Log.i("Beginning latest version list load.");
- setLoadState(LoadState.LOADING);
- if (!attemptRemoteLoad() && !attemptLocalLoad()) {
- Log.w("Failed to load both remote and local version list.");
- setLoadState(LoadState.FAILED);
- }
-
- setLoadState(LoadState.LOADED);
- }
-
- private boolean attemptLocalLoad() {
- Log.i("Attempting to download local version list...");
- URL versionUrl = ResourceLoader.getResourceURL("versions.json");
- return attemptLoad(versionUrl);
- }
-
- private boolean attemptRemoteLoad() {
- Log.i("Attempting to download remote version list...");
- URL versionUrl = null;
- try {
- versionUrl = new URL(Util.REMOTE_VERSION_LIST_URL);
- } catch (MalformedURLException e) {
- Log.w("MalformedURLException on remote version list. Aborting load. This should never be possible.");
- Log.printTraceStack(e);
- Log.w("Aborting remote version list load.");
- return false;
- }
-
- return attemptLoad(versionUrl);
- }
-
- private boolean attemptLoad(URL versionUrl) {
- URLConnection urlConnection = null;
- try {
- urlConnection = versionUrl.openConnection();
- } catch (IOException e) {
- Log.w("IOException when attempting to open connection to version list.");
- Log.printTraceStack(e);
- Log.w("Aborting version list load. URL: " + versionUrl);
- return false;
- }
-
- int contentLength = urlConnection.getContentLength();
- if (contentLength == -1) {
- Log.w("Content length of version list returned -1.");
- Log.w("Aborting version list load. URL: " + versionUrl);
- return false;
- }
-
- InputStream inputStream = null;
- try {
- inputStream = urlConnection.getInputStream();
- } catch (IOException e) {
- Log.w("IOException on opening input stream to version list.");
- Log.printTraceStack(e);
- Log.w("Aborting version list load. URL: " + versionUrl);
- return false;
- }
-
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- try {
- profile = Util.readObject(bufferedReader, VersionList.class);
- } catch (JsonSyntaxException e) {
- Log.w("Unable to parse version list.");
- Log.printTraceStack(e);
- Log.w("Aborting version list load. URL: " + versionUrl);
- return false;
- } finally {
- try {
- bufferedReader.close();
- } catch (IOException e) {
- Log.w("IOException thrown when attempting to close stream for version list.");
- Log.printTraceStack(e);
- }
- }
-
- Log.i("Successfully loaded version list. URL: " + versionUrl);
- return true;
- }
-
- public LoadState getLoadState() {
- return loadState;
- }
-
- private void setLoadState(LoadState state) {
- synchronized (listenerLock) {
- loadState = state;
- for (ILatestVersionListListener listener : loadListeners)
- listener.onLoadStateChange(new LatestVersionListEvent(this));
- }
- }
-
- public void addLoadListener(ILatestVersionListListener listener) {
- synchronized (listenerLock) {
- loadListeners.add(listener);
- }
- }
-
- public void removeLoadListener(ILatestVersionListListener listener) {
- synchronized (listenerLock) {
- loadListeners.remove(listener);
- }
- }
-
- public void addAndNotifyLoadListener(ILatestVersionListListener listener) {
- synchronized (listenerLock) {
- loadListeners.add(listener);
- listener.onLoadStateChange(new LatestVersionListEvent(this));
- }
- }
-
- private class VersionList {
- public HashMap latest;
- public HashMap[] versions;
- }
-}
diff --git a/src/amidst/version/LatestVersionListEvent.java b/src/amidst/version/LatestVersionListEvent.java
deleted file mode 100644
index 98c608818..000000000
--- a/src/amidst/version/LatestVersionListEvent.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package amidst.version;
-
-public class LatestVersionListEvent {
- private LatestVersionList source;
- public LatestVersionListEvent(LatestVersionList source) {
- this.source = source;
- }
- public LatestVersionList getSource() {
- return source;
- }
-}
diff --git a/src/amidst/version/MinecraftProfile.java b/src/amidst/version/MinecraftProfile.java
deleted file mode 100644
index b7ccdcba1..000000000
--- a/src/amidst/version/MinecraftProfile.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package amidst.version;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import amidst.json.InstallInformation;
-
-public class MinecraftProfile implements ILatestVersionListListener {
- public enum Status {
- IDLE("scanning"),
- MISSING("missing"),
- FAILED("failed"),
- FOUND("found");
-
- private String name;
- private Status(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
- private ArrayList listeners = new ArrayList();
-
- private MinecraftVersion version;
- private InstallInformation profile;
-
- private Status status = Status.IDLE;
- private String versionName = "unknown";
-
- public MinecraftProfile(InstallInformation profile) {
- this.profile = profile;
- if (profile.lastVersionId.equals("latest")) {
- LatestVersionList.get().addAndNotifyLoadListener(this);
- } else {
- version = MinecraftVersion.fromVersionId(profile.lastVersionId);
- if (version == null) {
- status = Status.MISSING;
- return;
- }
- status = Status.FOUND;
- versionName = version.getName();
- }
- }
-
- public String getProfileName() {
- return profile.name;
- }
-
- public String getGameDir() {
- return profile.gameDir;
- }
-
- public String getVersionName() {
- return versionName;
- }
-
- public void addUpdateListener(IProfileUpdateListener listener) {
- listeners.add(listener);
- }
- public void removeUpdateListener(IProfileUpdateListener listener) {
- listeners.remove(listener);
- }
-
- public Status getStatus() {
- return status;
- }
-
- @Override
- public void onLoadStateChange(LatestVersionListEvent event) {
- switch (event.getSource().getLoadState()) {
- case FAILED:
- status = Status.FAILED;
- break;
- case IDLE:
- status = Status.IDLE;
- break;
- case LOADED:
- status = Status.FOUND;
- boolean usingSnapshots = false;
- for (int i = 0; i < profile.allowedReleaseTypes.length; i++)
- if (profile.allowedReleaseTypes[i].equals("snapshot"))
- usingSnapshots = true;
- if (usingSnapshots)
- version = MinecraftVersion.fromLatestSnapshot();
- else
- version = MinecraftVersion.fromLatestRelease();
- if (version == null)
- status = Status.FAILED;
- else
- versionName = version.getName();
- break;
- case LOADING:
- status = Status.IDLE;
- break;
- }
- for (IProfileUpdateListener listener: listeners)
- listener.onProfileUpdate(new ProfileUpdateEvent(this));
- }
-
- public File getJarFile() {
- return version.getJarFile();
- }
-}
diff --git a/src/amidst/version/MinecraftVersion.java b/src/amidst/version/MinecraftVersion.java
deleted file mode 100644
index b1abee844..000000000
--- a/src/amidst/version/MinecraftVersion.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package amidst.version;
-
-import java.io.File;
-import java.util.HashMap;
-
-import amidst.Util;
-import amidst.logging.Log;
-
-public class MinecraftVersion {
- private File jarFile, jsonFile;
- private String name;
-
- private MinecraftVersion(String name, File jarFile, File jsonFile) {
- this.name = name;
-
- this.jarFile = jarFile;
- this.jsonFile = jsonFile;
- }
- public static MinecraftVersion fromVersionId(String lastVersionId) {
- return fromVersionPath(new File(Util.minecraftDirectory + "/versions/" + lastVersionId));
- }
- public static MinecraftVersion fromVersionPath(File path) {
- File jarFile = new File(path + "/" + path.getName() + ".jar");
- File jsonFile = new File(path + "/" + path.getName() + ".json");
-
- if (!jarFile.exists() || jarFile.isDirectory()) {
- Log.w("Unable to load MinecraftVersion at path: " + path + " because jarFile: " + jarFile + " is missing or a directory.");
- return null;
- }
- if (!jsonFile.exists() || jsonFile.isDirectory()) {
- Log.w("Unable to load MinecraftVersion at path: " + path + " because jsonFile: " + jsonFile + " is missing or a directory.");
- return null;
- }
-
- MinecraftVersion version = new MinecraftVersion(path.getName(), jarFile, jsonFile);
- return version;
- }
- public static MinecraftVersion fromLatestRelease() {
- MinecraftVersion version = null;
- HashMap[] versions = LatestVersionList.get().getVersions();
-
- for (int i = 0; i < versions.length; i++) {
- if (versions[i].get("type").equals("release") && (version = fromVersionId(versions[i].get("id"))) != null)
- return version;
- }
- return null;
- }
-
- public static MinecraftVersion fromLatestSnapshot() {
- MinecraftVersion version = null;
- HashMap[] versions = LatestVersionList.get().getVersions();
-
- for (int i = 0; i < versions.length; i++) {
- if ((version = fromVersionId(versions[i].get("id"))) != null)
- return version;
- }
- return null;
- }
-
- public String getName() {
- return name;
- }
- public File getJarFile() {
- return jarFile;
- }
-}
diff --git a/src/amidst/version/ProfileUpdateEvent.java b/src/amidst/version/ProfileUpdateEvent.java
deleted file mode 100644
index 9edc4dc0c..000000000
--- a/src/amidst/version/ProfileUpdateEvent.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package amidst.version;
-
-public class ProfileUpdateEvent {
- private MinecraftProfile profile;
- public ProfileUpdateEvent(MinecraftProfile profile) {
- this.profile = profile;
- }
-
- public MinecraftProfile getSource() {
- return profile;
- }
-}
diff --git a/src/amidst/version/VersionFactory.java b/src/amidst/version/VersionFactory.java
deleted file mode 100644
index a446c9edc..000000000
--- a/src/amidst/version/VersionFactory.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package amidst.version;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Stack;
-
-import com.google.gson.JsonSyntaxException;
-
-import amidst.Util;
-import amidst.json.InstallInformation;
-import amidst.json.LauncherProfile;
-import amidst.logging.Log;
-
-public class VersionFactory {
- private MinecraftVersion[] localVersions;
- private MinecraftProfile[] profiles;
- public VersionFactory() {
-
- }
-
- public void scanForLocalVersions() {
- File versionPath = new File(Util.minecraftDirectory + "/versions");
- if (!versionPath.exists()) {
- Log.e("Cannot find version directory.");
- return;
- } else if (!versionPath.isDirectory()) {
- Log.e("Attempted to open version directory but found file.");
- return;
- }
- File[] versionDirectories = versionPath.listFiles();
- Stack versionStack = new Stack();
- for (int i = 0; i < versionDirectories.length; i++) {
- MinecraftVersion version = MinecraftVersion.fromVersionPath(versionDirectories[i]);
- if (version != null)
- versionStack.add(version);
- }
- if (versionStack.size() == 0)
- return;
-
- localVersions = new MinecraftVersion[versionStack.size()];
- versionStack.toArray(localVersions);
- }
-
- public void scanForProfiles() {
- Log.i("Scanning for profiles.");
- File profileJsonFile = new File(Util.minecraftDirectory + "/launcher_profiles.json");
- LauncherProfile launcherProfile = null;
- try {
- launcherProfile = Util.readObject(profileJsonFile, LauncherProfile.class);
- } catch (JsonSyntaxException e) {
- Log.crash(e, "Syntax exception thrown from launch_profiles.json");
- return;
- } catch (IOException e) {
- Log.crash(e, "Unable to open launch_profiles.json");
- return;
- }
- Log.i("Successfully loaded profile list.");
-
- profiles = new MinecraftProfile[launcherProfile.profiles.size()];
-
- int i = 0;
- for (InstallInformation installInformation : launcherProfile.profiles.values())
- profiles[i++] = new MinecraftProfile(installInformation);
-
-
- }
- public MinecraftProfile[] getProfiles() {
- return profiles;
- }
- public MinecraftVersion[] getLocalVersions() {
- return localVersions;
- }
-}
diff --git a/src/amidst/version/VersionInfo.java b/src/amidst/version/VersionInfo.java
deleted file mode 100644
index b278f9f55..000000000
--- a/src/amidst/version/VersionInfo.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package amidst.version;
-
-/** Information about what each supported version is
- */
-public enum VersionInfo {
- unknown(null),
- V1_8_4("orntlljs[Lle;lx[J[[Jlt"),
- V1_8_3("osnulmjt[Llf;ly[J[[Jlu"), // 1.8.3 and 1.8.2 have the same typeDump version ID - probably because 1.8.2 -> 1.8.3 was a fix for a server-side bug (https://mojang.com/2015/02/minecraft-1-8-2-is-now-available/)
- V1_8_1("wduyrdnq[Lqu;sp[J[[Jsa"),
- V1_8("wbuwrcnp[Lqt;sn[J[[Jry"),
- V14w21b("tjseoylw[Loq;qd[J[[Jpo"),
- V1_7_10("riqinckb[Lmt;oi[J[[Jns"),
- V1_7_9("rhqhnbkb[Lms;oh[J[[Jnr"),
- V14w02a("qrponkki[Lnb;lv[J[[J"),
- V1_7_4("pzozmvjs[Lmm;lg[J[[J"),
- V1_7_2("pvovmsjp[Lmj;ld[J[[J"),
- V13w39a_or_b("npmp[Lkn;jh[J[J[J[J[J[[J"),
- V13w37b_or_38a("ntmt[Lkm;jg[J[J[J[J[J[[J"),
- V13w37a("nsms[Lkl;jf[J[J[J[J[J[[J"),
- V13w36b("nkmk[Lkd;hw[J[J[J[J[J[[J"),
- V13w36a("nkmk[Lkd;hx[J[J[J[J[J[[J"),
- V1_6_4("mvlv[Ljs;hn[J[J[J[J[J[[J"),
- V1_6_2("mulu[Ljr;hm[J[J[J[J[J[[J"),
- V1_6_1("msls[Ljp;hk[J[J[J[J[J[[J"),
- V1_5_1("[Bbeabdsbawemabdtbfzbdwngngbevawfbgfawvawvaxrawbbfrausbjhaycawwaraavybkdavwbjvbkila"),
- V1_5_0("Invalid"), // TODO: This makes no sense? 1.5.0 is not on the version list!
- V1_4_6("[Baywayoaaszleaypbavaysmdazratabbaatqatqaulaswbanarnbdzauwatraohastbevasrbenbezbdmbdjkh"), // Includes 1.4.7
- V1_4_5("[Bayoaygaasrleayhbakaykmdazfassbapatjatjaueasobacarfbdoaupatkanzaslbekasjbecbenbdbbcykh"),
- V1_4_2("[Baxgawyaarjkpawzayyaxclnaxxarkazcasbasbaswargaytaqabcbathascamuardbcxarbbcpbdabbobbljy"),
- V1_3_2("[Batkatcaaofjbatdavbatgjwaubaogavfaovaovapnaocauwamxaxvapyaowajqanzayqanxayjaytaxkaxhik"),
- V1_3_1("adb"),
- V1_3pre("acl"),
- V12w27a("acs"),
- V12w26a("acl"),
- V12w25a("acg"),
- V12w24a("aca"),
- V12w23b("acg"),
- V12w22a("ace"),
- V12w21b("aby"),
- V12w21a("abm"),
- V12w19a("aau"),
- V1_2_4("[Bkivmaftxdlvqacqcwfcaawnlnlvpjclrckqdaiyxgplhusdakagi[J[Jalfqabv"), // Includes 1.2.5
- V1_2_2("wl"),
- V12w08a("wj"),
- V12w07b("wd"),
- V12w06a("wb"),
- V12w05a("vy"),
- V12w04a("vu"),
- V12w03a("vj"),
- V1_1("[Bjsudadrvqluhaarcqevyzmqmqugiokzcepgagqvsonhhrgahqfy[J[Jaitpdbo"),
- V1_0("[Baesmmaijryafvdinqfdrzhabeabexexwadtnglkqdfagvkiahmhsadk[J[Jtkgkyu"),
- V1_9pre6("uk"), // TODO: Remove these versions?
- V1_9pre5("ug"),
- V1_9pre4("uh"), //TODO stronghold reset??
- V1_9pre3("to"),
- V1_9pre2("sv"),
- V1_9pre1("sq"),
- Vbeta_1_8_1("[Bhwqpyrrviqswdbzdqurkhqrgviwbomnabjrxmafvoeacfer[J[Jaddmkbb"); // Had to rename from V1_8_1 - should it just be removed?
-
- public final String versionId;
-
- VersionInfo(String versionId) {
- this.versionId = versionId;
- }
-
- public boolean saveEnabled() {
- return this != V12w21a && this != V12w21b && this != V12w22a;
- }
-
- @Override
- public String toString() {
- return super.toString().replace("_", ".");
- }
-
- public boolean isAtLeast(VersionInfo other) {
- return this.ordinal() <= other.ordinal();
- }
-}
\ No newline at end of file
diff --git a/src/devtools/java/amidst/devtools/MinecraftJarDownloadAvailabilityChecker.java b/src/devtools/java/amidst/devtools/MinecraftJarDownloadAvailabilityChecker.java
new file mode 100644
index 000000000..48d66273c
--- /dev/null
+++ b/src/devtools/java/amidst/devtools/MinecraftJarDownloadAvailabilityChecker.java
@@ -0,0 +1,33 @@
+package amidst.devtools;
+
+import java.io.IOException;
+
+import amidst.devtools.utils.VersionStateRenderer;
+import amidst.mojangapi.file.MojangApiParsingException;
+import amidst.mojangapi.file.json.JsonReader;
+import amidst.mojangapi.file.json.versionlist.VersionListEntryJson;
+import amidst.mojangapi.file.json.versionlist.VersionListJson;
+
+public class MinecraftJarDownloadAvailabilityChecker {
+ public static void main(String[] args) throws IOException,
+ MojangApiParsingException {
+ new MinecraftJarDownloadAvailabilityChecker(
+ JsonReader.readRemoteVersionList())
+ .displayDownloadAvailability();
+ }
+
+ private VersionStateRenderer renderer = new VersionStateRenderer();
+ private VersionListJson versionList;
+
+ public MinecraftJarDownloadAvailabilityChecker(VersionListJson versionList) {
+ this.versionList = versionList;
+ }
+
+ public void displayDownloadAvailability() {
+ for (VersionListEntryJson version : versionList.getVersions()) {
+ boolean hasServer = version.hasServer();
+ boolean hasClient = version.hasClient();
+ System.out.println(renderer.render(version, hasServer, hasClient));
+ }
+ }
+}
diff --git a/src/devtools/java/amidst/devtools/MinecraftJarDownloader.java b/src/devtools/java/amidst/devtools/MinecraftJarDownloader.java
new file mode 100644
index 000000000..80f1e835d
--- /dev/null
+++ b/src/devtools/java/amidst/devtools/MinecraftJarDownloader.java
@@ -0,0 +1,36 @@
+package amidst.devtools;
+
+import java.io.IOException;
+
+import amidst.devtools.settings.DevToolsSettings;
+import amidst.devtools.utils.VersionStateRenderer;
+import amidst.mojangapi.file.MojangApiParsingException;
+import amidst.mojangapi.file.json.JsonReader;
+import amidst.mojangapi.file.json.versionlist.VersionListEntryJson;
+import amidst.mojangapi.file.json.versionlist.VersionListJson;
+
+public class MinecraftJarDownloader {
+ public static void main(String[] args) throws IOException,
+ MojangApiParsingException {
+ new MinecraftJarDownloader(
+ DevToolsSettings.INSTANCE.getMinecraftVersionsDirectory(),
+ JsonReader.readRemoteVersionList()).downloadAll();
+ }
+
+ private VersionStateRenderer renderer = new VersionStateRenderer();
+ private String prefix;
+ private VersionListJson versionList;
+
+ public MinecraftJarDownloader(String prefix, VersionListJson versionList) {
+ this.prefix = prefix;
+ this.versionList = versionList;
+ }
+
+ public void downloadAll() {
+ for (VersionListEntryJson version : versionList.getVersions()) {
+ boolean hasServer = version.tryDownloadServer(prefix);
+ boolean hasClient = version.tryDownloadClient(prefix);
+ System.out.println(renderer.render(version, hasServer, hasClient));
+ }
+ }
+}
diff --git a/src/devtools/java/amidst/devtools/MinecraftVersionCompatibilityChecker.java b/src/devtools/java/amidst/devtools/MinecraftVersionCompatibilityChecker.java
new file mode 100644
index 000000000..3da1a83bf
--- /dev/null
+++ b/src/devtools/java/amidst/devtools/MinecraftVersionCompatibilityChecker.java
@@ -0,0 +1,96 @@
+package amidst.devtools;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import amidst.clazz.Classes;
+import amidst.clazz.real.JarFileParsingException;
+import amidst.clazz.symbolic.declaration.SymbolicClassDeclaration;
+import amidst.clazz.translator.ClassTranslator;
+import amidst.devtools.settings.DevToolsSettings;
+import amidst.mojangapi.file.MojangApiParsingException;
+import amidst.mojangapi.file.json.JsonReader;
+import amidst.mojangapi.file.json.versionlist.VersionListEntryJson;
+import amidst.mojangapi.file.json.versionlist.VersionListJson;
+import amidst.mojangapi.minecraftinterface.local.DefaultClassTranslator;
+
+/**
+ * This only checks if there is exactly one class in the jar file for each
+ * class, defined by the class translator. Optional classes can be missing.
+ * However, it does not check if the class has all the required constructors,
+ * methods and fields. It also does not try to use the found classes.
+ */
+public class MinecraftVersionCompatibilityChecker {
+ public static void main(String[] args) throws IOException,
+ MojangApiParsingException {
+ new MinecraftVersionCompatibilityChecker(
+ DevToolsSettings.INSTANCE.getMinecraftVersionsDirectory(),
+ JsonReader.readRemoteVersionList()).checkAll();
+ }
+
+ private String prefix;
+ private VersionListJson versionList;
+
+ public MinecraftVersionCompatibilityChecker(String prefix,
+ VersionListJson versionList) {
+ this.prefix = prefix;
+ this.versionList = versionList;
+ }
+
+ public void checkAll() {
+ List supported = new ArrayList();
+ List unsupported = new ArrayList();
+ for (VersionListEntryJson version : versionList.getVersions()) {
+ if (checkOne(version)) {
+ supported.add(version);
+ } else {
+ unsupported.add(version);
+ }
+ }
+ displayVersionList(supported,
+ "================= SUPPORTED VERSIONS =================");
+ displayVersionList(unsupported,
+ "================ UNSUPPORTED VERSIONS ================");
+ }
+
+ private boolean checkOne(VersionListEntryJson version) {
+ if (version.tryDownloadClient(prefix)) {
+ try {
+ File jarFile = new File(version.getClientJar(prefix));
+ ClassTranslator translator = DefaultClassTranslator.INSTANCE
+ .get();
+ return isSupported(Classes.countMatches(jarFile, translator));
+ } catch (FileNotFoundException | JarFileParsingException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ private boolean isSupported(
+ Map matchesMap) {
+ for (Entry entry : matchesMap
+ .entrySet()) {
+ if (entry.getValue() > 1) {
+ return false;
+ } else if (entry.getValue() == 0 && !entry.getKey().isOptional()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void displayVersionList(List supported,
+ String message) {
+ System.out.println();
+ System.out.println(message);
+ for (VersionListEntryJson version : supported) {
+ System.out.println(version.getId());
+ }
+ }
+}
diff --git a/src/devtools/java/amidst/devtools/settings/DevToolsSettings.java b/src/devtools/java/amidst/devtools/settings/DevToolsSettings.java
new file mode 100644
index 000000000..1cddfd304
--- /dev/null
+++ b/src/devtools/java/amidst/devtools/settings/DevToolsSettings.java
@@ -0,0 +1,11 @@
+package amidst.devtools.settings;
+
+public enum DevToolsSettings {
+ INSTANCE;
+
+ private String minecraftVersionsDirectory = "/home/stefan/.minecraft/amidst-all-client-versions/";
+
+ public String getMinecraftVersionsDirectory() {
+ return minecraftVersionsDirectory;
+ }
+}
diff --git a/src/devtools/java/amidst/devtools/utils/VersionStateRenderer.java b/src/devtools/java/amidst/devtools/utils/VersionStateRenderer.java
new file mode 100644
index 000000000..ce48651de
--- /dev/null
+++ b/src/devtools/java/amidst/devtools/utils/VersionStateRenderer.java
@@ -0,0 +1,19 @@
+package amidst.devtools.utils;
+
+import amidst.mojangapi.file.json.versionlist.VersionListEntryJson;
+
+public class VersionStateRenderer {
+ public String render(VersionListEntryJson version, boolean hasServer,
+ boolean hasClient) {
+ return toBox(hasServer, 'S') + " " + toBox(hasClient, 'C') + " "
+ + version.getType().getTypeChar() + " " + version.getId();
+ }
+
+ private String toBox(boolean value, char c) {
+ if (value) {
+ return "[" + c + "]";
+ } else {
+ return "[ ]";
+ }
+ }
+}
diff --git a/src/main/java/amidst/Amidst.java b/src/main/java/amidst/Amidst.java
new file mode 100644
index 000000000..2c1fccc06
--- /dev/null
+++ b/src/main/java/amidst/Amidst.java
@@ -0,0 +1,126 @@
+package amidst;
+
+import java.io.File;
+
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+
+import amidst.documentation.AmidstThread;
+import amidst.documentation.CalledByAny;
+import amidst.documentation.CalledOnlyBy;
+import amidst.documentation.NotThreadSafe;
+import amidst.gui.crash.CrashWindow;
+import amidst.logging.FileLogger;
+import amidst.logging.Log;
+
+@NotThreadSafe
+public class Amidst {
+ private static final String UNCAUGHT_EXCEPTION_ERROR_MESSAGE = "Amidst has encounted an uncaught exception on thread: ";
+ private static final String COMMAND_LINE_PARSING_ERROR_MESSAGE = "There was an issue parsing command line parameters.";
+ private static final CommandLineParameters PARAMETERS = new CommandLineParameters();
+
+ @CalledOnlyBy(AmidstThread.STARTUP)
+ public static void main(String args[]) {
+ initUncaughtExceptionHandler();
+ parseCommandLineArguments(args);
+ initLogger();
+ initLookAndFeel();
+ setJava2DEnvironmentVariables();
+ startApplication();
+ }
+
+ private static void initUncaughtExceptionHandler() {
+ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(Thread thread, Throwable e) {
+ handleCrash(e, UNCAUGHT_EXCEPTION_ERROR_MESSAGE + thread);
+ }
+ });
+ }
+
+ private static void parseCommandLineArguments(String[] args) {
+ try {
+ new CmdLineParser(PARAMETERS).parseArgument(args);
+ } catch (CmdLineException e) {
+ Log.w(COMMAND_LINE_PARSING_ERROR_MESSAGE);
+ e.printStackTrace();
+ }
+ }
+
+ private static void initLogger() {
+ if (PARAMETERS.logPath != null) {
+ Log.addListener("file",
+ new FileLogger(new File(PARAMETERS.logPath)));
+ }
+ }
+
+ private static void initLookAndFeel() {
+ if (!isOSX()) {
+ try {
+ UIManager.setLookAndFeel(UIManager
+ .getSystemLookAndFeelClassName());
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e) {
+ Log.printTraceStack(e);
+ }
+ }
+ }
+
+ private static boolean isOSX() {
+ return System.getProperty("os.name").contains("OS X");
+ }
+
+ private static void setJava2DEnvironmentVariables() {
+ System.setProperty("sun.java2d.opengl", "True");
+ System.setProperty("sun.java2d.accthreshold", "0");
+ }
+
+ private static void startApplication() {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ doStartApplication();
+ }
+ });
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private static void doStartApplication() {
+ try {
+ new Application(PARAMETERS).run();
+ } catch (Exception e) {
+ handleCrash(e, "Amidst crashed!");
+ }
+ }
+
+ @CalledByAny
+ private static void handleCrash(Throwable e, String message) {
+ try {
+ Log.crash(e, message);
+ displayCrashWindow(message, Log.getAllMessages());
+ } catch (Throwable t) {
+ System.err.println("Amidst crashed!");
+ System.err.println(message);
+ e.printStackTrace();
+ }
+ }
+
+ private static void displayCrashWindow(final String message,
+ final String allMessages) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new CrashWindow(message, allMessages, new Runnable() {
+ @Override
+ public void run() {
+ System.exit(4);
+ }
+ });
+ }
+ });
+ }
+}
diff --git a/src/main/java/amidst/AmidstMetaData.java b/src/main/java/amidst/AmidstMetaData.java
new file mode 100644
index 000000000..9dda247df
--- /dev/null
+++ b/src/main/java/amidst/AmidstMetaData.java
@@ -0,0 +1,48 @@
+package amidst;
+
+import java.awt.image.BufferedImage;
+import java.util.Properties;
+
+import amidst.documentation.Immutable;
+
+@Immutable
+public class AmidstMetaData {
+ public static AmidstMetaData from(Properties properties, BufferedImage icon) {
+ // @formatter:off
+ return new AmidstMetaData(
+ icon,
+ Integer.parseInt(properties.getProperty("amidst.version.major")),
+ Integer.parseInt(properties.getProperty("amidst.version.minor")),
+ properties.getProperty("amidst.gui.mainWindow.title"));
+ // @formatter:on
+ }
+
+ private final BufferedImage icon;
+ private final int majorVersion;
+ private final int minorVersion;
+ private final String mainWindowTitle;
+
+ private AmidstMetaData(BufferedImage icon, int majorVersion,
+ int minorVersion, String mainWindowTitle) {
+ this.icon = icon;
+ this.majorVersion = majorVersion;
+ this.minorVersion = minorVersion;
+ this.mainWindowTitle = mainWindowTitle;
+ }
+
+ public BufferedImage getIcon() {
+ return icon;
+ }
+
+ public int getMajorVersion() {
+ return majorVersion;
+ }
+
+ public int getMinorVersion() {
+ return minorVersion;
+ }
+
+ public String getMainWindowTitle() {
+ return mainWindowTitle;
+ }
+}
diff --git a/src/main/java/amidst/Application.java b/src/main/java/amidst/Application.java
new file mode 100644
index 000000000..36b9b39e5
--- /dev/null
+++ b/src/main/java/amidst/Application.java
@@ -0,0 +1,146 @@
+package amidst;
+
+import java.io.FileNotFoundException;
+import java.util.prefs.Preferences;
+
+import amidst.documentation.AmidstThread;
+import amidst.documentation.CalledOnlyBy;
+import amidst.documentation.NotThreadSafe;
+import amidst.fragment.layer.LayerBuilder;
+import amidst.gui.license.LicenseWindow;
+import amidst.gui.main.MainWindow;
+import amidst.gui.main.worldsurroundings.WorldSurroundingsBuilder;
+import amidst.gui.profileselect.ProfileSelectWindow;
+import amidst.mojangapi.MojangApi;
+import amidst.mojangapi.MojangApiBuilder;
+import amidst.mojangapi.minecraftinterface.local.LocalMinecraftInterfaceCreationException;
+import amidst.mojangapi.world.SeedHistoryLogger;
+import amidst.mojangapi.world.WorldBuilder;
+import amidst.mojangapi.world.player.PlayerInformationCache;
+import amidst.threading.ThreadMaster;
+
+@NotThreadSafe
+public class Application {
+ private final CommandLineParameters parameters;
+ private final AmidstMetaData metadata;
+ private final Settings settings;
+ private final MojangApi mojangApi;
+ private final WorldSurroundingsBuilder worldSurroundingsBuilder;
+ private final ThreadMaster threadMaster;
+
+ private volatile ProfileSelectWindow profileSelectWindow;
+ private volatile MainWindow mainWindow;
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public Application(CommandLineParameters parameters)
+ throws FileNotFoundException,
+ LocalMinecraftInterfaceCreationException {
+ this.parameters = parameters;
+ this.metadata = createMetadata();
+ this.settings = createSettings();
+ this.mojangApi = createMojangApi();
+ this.worldSurroundingsBuilder = createWorldSurroundingsBuilder();
+ this.threadMaster = createThreadMaster();
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private AmidstMetaData createMetadata() {
+ return AmidstMetaData.from(
+ ResourceLoader.getProperties("/amidst/metadata.properties"),
+ ResourceLoader.getImage("/amidst/icon.png"));
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private Settings createSettings() {
+ return new Settings(Preferences.userNodeForPackage(Amidst.class));
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private MojangApi createMojangApi() throws FileNotFoundException,
+ LocalMinecraftInterfaceCreationException {
+ return new MojangApiBuilder(new WorldBuilder(
+ new PlayerInformationCache(), new SeedHistoryLogger(
+ parameters.historyPath)), parameters.minecraftPath,
+ parameters.minecraftLibraries, parameters.minecraftJar,
+ parameters.minecraftJson).construct();
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private WorldSurroundingsBuilder createWorldSurroundingsBuilder() {
+ return new WorldSurroundingsBuilder(settings,
+ new LayerBuilder(settings));
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private ThreadMaster createThreadMaster() {
+ return new ThreadMaster();
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void run() {
+ if (mojangApi.canCreateWorld()) {
+ displayMainWindow();
+ } else {
+ displayProfileSelectWindow();
+ }
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void displayMainWindow() {
+ setMainWindow(new MainWindow(this, metadata, settings, mojangApi,
+ worldSurroundingsBuilder, threadMaster));
+ setProfileSelectWindow(null);
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void displayProfileSelectWindow() {
+ setProfileSelectWindow(new ProfileSelectWindow(this, metadata,
+ threadMaster.getWorkerExecutor(), mojangApi, settings));
+ setMainWindow(null);
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private void setProfileSelectWindow(ProfileSelectWindow profileSelectWindow) {
+ disposeProfileSelectWindow();
+ this.profileSelectWindow = profileSelectWindow;
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private void setMainWindow(MainWindow mainWindow) {
+ disposeMainWindow();
+ this.mainWindow = mainWindow;
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private void disposeProfileSelectWindow() {
+ ProfileSelectWindow profileSelectWindow = this.profileSelectWindow;
+ if (profileSelectWindow != null) {
+ profileSelectWindow.dispose();
+ }
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ private void disposeMainWindow() {
+ MainWindow mainWindow = this.mainWindow;
+ if (mainWindow != null) {
+ mainWindow.dispose();
+ }
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void displayLicenseWindow() {
+ new LicenseWindow(metadata);
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void exitGracefully() {
+ dispose();
+ System.exit(0);
+ }
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public void dispose() {
+ setProfileSelectWindow(null);
+ setMainWindow(null);
+ }
+}
diff --git a/src/main/java/amidst/CommandLineParameters.java b/src/main/java/amidst/CommandLineParameters.java
new file mode 100644
index 000000000..0f0baf5a2
--- /dev/null
+++ b/src/main/java/amidst/CommandLineParameters.java
@@ -0,0 +1,30 @@
+package amidst;
+
+import org.kohsuke.args4j.Option;
+
+import amidst.documentation.ThreadSafe;
+
+/**
+ * An instance of this class will be created to hold the command line
+ * parameters. Afterwards, the assigned values should not be modified.
+ */
+@ThreadSafe
+public class CommandLineParameters {
+ @Option(name = "-history", usage = "Sets the path to seed history file.", metaVar = "")
+ public volatile String historyPath;
+
+ @Option(name = "-log", usage = "Sets the path to logging file.", metaVar = "")
+ public volatile String logPath;
+
+ @Option(name = "-mcpath", usage = "Sets the path to the .minecraft directory.", metaVar = "")
+ public volatile String minecraftPath;
+
+ @Option(name = "-mcjar", usage = "Sets the path to the minecraft .jar", metaVar = "")
+ public volatile String minecraftJar;
+
+ @Option(name = "-mcjson", usage = "Sets the path to the minecraft .json", metaVar = "")
+ public volatile String minecraftJson;
+
+ @Option(name = "-mclibs", usage = "Sets the path to the libraries/ folder", metaVar = "")
+ public volatile String minecraftLibraries;
+}
diff --git a/src/main/java/amidst/ResourceLoader.java b/src/main/java/amidst/ResourceLoader.java
new file mode 100644
index 000000000..f72960444
--- /dev/null
+++ b/src/main/java/amidst/ResourceLoader.java
@@ -0,0 +1,62 @@
+package amidst;
+
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
+import javax.imageio.ImageIO;
+
+import amidst.documentation.Immutable;
+
+@Immutable
+public enum ResourceLoader {
+ ;
+
+ public static URL getResourceURL(String name) {
+ return ResourceLoader.class.getResource(name);
+ }
+
+ public static BufferedImage getImage(String name) {
+ try {
+ return ImageIO.read(getResourceURL(name));
+ } catch (IOException e) {
+ // This is always a developer error, because a resource was not
+ // included in the jar file.
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static Properties getProperties(String name) {
+ Properties properties = new Properties();
+ try {
+ properties.load(getResourceAsStream(name));
+ } catch (IOException e) {
+ // This is always a developer error, because a resource was not
+ // included in the jar file.
+ throw new IllegalArgumentException(e);
+ }
+ return properties;
+ }
+
+ public static String getResourceAsString(String name) throws IOException {
+ InputStreamReader reader = new InputStreamReader(
+ getResourceAsStream(name), StandardCharsets.UTF_8);
+ char[] buffer = new char[1024];
+ int length;
+ StringBuilder result = new StringBuilder();
+ while ((length = reader.read(buffer)) != -1) {
+ result.append(buffer, 0, length);
+ }
+ return result.toString();
+ }
+
+ private static InputStream getResourceAsStream(String filename) {
+ return new BufferedInputStream(
+ ResourceLoader.class.getResourceAsStream(filename));
+ }
+}
diff --git a/src/main/java/amidst/Settings.java b/src/main/java/amidst/Settings.java
new file mode 100644
index 000000000..d7ab070f7
--- /dev/null
+++ b/src/main/java/amidst/Settings.java
@@ -0,0 +1,62 @@
+package amidst;
+
+import java.util.prefs.Preferences;
+
+import amidst.documentation.AmidstThread;
+import amidst.documentation.CalledOnlyBy;
+import amidst.documentation.ThreadSafe;
+import amidst.mojangapi.world.WorldType;
+import amidst.settings.BooleanSetting;
+import amidst.settings.MultipleStringsSetting;
+import amidst.settings.Setting;
+import amidst.settings.StringSetting;
+import amidst.settings.biomecolorprofile.BiomeColorProfile;
+import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
+
+@ThreadSafe
+public class Settings {
+ public final BooleanSetting showSlimeChunks;
+ public final BooleanSetting showGrid;
+ public final BooleanSetting showNetherFortresses;
+ public final BooleanSetting showTemples;
+ public final BooleanSetting showPlayers;
+ public final BooleanSetting showStrongholds;
+ public final BooleanSetting showVillages;
+ public final BooleanSetting showOceanMonuments;
+ public final BooleanSetting showSpawn;
+ public final BooleanSetting smoothScrolling;
+ public final BooleanSetting fragmentFading;
+ public final BooleanSetting showFPS;
+ public final BooleanSetting showScale;
+ public final BooleanSetting showDebug;
+ public final BooleanSetting updateToUnstable;
+ public final BooleanSetting maxZoom;
+ public final Setting lastProfile;
+ public final MultipleStringsSetting worldType;
+ public final BiomeColorProfileSelection biomeColorProfileSelection;
+
+ @CalledOnlyBy(AmidstThread.EDT)
+ public Settings(Preferences preferences) {
+ // @formatter:off
+ showSlimeChunks = new BooleanSetting( preferences, "slimeChunks", false);
+ showGrid = new BooleanSetting( preferences, "grid", false);
+ showNetherFortresses = new BooleanSetting( preferences, "netherFortressIcons", false);
+ smoothScrolling = new BooleanSetting( preferences, "mapFlicking", true);
+ fragmentFading = new BooleanSetting( preferences, "mapFading", true);
+ maxZoom = new BooleanSetting( preferences, "maxZoom", true);
+ showStrongholds = new BooleanSetting( preferences, "strongholdIcons", true);
+ showPlayers = new BooleanSetting( preferences, "playerIcons", true);
+ showTemples = new BooleanSetting( preferences, "templeIcons", true);
+ showVillages = new BooleanSetting( preferences, "villageIcons", true);
+ showOceanMonuments = new BooleanSetting( preferences, "oceanMonumentIcons", true);
+ showSpawn = new BooleanSetting( preferences, "spawnIcon", true);
+ showFPS = new BooleanSetting( preferences, "showFPS", true);
+ showScale = new BooleanSetting( preferences, "showScale", true);
+ showDebug = new BooleanSetting( preferences, "showDebug", false);
+ updateToUnstable = new BooleanSetting( preferences, "updateToUnstable", false);
+ lastProfile = new StringSetting( preferences, "profile", null);
+ worldType = new MultipleStringsSetting(preferences, "worldType", WorldType.PROMPT_EACH_TIME, WorldType.getWorldTypeSettingAvailableValues());
+ biomeColorProfileSelection = new BiomeColorProfileSelection(BiomeColorProfile.getDefaultProfile());
+ // @formatter:on
+ }
+}
diff --git a/src/main/java/amidst/clazz/Classes.java b/src/main/java/amidst/clazz/Classes.java
new file mode 100644
index 000000000..dfeea9d9b
--- /dev/null
+++ b/src/main/java/amidst/clazz/Classes.java
@@ -0,0 +1,70 @@
+package amidst.clazz;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import amidst.clazz.real.JarFileParsingException;
+import amidst.clazz.real.RealClass;
+import amidst.clazz.real.RealClasses;
+import amidst.clazz.symbolic.SymbolicClass;
+import amidst.clazz.symbolic.SymbolicClassGraphCreationException;
+import amidst.clazz.symbolic.SymbolicClasses;
+import amidst.clazz.symbolic.declaration.SymbolicClassDeclaration;
+import amidst.clazz.translator.ClassTranslator;
+import amidst.documentation.Immutable;
+import amidst.logging.Log;
+
+@Immutable
+public enum Classes {
+ ;
+
+ public static Map createSymbolicClassMap(
+ File jarFile, URLClassLoader classLoader, ClassTranslator translator)
+ throws FileNotFoundException, JarFileParsingException,
+ SymbolicClassGraphCreationException, ClassNotFoundException {
+ Log.i("Reading " + jarFile.getName());
+ List realClasses = RealClasses.fromJarFile(jarFile);
+ Log.i("Jar load complete.");
+ Log.i("Searching for classes...");
+ Map realClassNamesBySymbolicClassDeclaration = translator
+ .translate(realClasses);
+ Log.i("Class search complete.");
+ Log.i("Loading classes...");
+ Map result = SymbolicClasses.from(
+ realClassNamesBySymbolicClassDeclaration, classLoader);
+ Log.i("Classes loaded.");
+ return result;
+ }
+
+ public static Map countMatches(
+ File jarFile, ClassTranslator translator)
+ throws FileNotFoundException, JarFileParsingException {
+ Log.i("Checking " + jarFile.getName());
+ List realClasses = RealClasses.fromJarFile(jarFile);
+ Map> map = translator
+ .translateToAllMatching(realClasses);
+ Map result = new HashMap();
+ for (Entry> entry : map
+ .entrySet()) {
+ result.put(entry.getKey(), entry.getValue().size());
+ if (entry.getValue().isEmpty()) {
+ Log.w(entry.getKey().getSymbolicClassName()
+ + " has no matching class");
+ } else if (entry.getValue().size() > 1) {
+ StringBuilder builder = new StringBuilder();
+ for (RealClass realClass : entry.getValue()) {
+ builder.append(", ").append(realClass.getRealClassName());
+ }
+ Log.w(entry.getKey().getSymbolicClassName()
+ + " has multiple matching classes: "
+ + builder.toString().substring(2));
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/amidst/clazz/real/AccessFlags.java b/src/main/java/amidst/clazz/real/AccessFlags.java
new file mode 100644
index 000000000..55fc70011
--- /dev/null
+++ b/src/main/java/amidst/clazz/real/AccessFlags.java
@@ -0,0 +1,31 @@
+package amidst.clazz.real;
+
+import amidst.documentation.Immutable;
+
+/*-
+ * ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its package.
+ * ACC_PRIVATE 0x0002 Declared private; usable only within the defining class.
+ * ACC_PROTECTED 0x0004 Declared protected; may be accessed within subclasses.
+ * ACC_STATIC 0x0008 Declared static.
+ * ACC_FINAL 0x0010 Declared final; no further assignment after initialization.
+ * ACC_VOLATILE 0x0040 Declared volatile; cannot be cached.
+ * ACC_TRANSIENT 0x0080 Declared transient; not written or read by a persistent object manager.
+ * ACC_INTERFACE 0x0200 Is an interface, not a class.
+ **/
+@Immutable
+public enum AccessFlags {
+ ;
+
+ public static final int PUBLIC = 0x01;
+ public static final int PRIVATE = 0x02;
+ public static final int PROTECTED = 0x04;
+ public static final int STATIC = 0x08;
+ public static final int FINAL = 0x10;
+ public static final int VOLATILE = 0x40;
+ public static final int TRANSIENT = 0x80;
+ public static final int INTERFACE = 0x0200;
+
+ public static boolean hasFlags(int accessFlags, int flags) {
+ return (accessFlags & flags) == flags;
+ }
+}
diff --git a/src/main/java/amidst/clazz/real/JarFileParsingException.java b/src/main/java/amidst/clazz/real/JarFileParsingException.java
new file mode 100644
index 000000000..d306199e4
--- /dev/null
+++ b/src/main/java/amidst/clazz/real/JarFileParsingException.java
@@ -0,0 +1,11 @@
+package amidst.clazz.real;
+
+import amidst.documentation.Immutable;
+
+@SuppressWarnings("serial")
+@Immutable
+public class JarFileParsingException extends Exception {
+ public JarFileParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/amidst/clazz/real/RealClass.java b/src/main/java/amidst/clazz/real/RealClass.java
new file mode 100644
index 000000000..0eacc5ad8
--- /dev/null
+++ b/src/main/java/amidst/clazz/real/RealClass.java
@@ -0,0 +1,261 @@
+package amidst.clazz.real;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import amidst.documentation.Immutable;
+
+@Immutable
+public class RealClass {
+ private static Map createPrimitiveTypeConversionMap() {
+ Map result = new HashMap();
+ result.put('B', "byte");
+ result.put('C', "char");
+ result.put('D', "double");
+ result.put('F', "float");
+ result.put('I', "int");
+ result.put('J', "long");
+ result.put('S', "short");
+ result.put('Z', "boolean");
+ return Collections.unmodifiableMap(result);
+ }
+
+ private static final Map PRIMITIV_TYPE_CONVERSION_MAP = createPrimitiveTypeConversionMap();
+ private static final Pattern ARG_PATTERN = Pattern
+ .compile("([\\[]+)?([BCDFIJSZ]|L[^;]+)");
+ private static final Pattern OBJECT_PATTERN = Pattern
+ .compile("^([\\[]+)?[LBCDFIJSZ]");
+ public static final int CLASS_DATA_WILDCARD = -1;
+
+ private final String realClassName;
+ private final byte[] classData;
+
+ private final int minorVersion;
+ private final int majorVersion;
+
+ private final int cpSize;
+ @SuppressWarnings("unused")
+ private final int[] constantTypes;
+ private final RealClassConstant>[] constants;
+
+ private final List utf8Constants;
+ private final List floatConstants;
+ private final List longConstants;
+ private final List stringIndices;
+ private final List methodIndices;
+
+ private final int accessFlags;
+ private final RealClassField[] fields;
+
+ private final int numberOfConstructors;
+ private final int numberOfMethods;
+
+ RealClass(String realClassName, byte[] classData, int minorVersion,
+ int majorVersion, int cpSize, int[] constantTypes,
+ RealClassConstant>[] constants, List utf8Constants,
+ List floatConstants, List longConstants,
+ List stringIndices, List methodIndices,
+ int accessFlags, RealClassField[] fields, int numberOfConstructors,
+ int numberOfMethods) {
+ this.realClassName = realClassName;
+ this.classData = classData;
+ this.minorVersion = minorVersion;
+ this.majorVersion = majorVersion;
+ this.cpSize = cpSize;
+ this.constantTypes = constantTypes;
+ this.constants = constants;
+ this.utf8Constants = utf8Constants;
+ this.floatConstants = floatConstants;
+ this.longConstants = longConstants;
+ this.stringIndices = stringIndices;
+ this.methodIndices = methodIndices;
+ this.accessFlags = accessFlags;
+ this.fields = fields;
+ this.numberOfConstructors = numberOfConstructors;
+ this.numberOfMethods = numberOfMethods;
+ }
+
+ public String getRealClassName() {
+ return realClassName;
+ }
+
+ public boolean isClassDataWildcardMatching(int[] bytes) {
+ int loopLimit = classData.length + 1 - bytes.length;
+ for (int startIndex = 0; startIndex < loopLimit; startIndex++) {
+ if (isClassDataWildcardMatchingAt(startIndex, bytes)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isClassDataWildcardMatchingAt(int startIndex, int[] bytes) {
+ for (int offset = 0; offset < bytes.length; offset++) {
+ if (bytes[offset] != CLASS_DATA_WILDCARD
+ && classData[startIndex + offset] != (byte) bytes[offset]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public int getMinorVersion() {
+ return minorVersion;
+ }
+
+ public int getMajorVersion() {
+ return majorVersion;
+ }
+
+ public int getCpSize() {
+ return cpSize;
+ }
+
+ public boolean searchForUtf8EqualTo(String required) {
+ for (String entry : utf8Constants) {
+ if (entry.equals(required)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean searchForFloat(float required) {
+ for (Float entry : floatConstants) {
+ if (entry.floatValue() == required) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean searchForLong(long required) {
+ for (Long entry : longConstants) {
+ if (entry.longValue() == required) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean searchForStringContaining(String requiredValue) {
+ for (Integer entry : stringIndices) {
+ String entryValue = getStringValueOfConstant(entry);
+ if (entryValue.contains(requiredValue)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String searchByReturnType(String required) {
+ String requiredType = "L" + required + ";";
+ for (ReferenceIndex entry : methodIndices) {
+ String value = getStringValueOfConstant(entry.getValue2());
+ String entryType = value.substring(value.indexOf(')') + 1);
+ if (entryType.equals(requiredType)) {
+ return getStringValueOfConstant(entry.getValue1());
+ }
+ }
+ return null;
+ }
+
+ public RealClassField getField(int index) {
+ return fields[index];
+ }
+
+ public int getAccessFlags() {
+ return accessFlags;
+ }
+
+ public int getNumberOfConstructors() {
+ return numberOfConstructors;
+ }
+
+ public int getNumberOfMethods() {
+ return numberOfMethods;
+ }
+
+ public int getNumberOfFields() {
+ return fields.length;
+ }
+
+ public boolean isInterface() {
+ return AccessFlags.hasFlags(accessFlags, AccessFlags.INTERFACE);
+ }
+
+ public boolean isFinal() {
+ return AccessFlags.hasFlags(accessFlags, AccessFlags.FINAL);
+ }
+
+ public String getArgumentsForConstructor(int constructorId) {
+ int i = 0;
+ for (ReferenceIndex entry : methodIndices) {
+ if (getStringValueOfConstant(entry.getValue1()).equals("")) {
+ if (i == constructorId) {
+ String arguments = getStringValueOfConstant(entry
+ .getValue2());
+ return toArgumentString(readArguments(arguments));
+ }
+ i++;
+ }
+ }
+ return "";
+ }
+
+ private String getStringValueOfConstant(int value) {
+ return (String) constants[value - 1].getValue();
+ }
+
+ private String[] readArguments(String arguments) {
+ List result = new ArrayList();
+ String args = arguments.substring(1).split("\\)")[0];
+ Matcher matcher = ARG_PATTERN.matcher(args);
+ while (matcher.find()) {
+ String arg = args.substring(matcher.start(), matcher.end());
+ Matcher objectMatcher = OBJECT_PATTERN.matcher(arg);
+ if (objectMatcher.find()) {
+ arg = getObjectArg(arg, objectMatcher.end());
+ }
+ result.add(arg);
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ private String getObjectArg(String arg, int matcherEnd) {
+ return arg.substring(0, Math.max(0, matcherEnd - 1))
+ + getPrimitiveType(arg.charAt(matcherEnd - 1))
+ + arg.substring(Math.min(matcherEnd, arg.length()));
+ }
+
+ private String getPrimitiveType(char typeChar) {
+ if (PRIMITIV_TYPE_CONVERSION_MAP.containsKey(typeChar)) {
+ return PRIMITIV_TYPE_CONVERSION_MAP.get(typeChar);
+ } else {
+ return "";
+ }
+ }
+
+ private String toArgumentString(String[] arguments) {
+ StringBuilder result = new StringBuilder();
+ result.append("(");
+ if (arguments.length > 0) {
+ result.append(arguments[0]);
+ for (int i = 1; i < arguments.length; i++) {
+ result.append(",").append(arguments[i]);
+ }
+ }
+ result.append(")");
+ return result.toString();
+ }
+
+ @Override
+ public String toString() {
+ return "[RealClass " + realClassName + "]";
+ }
+}
diff --git a/src/main/java/amidst/clazz/real/RealClassBuilder.java b/src/main/java/amidst/clazz/real/RealClassBuilder.java
new file mode 100644
index 000000000..b9a03b09b
--- /dev/null
+++ b/src/main/java/amidst/clazz/real/RealClassBuilder.java
@@ -0,0 +1,254 @@
+package amidst.clazz.real;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import amidst.clazz.real.RealClassConstant.RealClassConstantType;
+import amidst.documentation.Immutable;
+
+@Immutable
+public class RealClassBuilder {
+ public RealClass construct(String realClassName, byte[] classData)
+ throws RealClassCreationException {
+ try (DataInputStream stream = new DataInputStream(
+ new ByteArrayInputStream(classData))) {
+ return doConstruct(realClassName, classData, stream);
+ } catch (IOException e) {
+ throw new RealClassCreationException(
+ "unable to create real class for the class: "
+ + realClassName, e);
+ }
+ }
+
+ private RealClass doConstruct(String realClassName, byte[] classData,
+ DataInputStream stream) throws IOException {
+ if (isValidClass(stream)) {
+ int minorVersion = readMinorVersion(stream);
+ int majorVersion = readMajorVersion(stream);
+ int cpSize = readCpSize(stream);
+ int[] constantTypes = new int[cpSize];
+ RealClassConstant>[] constants = new RealClassConstant>[cpSize];
+ List utf8Constants = new ArrayList();
+ List floatConstants = new ArrayList();
+ List longConstants = new ArrayList();
+ List stringIndices = new ArrayList();
+ List methodIndices = new ArrayList();
+ readConstants(stream, cpSize, constantTypes, constants,
+ utf8Constants, floatConstants, longConstants, stringIndices);
+ int accessFlags = readAccessFlags(stream);
+ skipThisClass(stream);
+ skipSuperClass(stream);
+ skipInterfaces(stream);
+ RealClassField[] fields = readFields(stream);
+ int numberOfMethodsAndConstructors = readNumberOfMethodsAndConstructors(stream);
+ int numberOfConstructors = readMethodsAndConstructors(stream,
+ numberOfMethodsAndConstructors, constants, methodIndices);
+ int numberOfMethods = numberOfMethodsAndConstructors
+ - numberOfConstructors;
+ return new RealClass(realClassName, classData, minorVersion,
+ majorVersion, cpSize, constantTypes, constants,
+ utf8Constants, floatConstants, longConstants,
+ stringIndices, methodIndices, accessFlags, fields,
+ numberOfConstructors, numberOfMethods);
+ } else {
+ return null;
+ }
+ }
+
+ private boolean isValidClass(DataInputStream stream) throws IOException {
+ return stream.readInt() == 0xCAFEBABE;
+ }
+
+ private int readMinorVersion(DataInputStream stream) throws IOException {
+ return stream.readUnsignedShort();
+ }
+
+ private int readMajorVersion(DataInputStream stream) throws IOException {
+ return stream.readUnsignedShort();
+ }
+
+ private int readCpSize(DataInputStream stream) throws IOException {
+ return stream.readUnsignedShort() - 1;
+ }
+
+ private void readConstants(DataInputStream stream, int cpSize,
+ int[] constantTypes, RealClassConstant>[] constants,
+ List utf8Constants, List floatConstants,
+ List longConstants, List stringIndices)
+ throws IOException {
+ for (int q = 0; q < cpSize; q++) {
+ byte type = stream.readByte();
+ constantTypes[q] = type;
+ constants[q] = readConstant(stream, type, utf8Constants,
+ floatConstants, longConstants, stringIndices);
+ if (RealClassConstantType.isQIncreasing(type)) {
+ q++;
+ }
+ }
+ }
+
+ private RealClassConstant> readConstant(DataInputStream stream,
+ byte type, List utf8Constants, List floatConstants,
+ List longConstants, List stringIndices)
+ throws IOException {
+ switch (type) {
+ case RealClassConstantType.STRING:
+ return readString(stream, type, utf8Constants);
+ case RealClassConstantType.INTEGER:
+ return readInteger(stream, type);
+ case RealClassConstantType.FLOAT:
+ return readFloat(stream, type, floatConstants);
+ case RealClassConstantType.LONG:
+ return readLong(stream, type, longConstants);
+ case RealClassConstantType.DOUBLE:
+ return readDouble(stream, type);
+ case RealClassConstantType.CLASS_REFERENCE:
+ return readClassReference(stream, type);
+ case RealClassConstantType.STRING_REFERENCE:
+ return readStringReference(stream, type, stringIndices);
+ case RealClassConstantType.FIELD_REFERENCE:
+ return readAnotherReference(stream, type);
+ case RealClassConstantType.METHOD_REFERENCE:
+ return readAnotherReference(stream, type);
+ case RealClassConstantType.INTERFACE_METHOD_REFERENCE:
+ return readAnotherReference(stream, type);
+ case RealClassConstantType.NAME_AND_TYPE_DESCRIPTOR:
+ return readAnotherReference(stream, type);
+ default:
+ return null;
+ }
+ }
+
+ private RealClassConstant readString(DataInputStream stream,
+ byte type, List utf8Constants) throws IOException {
+ String value = readStringValue(stream);
+ utf8Constants.add(value);
+ return new RealClassConstant(type, value);
+ }
+
+ private String readStringValue(DataInputStream stream) throws IOException {
+ char[] result = new char[stream.readUnsignedShort()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = (char) stream.readByte();
+ }
+ return new String(result);
+ }
+
+ private RealClassConstant readInteger(DataInputStream stream,
+ byte type) throws IOException {
+ int value = stream.readInt();
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readFloat(DataInputStream stream,
+ byte type, List floatConstants) throws IOException {
+ float value = stream.readFloat();
+ floatConstants.add(value);
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readLong(DataInputStream stream, byte type,
+ List longConstants) throws IOException {
+ long value = stream.readLong();
+ longConstants.add(value);
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readDouble(DataInputStream stream,
+ byte type) throws IOException {
+ double value = stream.readDouble();
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readClassReference(
+ DataInputStream stream, byte type) throws IOException {
+ int value = stream.readUnsignedShort();
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readStringReference(
+ DataInputStream stream, byte type, List stringIndices)
+ throws IOException {
+ int value = stream.readUnsignedShort();
+ stringIndices.add(value);
+ return new RealClassConstant(type, value);
+ }
+
+ private RealClassConstant readAnotherReference(
+ DataInputStream stream, byte type) throws IOException {
+ ReferenceIndex value = readReferenceIndex(stream);
+ return new RealClassConstant(type, value);
+ }
+
+ private int readAccessFlags(DataInputStream stream) throws IOException {
+ return stream.readUnsignedShort();
+ }
+
+ private void skipThisClass(DataInputStream stream) throws IOException {
+ stream.skip(2);
+ }
+
+ private void skipSuperClass(DataInputStream stream) throws IOException {
+ stream.skip(2);
+ }
+
+ private void skipInterfaces(DataInputStream stream) throws IOException {
+ stream.skip(2 * stream.readUnsignedShort());
+ }
+
+ private RealClassField[] readFields(DataInputStream stream)
+ throws IOException {
+ RealClassField[] fields = new RealClassField[stream.readUnsignedShort()];
+ for (int i = 0; i < fields.length; i++) {
+ fields[i] = new RealClassField(stream.readUnsignedShort());
+ stream.skip(4);
+ skipAttributes(stream);
+ }
+ return fields;
+ }
+
+ private int readNumberOfMethodsAndConstructors(DataInputStream stream)
+ throws IOException {
+ return stream.readUnsignedShort();
+ }
+
+ private int readMethodsAndConstructors(DataInputStream stream,
+ int numberOfMethodsAndConstructors,
+ RealClassConstant>[] constants, List methodIndices)
+ throws IOException {
+ int numberOfConstructors = 0;
+ for (int i = 0; i < numberOfMethodsAndConstructors; i++) {
+ stream.skip(2);
+ ReferenceIndex referenceIndex = readReferenceIndex(stream);
+ methodIndices.add(referenceIndex);
+ String constant = (String) constants[referenceIndex.getValue1() - 1]
+ .getValue();
+ if (constant.contains("