/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.io.FileInputStream; import java.io.FileOutputStream; /** * * @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 * */ static ExtinguishFiresInChunk iThis; iThis = new ExtinguishFiresInChunk(); t.start(); } // main public void run() { String sWorldFolder = "C:\\Documents and Settings\\Jeff\\Application Data\\.minecraft\\saves\\World1"; int xPos = 4; int zPos = -6; //System.out.println(sInputFile); try{ Tag datFileTag = Tag.readFrom(fis); fis.close(); editBlocksInTag(datFileTag); datFileTag.writeTo(fos); fos.close(); return; } } //get mod 64 of x and z int nModX; int nModZ; if(p_xPos<0){ nModX = (p_xPos + 64) % 64; }else{ nModX = p_xPos % 64; } if(p_zPos<0){ nModZ = (p_zPos + 64) % 64; }else{ nModZ = p_zPos % 64; } if(!sReturn.endsWith("\\")){ sReturn += "\\"; } sReturn += getBase36(nModX) + "\\" + getBase36(nModZ) + "\\c." + getBase36(p_xPos) + "." + getBase36(p_zPos) + ".dat"; return sReturn; } boolean bNegative = false; if(decimalNumber<0){ bNegative = true; decimalNumber = decimalNumber*-1; } int mod = 0; while( decimalNumber != 0 ) { mod = decimalNumber % 36; tempVal = baseDigits.substring( mod, mod + 1 ) + tempVal; decimalNumber = decimalNumber / 36; } if(bNegative){ tempVal = "-" + tempVal; } return tempVal; } private byte[] editBlocksInTag(Tag p_tag){ Tag.Type type = p_tag.getType(); if (type == Tag.Type.TAG_End) return null; if (type == Tag.Type.TAG_Byte_Array) { if(sName.equals("Blocks")){ byte[] b = (byte[]) o; //b is a byte array of the blocks in this chunk - Changes can be made and the passed Tag is written back out by the caller //Extinguish any fires in the chunk (id 51) by replacing with air (id 0) int nCount =0; for(int n=0;n<b.length;n++){ if(b[n]==51){//fire b[n] = 0; //air nCount++; } } return b; } } else if (type == Tag.Type.TAG_List) { Tag[] subtags = (Tag[]) p_tag.getValue(); for (Tag st : subtags) { editBlocksInTag(st); } } else if (type == Tag.Type.TAG_Compound) { Tag[] subtags = (Tag[]) p_tag.getValue(); for (Tag st : subtags) { editBlocksInTag(st); } } else { } return null; } }