Skip to content

Commit 3620f69

Browse files
authored
Merge pull request #2 from KpoxaPy/master
Fix nether export bug & add dimId to wp filename
2 parents 5ec35e4 + 411ebd1 commit 3620f69

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/org/prank/MainFrame.java

+20-6
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,37 @@ private void export() {
139139

140140
private void writeWayPoint(Coord coord, String name) {
141141
String upName = name.substring(0, 1).toUpperCase() + name.substring(1, name.length());
142-
String fn = upName + "_" + coord.x + "," + coord.y + "," + coord.z;
142+
String wpName = upName + "_" + coord.x + "," + coord.y + "," + coord.z;
143+
String fileName = "waypoints/" + wpName + "." + getCurrentDimID() + ".json";
144+
145+
// Translate chunk coords to block coords
146+
int x = coord.x * 16 + 8;
147+
int y = coord.y;
148+
int z = coord.z * 16 + 8;
149+
150+
// Stretch coords if nether dimension due to JourneyMap squeezing
151+
if (getCurrentDimID() == -1)
152+
{
153+
x *= 8;
154+
z *= 8;
155+
}
156+
143157
int hash = name.hashCode();
144158
StringBuilder sb = new StringBuilder("{")
145-
.append("\"id\": \"").append(fn).append("\", ")
159+
.append("\"id\": \"").append(wpName).append("\", ")
146160
.append("\"name\": \"").append(upName).append("\", ")
147161
.append("\"icon\": \"waypoint-normal.png\", ")
148-
.append("\"x\": ").append(coord.x * 16 + 8).append(", ")
149-
.append("\"y\": ").append(coord.y).append(", ")
150-
.append("\"z\": ").append(coord.z * 16 + 8).append(", ")
162+
.append("\"x\": ").append(x).append(", ")
163+
.append("\"y\": ").append(y).append(", ")
164+
.append("\"z\": ").append(z).append(", ")
151165
.append("\"r\": ").append((hash) & 0xff).append(", ")
152166
.append("\"g\": ").append((hash >> 8) & 0xff).append(", ")
153167
.append("\"b\": ").append((hash >> 16) & 0xff).append(", ")
154168
.append("\"enable\": true, ")
155169
.append("\"type\": \"Normal\", ")
156170
.append("\"origin\": \"JourneyMap\", ")
157171
.append("\"dimensions\": [").append(getCurrentDimID()).append("]}");
158-
try (FileWriter file = new FileWriter("waypoints/" + fn + ".json")) {
172+
try (FileWriter file = new FileWriter(fileName)) {
159173
file.write(sb.toString());
160174
file.flush();
161175
} catch (Exception e) {

0 commit comments

Comments
 (0)