Revision: 39900
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 22, 2011 08:36 by jkerr88
Initial Code
import java.io.FileInputStream; /** * * @author jkerr88 * * You need the code from here: * * http://www.minecraftwiki.net/wiki/NBT_class * * saved as Tag.java in the same folder as this one. This file should be saved as ReportPlayerLocation.java * */ public class ReportPlayerLocation implements Runnable{ static ReportPlayerLocation iThis; static String isCurrentFile; public static void main(String argv[]){ iThis = new ReportPlayerLocation(); Thread t = new Thread(iThis); t.start(); } // main public void run() { String sWorldFolder = "C:\\Documents and Settings\\Jeff\\Application Data\\.minecraft\\saves\\World1"; try{ Tag datFileTag = Tag.readFrom(new FileInputStream(sWorldFolder + "\\level.dat")); reportPlayerPositionFromTag(datFileTag); }catch(Exception e){ System.out.println(e); return; } System.out.println("\nDone!"); } private void reportPlayerPositionFromTag(Tag p_tag){ Tag.Type type = p_tag.getType(); if (type == Tag.Type.TAG_End) return; String sName = p_tag.getName(); if (type == Tag.Type.TAG_Byte_Array) { } else if (type == Tag.Type.TAG_List) { Tag[] subtags = (Tag[]) p_tag.getValue(); for (Tag st : subtags) { reportPlayerPositionFromTag(st); } if(sName.equals("Pos")){ System.out.println("Found Player Pos: (X is NS, Y is Altitude, Z is EW"); Double nX = (Double) subtags[0].getValue(); Double nY = (Double) subtags[1].getValue(); Double nZ = (Double) subtags[2].getValue(); System.out.println("X: " + Math.round(nX.doubleValue())); System.out.println("Y: " + Math.round(nY.doubleValue())); System.out.println("Z: " + Math.round(nZ.doubleValue())); System.out.println("\nChunk: (x/16, z/16)"); System.out.println("xPos: " + Math.floor(nX.doubleValue()/16)); System.out.println("zPos: " + Math.floor(nZ.doubleValue()/16)); } } else if (type == Tag.Type.TAG_Compound) { Tag[] subtags = (Tag[]) p_tag.getValue(); for (Tag st : subtags) { reportPlayerPositionFromTag(st); } } else { } } }
Initial URL
Initial Description
Initial Title
Find and report player position in Minecraft save file
Initial Tags
Initial Language
Java