├── .gitignore ├── lib ├── lwjgl.jar ├── lwjgl_util.jar ├── log4j-1.2.16.jar ├── native │ ├── lwjgl.dll │ ├── OpenAL32.dll │ ├── OpenAL64.dll │ ├── liblwjgl.so │ ├── libopenal.so │ ├── lwjgl64.dll │ ├── openal.dylib │ ├── jinput-dx8.dll │ ├── jinput-raw.dll │ ├── liblwjgl64.so │ ├── libopenal64.so │ ├── jinput-dx8_64.dll │ ├── jinput-raw_64.dll │ ├── liblwjgl.jnilib │ ├── libjinput-linux.so │ ├── libjinput-linux64.so │ └── libjinput-osx.jnilib └── snakeyaml-1.9.jar ├── textures ├── art │ └── kz.png ├── terrain.png ├── misc │ └── water.png └── particles.png ├── support ├── xray_icon.ico ├── xray_icon.png ├── launch4j-dist │ ├── bin │ │ ├── ld │ │ └── windres │ ├── head │ │ ├── head.o │ │ └── guihead.o │ ├── xstream.jar │ ├── launch4j.jar │ └── w32api │ │ ├── crt2.o │ │ ├── libgcc.a │ │ ├── libmsvcrt.a │ │ ├── libuser32.a │ │ ├── libadvapi32.a │ │ ├── libkernel32.a │ │ ├── libmingw32.a │ │ └── libshell32.a ├── minecraft_xray.bat ├── minecraft_xray.sh ├── minecraft_xray_osx.command ├── launch4j.xml └── log4j.properties ├── META-INF └── MANIFEST.MF ├── .project ├── .classpath ├── .settings └── org.eclipse.jdt.core.prefs ├── COPYING-lwjgl.txt ├── src └── com │ └── apocalyptech │ └── minecraft │ └── xray │ ├── DimensionFilterException.java │ ├── dtf │ ├── EndTag.java │ ├── IntTag.java │ ├── ByteTag.java │ ├── LongTag.java │ ├── FloatTag.java │ ├── ShortTag.java │ ├── StringTag.java │ ├── DoubleTag.java │ ├── Tag.java │ ├── IntArrayTag.java │ ├── ListTag.java │ ├── ByteArrayTag.java │ ├── ShortArrayTag.java │ ├── CompoundTag.java │ └── DTFReader.java │ ├── CameraPreset.java │ ├── RegionFileFilter.java │ ├── PaintingEntity.java │ ├── DimensionFilter.java │ ├── dialog │ ├── BlockBindChooserButton.java │ ├── BlockBindMainButton.java │ ├── BlockBindButton.java │ ├── KeyField.java │ ├── KeyPanel.java │ └── WarningDialog.java │ ├── IntegerPair.java │ ├── PaintingInfo.java │ ├── Block.java │ ├── BlockTypeLoadException.java │ ├── LightSourceRegistry.java │ ├── XRayProperties.java │ ├── FirstPersonCameraController.java │ ├── BlockTypeRegular.java │ ├── TextureDecorationStats.java │ ├── SpriteTool.java │ ├── RegionFileCache.java │ ├── BlockTypeFilename.java │ ├── ChunkOriginal.java │ └── WorldInfo.java ├── COPYING-launch4j.txt ├── COPYING.txt ├── BUILDING.txt ├── TODO.txt ├── COPYING-snakeyaml.txt └── COPYING-log4j.txt /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | *.swp 4 | minecraft_xray_output_log.txt 5 | -------------------------------------------------------------------------------- /lib/lwjgl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/lwjgl.jar -------------------------------------------------------------------------------- /lib/lwjgl_util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/lwjgl_util.jar -------------------------------------------------------------------------------- /lib/log4j-1.2.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/log4j-1.2.16.jar -------------------------------------------------------------------------------- /lib/native/lwjgl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/lwjgl.dll -------------------------------------------------------------------------------- /textures/art/kz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/textures/art/kz.png -------------------------------------------------------------------------------- /textures/terrain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/textures/terrain.png -------------------------------------------------------------------------------- /lib/native/OpenAL32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/OpenAL32.dll -------------------------------------------------------------------------------- /lib/native/OpenAL64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/OpenAL64.dll -------------------------------------------------------------------------------- /lib/native/liblwjgl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/liblwjgl.so -------------------------------------------------------------------------------- /lib/native/libopenal.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/libopenal.so -------------------------------------------------------------------------------- /lib/native/lwjgl64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/lwjgl64.dll -------------------------------------------------------------------------------- /lib/native/openal.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/openal.dylib -------------------------------------------------------------------------------- /lib/snakeyaml-1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/snakeyaml-1.9.jar -------------------------------------------------------------------------------- /support/xray_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/xray_icon.ico -------------------------------------------------------------------------------- /support/xray_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/xray_icon.png -------------------------------------------------------------------------------- /textures/misc/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/textures/misc/water.png -------------------------------------------------------------------------------- /textures/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/textures/particles.png -------------------------------------------------------------------------------- /lib/native/jinput-dx8.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/jinput-dx8.dll -------------------------------------------------------------------------------- /lib/native/jinput-raw.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/jinput-raw.dll -------------------------------------------------------------------------------- /lib/native/liblwjgl64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/liblwjgl64.so -------------------------------------------------------------------------------- /lib/native/libopenal64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/libopenal64.so -------------------------------------------------------------------------------- /lib/native/jinput-dx8_64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/jinput-dx8_64.dll -------------------------------------------------------------------------------- /lib/native/jinput-raw_64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/jinput-raw_64.dll -------------------------------------------------------------------------------- /lib/native/liblwjgl.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/liblwjgl.jnilib -------------------------------------------------------------------------------- /support/launch4j-dist/bin/ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/bin/ld -------------------------------------------------------------------------------- /lib/native/libjinput-linux.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/libjinput-linux.so -------------------------------------------------------------------------------- /lib/native/libjinput-linux64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/libjinput-linux64.so -------------------------------------------------------------------------------- /lib/native/libjinput-osx.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/lib/native/libjinput-osx.jnilib -------------------------------------------------------------------------------- /support/launch4j-dist/bin/windres: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/bin/windres -------------------------------------------------------------------------------- /support/launch4j-dist/head/head.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/head/head.o -------------------------------------------------------------------------------- /support/launch4j-dist/xstream.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/xstream.jar -------------------------------------------------------------------------------- /support/launch4j-dist/launch4j.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/launch4j.jar -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/crt2.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/crt2.o -------------------------------------------------------------------------------- /support/launch4j-dist/head/guihead.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/head/guihead.o -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libgcc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libgcc.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libmsvcrt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libmsvcrt.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libuser32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libuser32.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libadvapi32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libadvapi32.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libkernel32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libkernel32.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libmingw32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libmingw32.a -------------------------------------------------------------------------------- /support/launch4j-dist/w32api/libshell32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apocalyptech/minecraftxray/HEAD/support/launch4j-dist/w32api/libshell32.a -------------------------------------------------------------------------------- /META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.2 2 | Main-Class: com.apocalyptech.minecraft.xray.XRay 3 | Class-Path: lib/lwjgl.jar lib/lwjgl_util.jar lib/snakeyaml-1.9.jar lib/log4j-1.2.16.jar 4 | -------------------------------------------------------------------------------- /support/minecraft_xray.bat: -------------------------------------------------------------------------------- 1 | java -Xms256m -Xmx1024m -Djava.library.path=lib/native -Dlog4j.configuration=file:log4j.properties -jar xray.jar 2 | @echo. 3 | @echo X-Ray log saved to minecraft_xray_output_log.txt 4 | @echo. 5 | @pause 6 | -------------------------------------------------------------------------------- /support/minecraft_xray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "`dirname "$0"`" 3 | java -Xms256m -Xmx1024m -Djava.library.path=lib/native -Dlog4j.configuration=file:log4j.properties -jar xray.jar 4 | 5 | echo 6 | echo "X-Ray log saved to minecraft_xray_output_log.txt" 7 | echo 8 | -------------------------------------------------------------------------------- /support/minecraft_xray_osx.command: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "`dirname "$0"`" 3 | java -Xms256m -Xmx1024m -Djava.library.path=lib/native -Dlog4j.configuration=file:log4j.properties -jar xray.jar 4 | 5 | echo 6 | echo "X-Ray log saved to minecraft_xray_output_log.txt" 7 | echo 8 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | xray 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /support/launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | minecraft_xray.exe 4 | xray.jar 5 | true 6 | http://java.com/download 7 | xray_icon.ico 8 | 9 | 1.6.0 10 | -Djava.library.path=lib\\native 11 | -Dlog4j.configuration=file:log4j.properties 12 | 13 | 14 | -------------------------------------------------------------------------------- /support/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger = INFO, STDOUT, LOGFILE 2 | 3 | log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender 4 | log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.STDOUT.layout.ConversionPattern=%5p | %m%n 6 | 7 | log4j.appender.LOGFILE=org.apache.log4j.FileAppender 8 | log4j.appender.LOGFILE.File=minecraft_xray_output_log.txt 9 | log4j.appender.LOGFILE.Append=false 10 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.LOGFILE.layout.ConversionPattern=%d - %p | %m%n 12 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Mon Oct 04 20:54:23 CEST 2010 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.5 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.5 13 | -------------------------------------------------------------------------------- /COPYING-lwjgl.txt: -------------------------------------------------------------------------------- 1 | LWJGL is provided under the New/Modified BSD License. For LWJGL sourcecode 2 | and the like, see http://www.lwjgl.org/ 3 | 4 | /* 5 | * Copyright (c) 2002-2008 Lightweight Java Game Library Project 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * * Neither the name of 'Light Weight Java Game Library' nor the names of 20 | * its contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/DimensionFilterException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | public class DimensionFilterException extends Exception { 30 | public DimensionFilterException() 31 | { 32 | super(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/EndTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class EndTag extends Tag { 30 | public EndTag() { 31 | 32 | } 33 | public String toString(int tab) { 34 | return tab(tab) + "TAG_End()\n"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/IntTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class IntTag extends Tag { 30 | public int value; 31 | public IntTag(String name, int value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | public String toString(int tab) { 36 | return tab(tab) + "TAG_Int(\"" + name + "\"): " + value + "\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/ByteTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class ByteTag extends Tag { 30 | public byte value; 31 | public ByteTag(String name, byte b) { 32 | this.name = name; 33 | this.value = b; 34 | } 35 | 36 | public String toString(int tab) { 37 | return tab(tab) + "TAG_Byte(\"" + name + "\"): " + value + "\n"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/LongTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class LongTag extends Tag { 30 | public long value; 31 | public LongTag(String name, long value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | public String toString(int tab) { 36 | return tab(tab) + "TAG_Long(\"" + name + "\"): " + value + "\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/FloatTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class FloatTag extends Tag { 30 | public float value; 31 | public FloatTag(String name, float value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | public String toString(int tab) { 36 | return tab(tab) + "TAG_Float(\"" + name + "\"): " + value + "\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/ShortTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class ShortTag extends Tag { 30 | public short value; 31 | public ShortTag(String name, short value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | public String toString(int tab) { 36 | return tab(tab) + "TAG_Short(\"" + this.name + "\"): " + this.value + "\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/StringTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class StringTag extends Tag { 30 | public String value; 31 | public StringTag(String name, String value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | public String toString(int tab) { 36 | return tab(tab) + "TAG_String(\"" + name + "\"): " + value + "\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/DoubleTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class DoubleTag extends Tag { 30 | public double value; 31 | public DoubleTag(String name, double value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | 36 | public String toString(int tab) { 37 | return tab(tab) + "TAG_Double(\"" + name + "\"): " + value + "\n"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/Tag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public abstract class Tag { 30 | public Tag nextTag; 31 | public String name; 32 | 33 | public String tab(int t) { 34 | String f = ""; 35 | for(int i=0;i value; 33 | public ListTag(String name, ArrayList value) { 34 | this.name = name; 35 | this.value = value; 36 | } 37 | public String toString(int tab) { 38 | String f = tab(tab); 39 | f += "TAG_List(\"" + name + "\")\n"; 40 | f += tab(tab) + "(\n"; 41 | for(Tag t : value) { 42 | f += t.toString(tab+1); 43 | } 44 | f += tab(tab) + "}\n"; 45 | 46 | return f; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/ByteArrayTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class ByteArrayTag extends Tag { 30 | public byte[] value; 31 | public ByteArrayTag(String name, byte[] value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | 36 | public String toString(int tab) { 37 | String f = tab(tab) + "TAG_ByteArray(\"" + name + "\"): ["; 38 | /* for(byte b : value) { 39 | f += Integer.toHexString(b) + ", "; 40 | }*/ 41 | 42 | //f = f.substring(0,f.length()-2); 43 | f += "" + value.length + " bytes"; 44 | f += "]\n"; 45 | return f; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/ShortArrayTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | public class ShortArrayTag extends Tag { 30 | public short[] value; 31 | public ShortArrayTag(String name, short[] value) { 32 | this.name = name; 33 | this.value = value; 34 | } 35 | 36 | public String toString(int tab) { 37 | String f = tab(tab) + "TAG_ShortArray(\"" + name + "\"): ["; 38 | /* for(byte b : value) { 39 | f += Integer.toHexString(b) + ", "; 40 | }*/ 41 | 42 | //f = f.substring(0,f.length()-2); 43 | f += "" + (value.length*2) + " bytes"; 44 | f += "]\n"; 45 | return f; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/CameraPreset.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | /** 30 | * Simple data container to hold information about a player's location. Used so 31 | * that we can switch between users when loading multiplayer maps, though it's 32 | * also intended to hold the singleplayer location, if available. 33 | */ 34 | class CameraPreset 35 | { 36 | public int idx; 37 | public String name; 38 | public Block block; 39 | public float yaw; 40 | public float pitch; 41 | 42 | CameraPreset(int idx, String name, Block block, float yaw, float pitch) 43 | { 44 | this.idx = idx; 45 | this.name = name; 46 | this.block = block; 47 | this.yaw = yaw; 48 | this.pitch = pitch; 49 | } 50 | } -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/CompoundTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | import java.util.ArrayList; 30 | 31 | public class CompoundTag extends Tag { 32 | public ArrayList value; 33 | public CompoundTag(String name, ArrayList value) { 34 | this.name = name; 35 | this.value = value; 36 | } 37 | public Tag getTagWithName(String name) { 38 | for(Tag t : value) { 39 | if(t.name != null && t.name.equals(name)) { 40 | return t; 41 | } 42 | } 43 | return null; 44 | } 45 | public String toString(int tab) { 46 | String f = tab(tab); 47 | f += "TAG_Compound(\"" + name + "\")\n"; 48 | f += tab(tab) + "(\n"; 49 | for(Tag t : value) { 50 | f += t.toString(tab+1); 51 | } 52 | f += tab(tab) + "}\n"; 53 | 54 | return f; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/RegionFileFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | package com.apocalyptech.minecraft.xray; 29 | 30 | import java.io.File; 31 | import java.io.FilenameFilter; 32 | 33 | /** 34 | * Simple class to filter on region files 35 | */ 36 | public class RegionFileFilter implements FilenameFilter 37 | { 38 | public static String match_regex; 39 | 40 | public RegionFileFilter(WorldInfo world) { 41 | switch (world.data_format) 42 | { 43 | case ANVIL: 44 | RegionFileFilter.match_regex = "^r\\.(-?\\d+)\\.(-?\\d+)\\.mca$"; 45 | break; 46 | 47 | case ORIGINAL: 48 | default: 49 | RegionFileFilter.match_regex = "^r\\.(-?\\d+)\\.(-?\\d+)\\.mcr$"; 50 | break; 51 | } 52 | } 53 | 54 | public boolean accept(File directory, String filename) { 55 | return (filename.matches(this.match_regex)); 56 | //return (filename.endsWith(".mcr")); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/PaintingEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import com.apocalyptech.minecraft.xray.dtf.CompoundTag; 30 | import com.apocalyptech.minecraft.xray.dtf.StringTag; 31 | import com.apocalyptech.minecraft.xray.dtf.ByteTag; 32 | import com.apocalyptech.minecraft.xray.dtf.IntTag; 33 | 34 | public class PaintingEntity 35 | { 36 | public float tile_x; 37 | public float tile_y; 38 | public float tile_z; 39 | public String name; 40 | public byte dir; 41 | 42 | public PaintingEntity(CompoundTag t) 43 | { 44 | IntTag tile_x = (IntTag) t.getTagWithName("TileX"); 45 | IntTag tile_y = (IntTag) t.getTagWithName("TileY"); 46 | IntTag tile_z = (IntTag) t.getTagWithName("TileZ"); 47 | StringTag name = (StringTag) t.getTagWithName("Motive"); 48 | ByteTag dir = (ByteTag) t.getTagWithName("Dir"); 49 | 50 | this.tile_x = tile_x.value; 51 | this.tile_y = tile_y.value; 52 | this.tile_z = tile_z.value; 53 | this.name = name.value; 54 | this.dir = dir.value; 55 | } 56 | } -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/DimensionFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.io.File; 30 | import java.io.FilenameFilter; 31 | import java.lang.NumberFormatException; 32 | 33 | public class DimensionFilter implements FilenameFilter 34 | { 35 | public DimensionFilter() { 36 | // Nothing, really 37 | } 38 | 39 | public static int get_dimension(String filename) throws DimensionFilterException { 40 | if (filename.startsWith("DIM")) 41 | { 42 | try 43 | { 44 | return Integer.parseInt(filename.substring(3)); 45 | } 46 | catch (NumberFormatException e) 47 | { 48 | // pass, will throw down below 49 | } 50 | } 51 | throw new DimensionFilterException(); 52 | } 53 | 54 | public boolean accept(File directory, String filename) { 55 | File combfile = new File(directory, filename); 56 | if (combfile.exists() && combfile.isDirectory()) 57 | { 58 | try 59 | { 60 | get_dimension(filename); 61 | return true; 62 | } 63 | catch (DimensionFilterException e) 64 | { 65 | return false; 66 | } 67 | } 68 | return false; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dialog/BlockBindChooserButton.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dialog; 28 | 29 | import com.apocalyptech.minecraft.xray.BlockType; 30 | 31 | import java.util.HashMap; 32 | import javax.swing.ImageIcon; 33 | 34 | import java.awt.event.ActionListener; 35 | import java.awt.event.ActionEvent; 36 | 37 | /** 38 | * A single button describing a block 39 | */ 40 | public class BlockBindChooserButton 41 | extends BlockBindButton 42 | implements ActionListener 43 | { 44 | private BlockBindChooserDialog parent; 45 | 46 | /** 47 | * Constructor, takes in our currently-assigned block, and a map of icons. 48 | * 49 | * @param block The currently assigned block 50 | * @param icon_map A map of block IDs to icons 51 | * @param parent our parent to callback to when clicked 52 | */ 53 | public BlockBindChooserButton(BlockType block, HashMap icon_map, BlockBindChooserDialog parent) 54 | { 55 | super(block, icon_map); 56 | this.parent = parent; 57 | this.addActionListener(this); 58 | } 59 | 60 | /** 61 | * What to do when we're clicked, for the ActionListener interface 62 | */ 63 | public void actionPerformed(ActionEvent e) 64 | { 65 | parent.notifyHighlightClicked(this); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/IntegerPair.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2005-2006, The ParticleReality Project 3 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Minecraft X-Ray team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | package com.apocalyptech.minecraft.xray; 30 | 31 | /*** 32 | * Class holding a pair of two integers where the order is determined 33 | * first by the first integer and when these are equal, by the second 34 | * integer. This is used for holding resolution information 35 | * @author Vincent Vollers 36 | */ 37 | @SuppressWarnings("rawtypes") 38 | public class IntegerPair implements Comparable { 39 | private int valueOne; 40 | private int valueTwo; 41 | 42 | public IntegerPair(int valueOne, int valueTwo) { 43 | this.valueOne = valueOne; 44 | this.valueTwo = valueTwo; 45 | } 46 | 47 | public int getValueOne() { 48 | return this.valueOne; 49 | } 50 | 51 | public int getValueTwo() { 52 | return this.valueTwo; 53 | } 54 | 55 | public int compareTo(Object o) { 56 | if(!(o instanceof IntegerPair)) { 57 | return -1; 58 | } 59 | IntegerPair i = (IntegerPair) o; 60 | 61 | if(i.getValueOne()>valueOne) 62 | return 1; 63 | 64 | if(i.getValueOne()valueTwo) 68 | return 1; 69 | 70 | if(i.getValueTwo() icon_map, BlockBindDialog parent, int position) 55 | { 56 | super(block, icon_map); 57 | this.position = position; 58 | this.parent = parent; 59 | this.addActionListener(this); 60 | } 61 | 62 | /** 63 | * Returns our highlight position 64 | */ 65 | public int getPosition() 66 | { 67 | return this.position; 68 | } 69 | 70 | /** 71 | * What to do when we're clicked, for the ActionListener interface 72 | */ 73 | public void actionPerformed(ActionEvent e) 74 | { 75 | parent.notifyHighlightClicked(this); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/Block.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | /** 30 | * @author Vincent Vollers 31 | * 32 | * A Block in the minecraft world 33 | * wildly abused :( for its 'simple' integer x,y,z properties 34 | */ 35 | public class Block implements Comparable { 36 | 37 | 38 | public int x; 39 | public int y; 40 | public int z; 41 | public int t; 42 | public int cx; 43 | public int cz; 44 | 45 | public Block(int x, int y, int z) { 46 | this.x =x; 47 | this.y =y; 48 | this.z =z; 49 | this.cx = -x/16; 50 | this.cz = -z/16; 51 | } 52 | 53 | public int compareTo(Block a) { 54 | // TODO Auto-generated method stub 55 | 56 | Block b = (Block) a; 57 | if(b.x > x) { 58 | return 1; 59 | } 60 | if(b.x < x) { 61 | return -1; 62 | } 63 | if(b.z > z) { 64 | return 1; 65 | } 66 | if(b.z < z) { 67 | return -1; 68 | } 69 | if(b.y > y) { 70 | return 1; 71 | } 72 | if(b.y < y) { 73 | return -1; 74 | } 75 | return 0; 76 | } 77 | 78 | public boolean equals(Object o) { 79 | if(!(o instanceof Block)) { 80 | return false; 81 | } 82 | Block p = (Block) o; 83 | return this.x == p.x && this.y == p.y && this.z == p.z; 84 | } 85 | 86 | public boolean equals(Block p) { 87 | return this.x == p.x && this.y == p.y && this.z == p.z; 88 | } 89 | public String toString() { 90 | return "Point( x=" + x + ", y=" + y + ", z=" + z + ")"; 91 | } 92 | 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dialog/BlockBindButton.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dialog; 28 | 29 | import com.apocalyptech.minecraft.xray.BlockType; 30 | 31 | import java.util.HashMap; 32 | import javax.swing.JButton; 33 | import javax.swing.ImageIcon; 34 | 35 | /** 36 | * A single button describing a block 37 | */ 38 | public class BlockBindButton 39 | extends JButton 40 | { 41 | private BlockType block; 42 | private HashMap icon_map; 43 | 44 | /** 45 | * Constructor, takes in our currently-assigned block, and a map of icons. 46 | * 47 | * @param block The currently assigned block 48 | * @param icon_map A map of block IDs to icons 49 | */ 50 | public BlockBindButton(BlockType block, HashMap icon_map) 51 | { 52 | super(); 53 | this.icon_map = icon_map; 54 | this.setBlock(block); 55 | } 56 | 57 | /** 58 | * Sets a new BlockType for this button to represent. Will update its 59 | * text and icon. 60 | * 61 | * @param block The new BlockType 62 | */ 63 | public void setBlock(BlockType block) 64 | { 65 | this.block = block; 66 | 67 | if (block == null) 68 | { 69 | this.setText("(none)"); 70 | } 71 | else 72 | { 73 | if (block.aka != null && !block.name.equalsIgnoreCase(block.aka)) 74 | { 75 | this.setText(block.name + " (" + block.aka + ")"); 76 | } 77 | else 78 | { 79 | this.setText(block.name); 80 | } 81 | if (icon_map.containsKey(block.getId())) 82 | { 83 | this.setIcon(icon_map.get(block.getId())); 84 | } 85 | } 86 | } 87 | 88 | /** 89 | * Gets the currently-assigned block 90 | */ 91 | public BlockType getBlock() 92 | { 93 | return this.block; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/BlockTypeLoadException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import com.apocalyptech.minecraft.xray.dialog.ExceptionDialog; 30 | 31 | public class BlockTypeLoadException extends Exception { 32 | private Exception origException; 33 | private String extraStatus1; 34 | private String extraStatus2; 35 | public BlockTypeLoadException() 36 | { 37 | this.origException = null; 38 | this.extraStatus1 = ExceptionDialog.getExtraStatus1(); 39 | this.extraStatus2 = ExceptionDialog.getExtraStatus2(); 40 | } 41 | public BlockTypeLoadException(String message) 42 | { 43 | super(message); 44 | this.origException = null; 45 | this.extraStatus1 = ExceptionDialog.getExtraStatus1(); 46 | this.extraStatus2 = ExceptionDialog.getExtraStatus2(); 47 | } 48 | public BlockTypeLoadException(String message, Exception origException) 49 | { 50 | super(message); 51 | this.origException = origException; 52 | this.extraStatus1 = ExceptionDialog.getExtraStatus1(); 53 | this.extraStatus2 = ExceptionDialog.getExtraStatus2(); 54 | } 55 | public Exception getOrigException() 56 | { 57 | return this.origException; 58 | } 59 | public String toString() 60 | { 61 | StringBuffer errStr = new StringBuffer(); 62 | if (this.extraStatus1 != null) 63 | { 64 | errStr.append(this.extraStatus1 + " - "); 65 | } 66 | if (this.extraStatus2 != null) 67 | { 68 | errStr.append(this.extraStatus2 + " - "); 69 | } 70 | if (this.getMessage() != null) 71 | { 72 | errStr.append(this.getMessage() + " - "); 73 | } 74 | if (this.origException != null && this.origException.toString() != null) 75 | { 76 | errStr.append(this.origException.toString()); 77 | } 78 | if (errStr.toString().endsWith(" - ")) 79 | { 80 | return errStr.toString().substring(0, errStr.length() - 3); 81 | } 82 | else 83 | { 84 | return errStr.toString(); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /COPYING-launch4j.txt: -------------------------------------------------------------------------------- 1 | As mentioned on http://launch4j.sourceforge.net/ - 2 | 3 | launch4j is free software licensed under the BSD license, the head subproject (the 4 | code which is attached to the wrapped jars) is licensed under the MIT license. 5 | Launch4j may be used for wrapping closed source, commercial applications. 6 | 7 | Additionally, launch4j (and thus this distribution) requires a couple of utilities 8 | from the MinGW project, which appear to be under the GPLv2 license. See "COPYING" 9 | inside support/launch4j-dist/bin for more information on that. 10 | 11 | All of the files redistributed here were taken from the launch4j 3.0.2 Linux 12 | distribution. 13 | 14 | The license for launch4j follows, and the license for "head" follows afterwards. 15 | 16 | launch4j 17 | -------- 18 | 19 | Launch4j (http://launch4j.sourceforge.net/) 20 | Cross-platform Java application wrapper for creating Windows native executables. 21 | 22 | Copyright (c) 2004, 2011 Grzegorz Kowal 23 | 24 | All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or without modification, 27 | are permitted provided that the following conditions are met: 28 | 29 | * Redistributions of source code must retain the above copyright notice, 30 | this list of conditions and the following disclaimer. 31 | * Redistributions in binary form must reproduce the above copyright notice, 32 | this list of conditions and the following disclaimer in the documentation 33 | and/or other materials provided with the distribution. 34 | * Neither the name of the Launch4j nor the names of its contributors 35 | may be used to endorse or promote products derived from this software without 36 | specific prior written permission. 37 | 38 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 41 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 42 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 43 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 44 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 45 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 46 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 47 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 48 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | head 51 | ---- 52 | 53 | Copyright (c) 2004, 2007 Grzegorz Kowal 54 | 55 | Permission is hereby granted, free of charge, to any person obtaining a copy 56 | of this software and associated documentation files (the "Software"), to deal 57 | in the Software without restriction, including without limitation the rights 58 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 59 | copies of the Software, and to permit persons to whom the Software is 60 | furnished to do so, subject to the following conditions: 61 | 62 | The above copyright notice and this permission notice shall be included in 63 | all copies or substantial portions of the Software. 64 | 65 | Except as contained in this notice, the name(s) of the above copyright holders 66 | shall not be used in advertising or otherwise to promote the sale, use or other 67 | dealings in this Software without prior written authorization. 68 | 69 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 70 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 71 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 72 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 73 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 74 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 75 | THE SOFTWARE. 76 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | X-Ray itself is available under the New/Modified BSD License. Full text 2 | is below. 3 | 4 | X-Ray redistributes the following components: 5 | 6 | * LWJGL 7 | http://lwjgl.org/ 8 | This is also distributed under the the new/modified BSD license, though 9 | specific details can be found in COPYING-lwjgl.txt. 10 | 11 | * launch4j 12 | http://launch4j.sourceforge.net/ 13 | This is used for Windows EXE generation, and is available under a BSD 14 | license. It also appears to include code under the MIT license, and 15 | includes some binaries licensed under the GPL. See COPYING-launch4j.txt 16 | for more details on that. 17 | 18 | * SnakeYAML 19 | http://code.google.com/p/snakeyaml/ 20 | Available under the Apache License 2.0. See COPYING-snakeyaml.txt for more 21 | details on that. 22 | 23 | * log4j 24 | http://logging.apache.org/log4j/1.2/ 25 | Also available under the Apache License 2.0. See COPYING-log4j.txt for 26 | more details on that. 27 | 28 | * Various files from Minecraft's builtin texturepack 29 | http://www.minecraft.net/ 30 | Specifically: terrain.png, particles.png, art/kz.png, and misc/water.png 31 | Technically this redistribution is in violation of Mojang's stated 32 | "Do not distribute anything we've made" rule, but I'm pretty sure that 33 | this kind of usage would be acceptible regardless, especially given that 34 | the bundled texturepack is only used in extreme corner cases where the 35 | user's installed minecraft.jar can't be found on the drive. Plus, many 36 | other prominent community tools have been bundling terrain.png for some 37 | time now (INVedit, MCEdit, etc). Ah, the "everyone else was doing it" 38 | argument! Anyway, I will of course readily cease using the official 39 | texturepack in here if asked. 40 | 41 | * RegionFile.java and RegionFileCache.java, courtesy Jens Bergensten of Mojang 42 | http://mojang.com/2011/02/16/minecraft-save-file-format-in-beta-1-3/ 43 | They appear to be under a sort of generic public domain license. 44 | 45 | In general, the X-Ray sourcecode files here will list a copyright for both 46 | Vincent Vollers and CJ Kucera, though the actual distribution of code copyright 47 | would probably be more complicated than that. Please forgive any instances of 48 | code misattribution! 49 | 50 | ---- 51 | 52 | Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 53 | All rights reserved. 54 | 55 | Redistribution and use in source and binary forms, with or without 56 | modification, are permitted provided that the following conditions are met: 57 | * Redistributions of source code must retain the above copyright 58 | notice, this list of conditions and the following disclaimer. 59 | * Redistributions in binary form must reproduce the above copyright 60 | notice, this list of conditions and the following disclaimer in the 61 | documentation and/or other materials provided with the distribution. 62 | * Neither the name of the Minecraft X-Ray team nor the 63 | names of its contributors may be used to endorse or promote products 64 | derived from this software without specific prior written permission. 65 | 66 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 67 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 68 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 69 | DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 70 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 71 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 72 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 73 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 74 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 75 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 76 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dialog/KeyField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera, Eleazar Vega-Gonzalez, 3 | * and Saxon Parker 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Minecraft X-Ray team nor the 14 | * names of its contributors may be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | package com.apocalyptech.minecraft.xray.dialog; 29 | 30 | import java.awt.Color; 31 | import java.awt.event.MouseEvent; 32 | import java.awt.event.MouseListener; 33 | 34 | import javax.swing.JTextField; 35 | 36 | import com.apocalyptech.minecraft.xray.MinecraftConstants.KEY_ACTION; 37 | 38 | /*** 39 | * KeyField class is used for the KeyHelpDialog. It is a Field that 40 | * will contain the LWJGL string for the keyboard button that is pressed 41 | * while the field is in focus. 42 | * 43 | * @author Eleazar 44 | */ 45 | public class KeyField extends JTextField{ 46 | private KEY_ACTION keyAction; 47 | private KeyPanel panel; 48 | private Color bgColorNormal; 49 | private Color bgColorActive; 50 | 51 | /** 52 | * Constructs a new KeyField given the string to populate it with 53 | * and the KEY_ACTION it represents 54 | * @param ka 55 | * @param s 56 | */ 57 | public KeyField(KEY_ACTION ka, KeyPanel panel) { 58 | super(10); 59 | this.keyAction = ka; 60 | this.panel = panel; 61 | this.setEditable(false); 62 | this.bgColorNormal = Color.WHITE; 63 | this.bgColorActive = new Color(144, 204, 255); 64 | this.setBackground(this.bgColorNormal); 65 | this.setFocusable(false); 66 | this.addMouseListener(new KeyFieldMouseListener(this)); 67 | } 68 | 69 | /** 70 | * What to do when we're clicked 71 | */ 72 | public void clicked() 73 | { 74 | this.panel.notifyClicked(); 75 | this.setBackground(this.bgColorActive); 76 | } 77 | 78 | /** 79 | * What to do when we're no longer in a "clicked" state 80 | */ 81 | public void clickFinish() 82 | { 83 | this.setBackground(this.bgColorNormal); 84 | } 85 | 86 | /*Inner classes below*/ 87 | 88 | private class KeyFieldMouseListener implements MouseListener 89 | { 90 | KeyField kf; 91 | KeyFieldMouseListener(KeyField kf) 92 | { 93 | this.kf = kf; 94 | } 95 | public void mouseClicked(MouseEvent e) 96 | { 97 | this.kf.clicked(); 98 | } 99 | public void mouseEntered(MouseEvent e) 100 | { 101 | } 102 | public void mouseExited(MouseEvent e) 103 | { 104 | } 105 | public void mousePressed(MouseEvent e) 106 | { 107 | } 108 | public void mouseReleased(MouseEvent e) 109 | { 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /BUILDING.txt: -------------------------------------------------------------------------------- 1 | You're best off checking out the project from Git, rather than 2 | using the bundled sourcecode in the release .zip and .tbz2 archives. 3 | If you do want to use the bundled source rather than checking out the 4 | project, you'll have to do some file copying: 5 | 6 | The build expects the LWJGL libraries and a few other Jar files in 7 | the "lib" directory. Specifically it's looking for: 8 | 9 | AppleJavaExtensions.jar (presumably just for OSX) 10 | jinput.jar 11 | lwjgl_test.jar 12 | lwjgl_util_applet.jar 13 | lwjgl_util.jar 14 | lwjgl.jar 15 | lzma.jar 16 | snakeyaml-1.9.jar 17 | log4j-1.2.16.jar 18 | 19 | ... Possibly some of those are optional, but you may as well leave them 20 | in. Inside lib/native, make sure that you've got the "native" LWJGL 21 | files, as well. These will be .dll if you're on Windows, and .so on 22 | Linux. 23 | 24 | Additionally, technically speaking you'd want to copy the "textures" 25 | directory over into the source tree as well. 26 | 27 | At that point, you should theoretically be good to go. 28 | 29 | You should be able to develop (or just use) the source either from 30 | the commandline or Eclipse. The tool was originally developed in 31 | Eclipse, but EGit (Eclipse's Git interface) turned out to be kind of 32 | annoying, which was all the urging I needed to abandon the crutch of 33 | handy autocompletion for the warm comforts of my beloved vim (which, 34 | yes, I know, can do autocompletes if you coerce it into doing so). 35 | 36 | COMMANDLINE 37 | ----------- 38 | 39 | If you're on the commandline, you can use Ant to build/run, 40 | etc. "ant run" should be sufficient to run the app (it will compile up 41 | a debug version automatically). "ant dist" will package it up as if you're 42 | doing a release, though note that right now that step will only work 43 | on Linux. I've never taken the time to figure out how to get launch4j to 44 | work on other platforms. See build.xml for other ant targets. 45 | 46 | ECLIPSE 47 | ------- 48 | 49 | First, a disclaimer: as I mentioned above, I haven't actually used Eclipse 50 | with this project in some time, so it's possible that you'll need to do 51 | more work than is mentioned here. I believe that these docs should be 52 | sufficient, but let me know if it's not. 53 | 54 | If you want to use Eclipse, there's a couple of extra steps. I feel that 55 | both of them really *should* have workarounds which would prevent them from 56 | being needed, but I never did figure it out. Anyway: 57 | 58 | 1) In Eclipse, go to Window -> Preferences -> Java -> Build Path -> Classpath 59 | Variables, then click the "New" button and create a variable called 60 | "XRAY_CLASSPATH". Point that directory at the "lib" dir underneath the 61 | X-Ray project. This should let you compile the app. 62 | 63 | (As an aside, the ".classpath" file distributed with the original X-Ray 64 | distribution specified its jar files with relative paths, such as 65 | "lib/lwjgl.jar". I could never get that to actually work, though, which 66 | is why they're all prefixed with that XRAY_CLASSPATH var now. It'd be 67 | nice to know why, and equally nice to be able to get rid of having to 68 | set up that variable.) 69 | 70 | 2) To actually RUN the app through Eclipse, right-click on the top project 71 | in Package Explorer, go to Properties -> Run/Debug Settings -> XRay, and 72 | click on "Edit". In the Arguments tab, set the VM arguments to: 73 | 74 | -Xms256m -Xmx1024m -Djava.library.path=/path/to/workspace/xray/lib/native -Dlog4j.configuration=file:support/log4j.properties 75 | 76 | ... replacing the "/path/to/workspace" with the path to your actual 77 | Eclipse workspace. If anyone's got a way around having to do that, let 78 | me know. 79 | 80 | You MIGHT have to go into the Classpath tab there, as well, and add in 81 | the JARs under lib/ again (which would show up under that XRAY_CLASSPATH 82 | var), though I don't remember if that automatically happens or not. 83 | 84 | The various build.xml targets should work fine inside Eclipse, too, of course. 85 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/LightSourceRegistry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.util.HashMap; 30 | 31 | /** 32 | * Class to aid in our "explored" highlight. Basically just a wrapper 33 | * around a big ol' HashMap. Note that there's currently no API to 34 | * expire information in here. Technically that means that if a user 35 | * were to load X-Ray, travel a ways away, then load Minecraft and make 36 | * some changes, then go BACK into X-Ray and travel back to the original 37 | * location, this registry might differ from what's being shown. 38 | * 39 | * I'm not exactly overly concerned about that. 40 | */ 41 | public class LightSourceRegistry 42 | { 43 | private HashMap>> registry; 44 | private final int radius = 3; 45 | 46 | public LightSourceRegistry() 47 | { 48 | // Note that the order will be: x, z, y 49 | registry = new HashMap>>(); 50 | } 51 | 52 | /** 53 | * Adds a new entry to the registry. Will also add all "adjacent" blocks 54 | * based on the radius, though note that we're adding a cube centered around 55 | * the given coordinates, not a sphere. 56 | */ 57 | public void add(int x, int y, int z) 58 | { 59 | for (int lx = x - this.radius; 60 | lx <= x + this.radius; 61 | lx++) 62 | { 63 | for (int lz = z - this.radius; 64 | lz <= z + this.radius; 65 | lz++) 66 | { 67 | for (int ly = y - this.radius; 68 | ly <= y + this.radius; 69 | ly++) 70 | { 71 | this._add(lx, ly, lz); 72 | } 73 | } 74 | } 75 | } 76 | 77 | /** 78 | * The private function that actually adds a single point to our structure. 79 | */ 80 | private void _add(int x, int y, int z) 81 | { 82 | if (!this.registry.containsKey(x)) 83 | { 84 | this.registry.put(x, new HashMap>()); 85 | } 86 | HashMap> hm_x = this.registry.get(x); 87 | 88 | if (!hm_x.containsKey(z)) 89 | { 90 | hm_x.put(z, new HashMap()); 91 | } 92 | HashMap hm_z = hm_x.get(z); 93 | 94 | hm_z.put(y, true); 95 | } 96 | 97 | /** 98 | * Checks to see if the given coordinate is in our registry 99 | */ 100 | public boolean check(int x, int y, int z) 101 | { 102 | if (!this.registry.containsKey(x)) 103 | { 104 | return false; 105 | } 106 | HashMap> hm_x = this.registry.get(x); 107 | 108 | if (!hm_x.containsKey(z)) 109 | { 110 | return false; 111 | } 112 | HashMap hm_z = hm_x.get(z); 113 | 114 | if (!hm_z.containsKey(y)) 115 | { 116 | return false; 117 | } 118 | 119 | return true; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | * Figure out transparency rendering glitches, and start using the 2 | transparent leaf texture for trees once that's been figured out. Right 3 | now they look better with the solid texture. In particular, all the 4 | "decorative" blocks like torches, flowers, reed, etc, look weird, as 5 | does water and portals. As it turns out, this is all to do with OpenGL 6 | alpha blending; in addition to a couple quick calls to glDepthMask (see 7 | renderSolid() in Chunk.java), we then need to make sure that all GL 8 | objects are rendered from far-away to near, which will take some doing. 9 | 10 | * Proper rendering support for redstone wire 11 | 12 | * Draw messages on signs like you'd expect. 13 | 14 | * Find a way to eliminate the stuttering when new map chunks are loading 15 | 16 | * Home/End will wipe the minimap and load chunks, even if we're already 17 | "in range" and might even have those chunks cached. Should fix that. 18 | 19 | * Minimap effective size has been cut quite a bit, would like to increase that 20 | 21 | * There are various conditions where the player position and spawn position 22 | markers won't show up properly on the minimap; should fix those. 23 | 24 | * As I've been editing the X-Ray code, I've been using underscore_variables like 25 | that, mostly, instead of the camelCase which was more prevalent. Should really 26 | reformat everything to a single style (and retab the whole thing, and clean up 27 | formatting and style in general). And really, I've been pretty lazy all around 28 | with doing things the "right way." The code could use cleanup in general. Also 29 | I think most of the files are still using DOS line-endings. 30 | 31 | * And, of course, completing the mod support - UI to select extra mod files, etc. 32 | "override" to explicitly override a previously-defined blocktype (this is 33 | technically in there already but completely untested), "version" so that people 34 | could override the builtin blockdef more efficiently, if they want, etc... 35 | 36 | * Technically the minimap colors for a few block types should vary based on the 37 | data value. 38 | 39 | * There's attributes in BlockType which use ArrayList, and I think I'd rather they 40 | just be arrays. Should look into that. 41 | 42 | * Pull the grass colorization color from a point on misc/grasscolor.png 43 | 44 | * Snow has data, as it turns out... Also, it would be nice to have grass+mycelium 45 | react to snow properly (by changing their side image). It seems fairly awkward to 46 | pull off with YAML definitions, though, so we'll just leave it for now. 47 | 48 | * Figure out why loading in nonexistant chunks seems to glitch the app so much 49 | 50 | * Update position information popup in realtime rather than after a delay 51 | 52 | * The resolution-picking dialog has some issues in Java7. One, the dropdowns 53 | seem very sluggish, whereas on previous JDKs they're quite fast. Two (and 54 | possibly relatedly), our hotkeys (enter and escape) only work so long as the 55 | dialog has NEVER actually had the mouse pointer focused on top of it, at 56 | least on my WM. This could potentially have something to do with my 57 | focus-follows-mouse type setup, but it works totally fine in both Java5 and 58 | Java6, so... 59 | 60 | * One of these days I need to just break down and start using some GUI library 61 | like TWL, rather than calling out to AWT windows. Alas. 62 | 63 | * It's entirely possible I should be calling .dispose() on Graphics2D objects 64 | I don't need anymore, and vice-versa. Possibly cut back on memory a bit? 65 | 66 | * Camera presets for bed positions 67 | 68 | * Doors should be rendered "properly" 69 | 70 | * Now that there's region data of some sort in the data files, we should 71 | look into doing some more accurate foliage highlighting. 72 | 73 | * I have never understood why our camera position seems to be the negative 74 | of what it should be. Like where we're storing the player position 'round 75 | line 132 in MinecraftLevel.java, or when we're reading out the camera 76 | position 'round line 2346 in XRay.java (in render()). It makes no sense to 77 | me, but I've been afraid to rip it apart to force it to make more sense. 78 | One of these days... For that matter, it might be a good idea to convert to 79 | using Minecraft's coordinate system, which differs from our own by .5f. In 80 | X-Ray, a block's coordinate (x, z) is found right at the very center of 81 | the block, whereas in Minecraft, it's found at one of the corners. So we're 82 | constantly doing some fudging to report the coordinates in a way that's 83 | consistent with what you get in Minecraft with F3. 84 | 85 | * Now that mobs are much more permanent than they used to be, it might make 86 | sense to have them in X-Ray. Would be nice to be able to highlight Ocelots 87 | hiding around in the jungle, for instance... 88 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/XRayProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.util.Vector; 30 | import java.util.Properties; 31 | import java.util.Enumeration; 32 | import java.util.Collections; 33 | 34 | /** 35 | * Class to provide a sorted properties list in our config file, 36 | * with a couple of extra functions that I want. 37 | * 38 | * The sorting functionality in here taken from 39 | * http://www.rgagnon.com/javadetails/java-0614.html 40 | */ 41 | public class XRayProperties extends Properties 42 | { 43 | 44 | // Added at the behest of Eclipse (or, well, presumably Java itself) 45 | private static final long serialVersionUID = 2578311914423692774L; 46 | 47 | /** 48 | * Overrides, called by the store method. 49 | */ 50 | @SuppressWarnings({ "unchecked", "rawtypes" }) 51 | public synchronized Enumeration keys() 52 | { 53 | Enumeration keysEnum = super.keys(); 54 | Vector keyList = new Vector(); 55 | while (keysEnum.hasMoreElements()) 56 | { 57 | keyList.add(keysEnum.nextElement()); 58 | } 59 | Collections.sort(keyList); 60 | return keyList.elements(); 61 | } 62 | 63 | /** 64 | * Reads a boolean property, with the given default value 65 | * in case it's not found. 66 | */ 67 | public boolean getBooleanProperty(String keyName, boolean defaultValue) 68 | { 69 | String propValue = this.getProperty(keyName); 70 | if (propValue != null && propValue.length() > 0) 71 | { 72 | String propLetter = propValue.substring(0, 1); 73 | return (propLetter.equalsIgnoreCase("y") || 74 | propLetter.equalsIgnoreCase("t") || 75 | propLetter.equals("1")); 76 | } 77 | else 78 | { 79 | return defaultValue; 80 | } 81 | } 82 | 83 | /** 84 | * Sets a boolean property. Basically just translates a 85 | * boolean to "1" or "0" 86 | */ 87 | public void setBooleanProperty(String keyName, boolean propValue) 88 | { 89 | if (propValue) 90 | { 91 | this.setProperty(keyName, "1"); 92 | } 93 | else 94 | { 95 | this.setProperty(keyName, "0"); 96 | } 97 | } 98 | 99 | /** 100 | * Gets an integer property, with a default vaule if it's not found. 101 | */ 102 | public int getIntProperty(String propName, int defaultValue) 103 | { 104 | String val = this.getProperty(propName); 105 | if (val == null) 106 | { 107 | return defaultValue; 108 | } 109 | else 110 | { 111 | return Integer.valueOf(val); 112 | } 113 | } 114 | 115 | /** 116 | * Sets an integer property (basically just wraps Integer.toString() 117 | */ 118 | public void setIntProperty(String propName, int propVal) 119 | { 120 | this.setProperty(propName, Integer.toString(propVal)); 121 | } 122 | 123 | /** 124 | * Gets a float property, with a default value if it's not found. 125 | */ 126 | public float getFloatProperty(String propName, float defaultValue) 127 | { 128 | String val = this.getProperty(propName); 129 | if (val == null) 130 | { 131 | return defaultValue; 132 | } 133 | else 134 | { 135 | return Float.valueOf(val); 136 | } 137 | } 138 | 139 | /** 140 | * Sets a float property (basically just wraps Float.toString() 141 | */ 142 | public void setFloatProperty(String propName, float propVal) 143 | { 144 | this.setProperty(propName, Float.toString(propVal)); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/FirstPersonCameraController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import org.lwjgl.opengl.GL11; 30 | import org.lwjgl.util.vector.Vector3f; 31 | 32 | 33 | /*** 34 | * Utility class which mimicks a first person shooters camera perspective 35 | * @author Vincent 36 | */ 37 | public class FirstPersonCameraController { 38 | private Vector3f position = null; 39 | private float yaw = 0.0f; 40 | private float pitch = 0.0f; 41 | 42 | /*** 43 | * Create a camera at location x,y,z facing down the z axis 44 | * @param x 45 | * @param y 46 | * @param z 47 | */ 48 | public FirstPersonCameraController(float x, float y, float z) 49 | { 50 | //instantiate position Vector3f to the x y z params. 51 | position = new Vector3f(x, y, z); 52 | } 53 | 54 | //increment the camera's current yaw rotation 55 | public void incYaw(float amount) 56 | { 57 | yaw += amount; 58 | } 59 | 60 | public float getYaw() { 61 | return this.yaw; 62 | } 63 | 64 | //increment the camera's current yaw rotation 65 | public void incPitch(float amount) 66 | { 67 | pitch += amount; 68 | } 69 | 70 | public float getPitch() { 71 | return this.pitch; 72 | } 73 | 74 | 75 | public void walkForward(float distance, boolean camera_lock) 76 | { 77 | position.x -= distance * (float)Math.sin(Math.toRadians(yaw)); 78 | position.z += distance * (float)Math.cos(Math.toRadians(yaw)); 79 | if (!camera_lock) 80 | { 81 | position.y += distance * (float)Math.sin(Math.toRadians(pitch)); 82 | } 83 | } 84 | 85 | 86 | public void walkBackwards(float distance, boolean camera_lock) 87 | { 88 | position.x += distance * (float)Math.sin(Math.toRadians(yaw)); 89 | position.z -= distance * (float)Math.cos(Math.toRadians(yaw)); 90 | if (!camera_lock) 91 | { 92 | position.y -= distance * (float)Math.sin(Math.toRadians(pitch)); 93 | } 94 | } 95 | 96 | public void strafeLeft(float distance) 97 | { 98 | position.x -= distance * (float)Math.sin(Math.toRadians(yaw-90)); 99 | position.z += distance * (float)Math.cos(Math.toRadians(yaw-90)); 100 | } 101 | 102 | public void strafeRight(float distance) 103 | { 104 | position.x -= distance * (float)Math.sin(Math.toRadians(yaw+90)); 105 | position.z += distance * (float)Math.cos(Math.toRadians(yaw+90)); 106 | } 107 | 108 | public void moveUp(float distance) { 109 | position.y -= distance; 110 | } 111 | 112 | public void applyCameraTransformation() 113 | { 114 | //roatate the pitch around the X axis 115 | GL11.glRotatef(pitch, 1.0f, 0.0f, 0.0f); 116 | //roatate the yaw around the Y axis 117 | GL11.glRotatef(yaw, 0.0f, 1.0f, 0.0f); 118 | //translate to the position vector's location 119 | GL11.glTranslatef(position.x, position.y, position.z); 120 | } 121 | 122 | public Vector3f getPosition() { 123 | return this.position; 124 | } 125 | 126 | public void setYawAndPitch(float yaw, float pitch) { 127 | this.yaw = yaw; 128 | this.pitch = pitch; 129 | } 130 | 131 | /** 132 | * Processes the given Nether warp factor (should generally be 8.0f or 133 | * 1/8.0f, depending on the direction we're headed). 134 | * 135 | * @param multiplier 136 | */ 137 | public void processNetherWarp(float multiplier) 138 | { 139 | this.position.x *= multiplier; 140 | this.position.z *= multiplier; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/BlockTypeRegular.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.util.Map; 30 | import java.util.HashMap; 31 | import java.util.ArrayList; 32 | import java.awt.Color; 33 | 34 | import static com.apocalyptech.minecraft.xray.MinecraftConstants.*; 35 | 36 | /** 37 | */ 38 | public class BlockTypeRegular extends BlockType 39 | { 40 | 41 | // YAML Attributes 42 | private ArrayList tex; 43 | private HashMap> tex_data; 44 | private HashMap> tex_direction; 45 | private HashMap> tex_extra; 46 | 47 | // Other attributes 48 | private boolean generated_texture; 49 | 50 | public BlockTypeRegular() 51 | { 52 | super(); 53 | this.generated_texture = false; 54 | } 55 | 56 | public void setTex(ArrayList tex) 57 | { 58 | this.tex = tex; 59 | } 60 | 61 | public ArrayList getTex() 62 | { 63 | return this.tex; 64 | } 65 | 66 | public void setTexReal(int tex) 67 | { 68 | this.setTex(BlockType.getTexCoords(tex)); 69 | } 70 | 71 | public int getTexReal() 72 | { 73 | return getTexReal(this.getTex()); 74 | } 75 | 76 | public void setTex_data(HashMap> tex_data) 77 | { 78 | this.tex_data = tex_data; 79 | } 80 | 81 | public HashMap> getTex_data() 82 | { 83 | return this.tex_data; 84 | } 85 | 86 | public void setTex_direction(HashMap> tex_direction) 87 | { 88 | this.tex_direction = tex_direction; 89 | } 90 | 91 | public HashMap> getTex_direction() 92 | { 93 | return this.tex_direction; 94 | } 95 | 96 | public void setTex_extra(HashMap> tex_extra) 97 | { 98 | this.tex_extra = tex_extra; 99 | } 100 | 101 | public HashMap> getTex_extra() 102 | { 103 | return this.tex_extra; 104 | } 105 | 106 | /** 107 | * Normalizes our data from what we get from YAML, to a format that's 108 | * easier to deal with in X-Ray. 109 | */ 110 | public void normalizeData() 111 | throws BlockTypeLoadException 112 | { 113 | // First call our parent 114 | super.normalizeData(); 115 | 116 | // Now check for some required attributes 117 | if (this.tex == null) 118 | { 119 | if (this.idStr.equals("WATER") || this.idStr.equals("STATIONARY_WATER") || 120 | this.idStr.equals("FIRE") || this.idStr.equals("PORTAL") || 121 | this.idStr.equals("END_PORTAL")) 122 | { 123 | this.generated_texture = true; 124 | } 125 | else 126 | { 127 | throw new BlockTypeLoadException("tex is a required attribute"); 128 | } 129 | } 130 | else if (this.tex.size() != 2) 131 | { 132 | throw new BlockTypeLoadException("tex coordinates require two elements (X, Y)"); 133 | } 134 | 135 | // Now do the actual normalizing 136 | if (!this.generated_texture) 137 | { 138 | this.tex_idx = this.getTexReal(); 139 | } 140 | 141 | if (this.tex_data != null && this.tex_data.size() > 0) 142 | { 143 | this.texture_data_map = new HashMap(); 144 | for (Map.Entry> entry : this.tex_data.entrySet()) 145 | { 146 | this.texture_data_map.put(entry.getKey().byteValue(), BlockType.getTexReal(entry.getValue())); 147 | } 148 | } 149 | if (this.tex_direction != null) 150 | { 151 | this.texture_dir_map = new HashMap(); 152 | for (Map.Entry> entry: this.tex_direction.entrySet()) 153 | { 154 | DIRECTION_REL dir; 155 | try 156 | { 157 | dir = DIRECTION_REL.valueOf(entry.getKey()); 158 | } 159 | catch (IllegalArgumentException e) 160 | { 161 | throw new BlockTypeLoadException("Invalid relative direction: " + entry.getKey()); 162 | } 163 | this.texture_dir_map.put(dir, BlockType.getTexReal(entry.getValue())); 164 | } 165 | } 166 | if (this.tex_extra != null) 167 | { 168 | this.texture_extra_map = new HashMap(); 169 | for (Map.Entry> entry : this.tex_extra.entrySet()) 170 | { 171 | this.texture_extra_map.put(entry.getKey(), BlockType.getTexReal(entry.getValue())); 172 | } 173 | } 174 | } 175 | 176 | } 177 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/TextureDecorationStats.java: -------------------------------------------------------------------------------- 1 | /** * Copyright (c) 2010-2012, Christopher J. Kucera 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of the Minecraft X-Ray team nor the 12 | * names of its contributors may be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | package com.apocalyptech.minecraft.xray; 27 | 28 | import java.awt.image.BufferedImage; 29 | 30 | public class TextureDecorationStats 31 | { 32 | private int top; 33 | private int bottom; 34 | private int left; 35 | private int right; 36 | 37 | private float top_f; 38 | private float bottom_f; 39 | private float left_f; 40 | private float right_f; 41 | private float width_f; 42 | private float height_f; 43 | 44 | private float top_tex_f; 45 | private float bottom_tex_f; 46 | private float left_tex_f; 47 | private float right_tex_f; 48 | private float width_tex_f; 49 | private float height_tex_f; 50 | 51 | public TextureDecorationStats(Texture textureData, int textureId) 52 | { 53 | int x; 54 | int y; 55 | int a; 56 | int row = textureId % 16; 57 | int col = textureId / 16; 58 | BufferedImage bi = textureData.getImage(); 59 | int square_width = bi.getWidth()/16; 60 | int[] pixels = new int[square_width*square_width]; 61 | bi.getRGB(row*square_width, col*square_width, square_width, square_width, pixels, 0, square_width); 62 | 63 | // Alpha threshhold that we'll test against 64 | int threshhold = 20; 65 | 66 | // Now that we have the necessary pixel information, figure out what the actual 67 | // bounds are. First top 68 | this.top = 0; 69 | mainloop: for (y=0; y threshhold) 74 | { 75 | this.top = y; 76 | break mainloop; 77 | } 78 | } 79 | } 80 | 81 | // Now bottom 82 | this.bottom = square_width-1; 83 | mainloop: for (y=square_width-1; y>=0; y--) 84 | { 85 | for (x=0; x threshhold) 88 | { 89 | this.bottom = y; 90 | break mainloop; 91 | } 92 | } 93 | } 94 | 95 | // Now left 96 | this.left = 0; 97 | mainloop: for (x=0; x threshhold) 102 | { 103 | this.left = x; 104 | break mainloop; 105 | } 106 | } 107 | } 108 | 109 | // Now right 110 | this.right = square_width-1; 111 | mainloop: for (x=square_width-1; x>=0; x--) 112 | { 113 | for (y=0; y threshhold) 116 | { 117 | this.right = x; 118 | break mainloop; 119 | } 120 | } 121 | } 122 | 123 | // Now compute the float values 124 | this.top_f = (float)this.top/(float)square_width; 125 | this.bottom_f = (float)this.bottom/(float)square_width; 126 | this.left_f = (float)this.left/(float)square_width; 127 | this.right_f = (float)this.right/(float)square_width; 128 | this.width_f = (float)(this.right+1-this.left)/(float)square_width; 129 | this.height_f = (float)(this.bottom+1-this.top)/(float)square_width; 130 | 131 | this.top_tex_f = (float)this.top/(float)bi.getHeight(); 132 | this.bottom_tex_f = (float)this.bottom/(float)bi.getHeight(); 133 | this.left_tex_f = (float)this.left/(float)bi.getWidth(); 134 | this.right_tex_f = (float)this.right/(float)bi.getWidth(); 135 | this.width_tex_f = (float)(this.right+1-this.left)/(float)bi.getWidth(); 136 | this.height_tex_f = (float)(this.bottom+1-this.top)/(float)bi.getHeight(); 137 | } 138 | 139 | /** 140 | * Gets the alpha value for a given pixel in an array. 141 | */ 142 | private static int getAlpha(int[] pixels, int width, int x, int y) 143 | { 144 | return pixels[y*width + x] >>> 24; 145 | } 146 | 147 | public float getTop() 148 | { 149 | return this.top_f; 150 | } 151 | 152 | public float getBottom() 153 | { 154 | return this.bottom_f; 155 | } 156 | 157 | public float getLeft() 158 | { 159 | return this.left_f; 160 | } 161 | 162 | public float getRight() 163 | { 164 | return this.right_f; 165 | } 166 | 167 | public float getWidth() 168 | { 169 | return this.width_f; 170 | } 171 | 172 | public float getHeight() 173 | { 174 | return this.height_f; 175 | } 176 | 177 | public float getTexTop() 178 | { 179 | return this.top_tex_f; 180 | } 181 | 182 | public float getTexBottom() 183 | { 184 | return this.bottom_tex_f; 185 | } 186 | 187 | public float getTexLeft() 188 | { 189 | return this.left_tex_f; 190 | } 191 | 192 | public float getTexRight() 193 | { 194 | return this.right_tex_f; 195 | } 196 | 197 | public float getTexWidth() 198 | { 199 | return this.width_tex_f; 200 | } 201 | 202 | public float getTexHeight() 203 | { 204 | return this.height_tex_f; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dtf/DTFReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dtf; 28 | 29 | import java.io.DataInputStream; 30 | import java.io.File; 31 | import java.io.FileInputStream; 32 | import java.io.FileNotFoundException; 33 | import java.io.IOException; 34 | import java.util.ArrayList; 35 | import java.util.zip.GZIPInputStream; 36 | 37 | import com.apocalyptech.minecraft.xray.XRay; 38 | 39 | public class DTFReader { 40 | public static Tag readTag(byte tagType, String name, DataInputStream stream) throws IOException { 41 | short twofiftysix = 256; 42 | int len; 43 | switch(tagType) { 44 | case 0: // end 45 | return new EndTag(); 46 | case 1: 47 | return new ByteTag(name, stream.readByte()); 48 | case 2: 49 | return new ShortTag(name, stream.readShort()); 50 | case 3: 51 | return new IntTag(name, stream.readInt()); 52 | case 4: 53 | return new LongTag(name, stream.readLong()); 54 | case 5: 55 | return new FloatTag(name, stream.readFloat()); 56 | case 6: 57 | return new DoubleTag(name, stream.readDouble()); 58 | case 7: 59 | len = stream.readInt(); 60 | 61 | // This little hack is so that we store our block types as shorts, rather than 62 | // bytes, so that we can more easily support blocks with IDs greater than 127. 63 | // Because of Java's lack of unsigned data types, it's either this, or doing 64 | // extra processing while rendering, and I figure we can afford the extra 65 | // memory footprint. Each chunk will consume an extra 32K because of this, 66 | // and if we're rendering the full 8x8 chunk range, that's still only an 67 | // extra 2MB total memory. Not too bad. 68 | // 69 | // Note too that using DataInputStream.readUnsignedByte() for each value is 70 | // quite noticeably slower than just using readFully(), whereas using 71 | // readFully() and then doing the conversion ourself seems to be not really 72 | // noticeable. 73 | if (name.equals("Blocks")) 74 | { 75 | short[] data = new short[len]; 76 | byte[] bdata = new byte[len]; 77 | stream.readFully(bdata); 78 | for (int i=0; i list = new ArrayList(); 105 | for(int i=0;i compound = new ArrayList(); 112 | while((type = stream.readByte()) != 0) { 113 | String tagName = stream.readUTF(); 114 | Tag tag = readTag(type, tagName, stream); 115 | compound.add(tag); 116 | } 117 | return new CompoundTag(name, compound); 118 | case 11: 119 | len = stream.readInt(); 120 | int[] data = new int[len]; 121 | // This may not be the fastest way to do this... 122 | for (int i=0; i 0) { 144 | byte type = stream.readByte(); 145 | if(type != 0){ 146 | String name = stream.readUTF(); 147 | Tag t = readTag(type, name, stream); 148 | stream.close(); 149 | return t; 150 | } 151 | } 152 | stream.close(); 153 | return null; 154 | } 155 | 156 | public static Tag readDTFFile(File f) { 157 | try { 158 | DataInputStream stream = new DataInputStream(new GZIPInputStream(new FileInputStream(f))); 159 | 160 | return readTagData(stream); 161 | } catch (FileNotFoundException e) { 162 | // TODO Auto-generated catch block" 163 | XRay.logger.error("Error reading " + f.getPath() + " -"); 164 | e.printStackTrace(); 165 | } catch (IOException e) { 166 | // TODO Auto-generated catch block 167 | XRay.logger.error("Error reading " + f.getPath() + " -"); 168 | e.printStackTrace(); 169 | } 170 | return null; 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dialog/KeyPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dialog; 28 | 29 | import com.apocalyptech.minecraft.xray.XRay; 30 | import static com.apocalyptech.minecraft.xray.MinecraftConstants.*; 31 | 32 | import java.awt.Font; 33 | import java.awt.Insets; 34 | import java.awt.FlowLayout; 35 | import java.awt.event.ActionEvent; 36 | import java.awt.event.ActionListener; 37 | 38 | import javax.swing.JLabel; 39 | import javax.swing.JPanel; 40 | import javax.swing.JButton; 41 | 42 | import org.lwjgl.input.Keyboard; 43 | 44 | /** 45 | * This is a custom JPanel for our key-binding dialog. It consists of four 46 | * elements: a JLabel for the key, an "edit" box for the key, and two JLabels for 47 | * "before" and "after" informational text. By default, only the labels are 48 | * shown, but the panel can be switched from display to edit (and vice versa) at 49 | * will. 50 | */ 51 | public class KeyPanel extends JPanel 52 | { 53 | private String beforeStr; 54 | private String keyStr; 55 | private String afterStr; 56 | 57 | private KeyHelpDialog kh; 58 | 59 | private KEY_ACTION action; 60 | private int bound_key; 61 | 62 | private JLabel beforeLabel; 63 | private JLabel afterLabel; 64 | private JLabel keyLabel; 65 | private KeyField keyEdit; 66 | private JLabel unbindSpacer; 67 | private JButton unbindButton; 68 | 69 | /** 70 | * Create a new KeyPanel 71 | * @param kh Our master dialog 72 | * @param action The action this KeyPanel represents 73 | * @param bound_key The currently-bound key 74 | */ 75 | public KeyPanel(KeyHelpDialog kh, Font keyFont, Font buttonFont, KEY_ACTION action, int bound_key) 76 | { 77 | super(); 78 | this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 79 | this.kh = kh; 80 | this.action = action; 81 | 82 | this.beforeLabel = new JLabel(); 83 | this.beforeLabel.setFont(keyFont); 84 | this.afterLabel = new JLabel(); 85 | this.afterLabel.setFont(keyFont); 86 | this.keyLabel = new JLabel(); 87 | this.keyLabel.setFont(keyFont); 88 | this.keyEdit = new KeyField(action, this); 89 | this.unbindSpacer = new JLabel(" "); 90 | this.unbindSpacer.setFont(keyFont); 91 | this.unbindButton = new JButton("Unbind"); 92 | this.unbindButton.setFont(buttonFont); 93 | this.unbindButton.setMargin(new Insets(0, 5, 0, 5)); 94 | this.unbindButton.addActionListener(new ActionListener() { 95 | public void actionPerformed(ActionEvent e) { 96 | notifyUnbindClicked(); 97 | } 98 | }); 99 | 100 | this.add(this.beforeLabel); 101 | this.add(this.keyLabel); 102 | this.add(this.keyEdit); 103 | this.add(this.afterLabel); 104 | this.add(this.unbindSpacer); 105 | this.add(this.unbindButton); 106 | 107 | this.setBoundKey(bound_key); 108 | this.finishEdit(); 109 | } 110 | 111 | /** 112 | * Sets a new bound key for this panel. Will update all the labels, etc. 113 | * @param bound_key The new bound key 114 | */ 115 | public void setBoundKey(int bound_key) 116 | { 117 | this.bound_key = bound_key; 118 | this.keyStr = getKeyEnglish(this.action, bound_key); 119 | this.beforeStr = getKeyExtraBefore(this.action, bound_key); 120 | this.afterStr = getKeyExtraAfter(this.action, bound_key); 121 | 122 | this.beforeLabel.setText(this.beforeStr); 123 | this.afterLabel.setText(this.afterStr); 124 | this.keyLabel.setText(this.keyStr); 125 | this.keyEdit.setText(this.keyStr); 126 | } 127 | 128 | /** 129 | * Get the action this Panel represents 130 | * @return The action 131 | */ 132 | public KEY_ACTION getAction() 133 | { 134 | return this.action; 135 | } 136 | 137 | /** 138 | * Get the currently-bound key for the Panel 139 | * @return The LWJGL key ID 140 | */ 141 | public int getBoundKey() 142 | { 143 | return this.bound_key; 144 | } 145 | 146 | /** 147 | * Called when our "Unbind" button is clicked. Report back up 148 | * to our master dialog to process. 149 | */ 150 | public void notifyUnbindClicked() 151 | { 152 | this.kh.notifyUnbindClicked(this); 153 | } 154 | 155 | /** 156 | * Called from our inner KeyField, this is how we 157 | * receive notification that we've been clicked. Passes that 158 | * information back up to the master dialog 159 | */ 160 | public void notifyClicked() 161 | { 162 | this.kh.notifyKeyPanelClicked(this); 163 | this.unbindButton.setVisible(true); 164 | this.unbindSpacer.setVisible(true); 165 | } 166 | 167 | /** 168 | * Called from the master dialog, a notification that we are no 169 | * longer the actively-clicked Panel. 170 | */ 171 | public void clickFinish() 172 | { 173 | this.unbindButton.setVisible(false); 174 | this.unbindSpacer.setVisible(false); 175 | this.keyEdit.clickFinish(); 176 | } 177 | 178 | /** 179 | * Called to move the Panel into "edit" mode 180 | */ 181 | public void startEdit() 182 | { 183 | this.keyLabel.setVisible(false); 184 | this.keyEdit.setVisible(true); 185 | this.afterLabel.setVisible(false); 186 | this.unbindButton.setVisible(false); 187 | this.unbindSpacer.setVisible(false); 188 | } 189 | 190 | /** 191 | * Called to move the Panel back into "display" mode 192 | */ 193 | public void finishEdit() 194 | { 195 | this.keyEdit.setVisible(false); 196 | this.keyLabel.setVisible(true); 197 | this.afterLabel.setVisible(true); 198 | this.unbindButton.setVisible(false); 199 | this.unbindSpacer.setVisible(false); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/SpriteTool.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import org.lwjgl.opengl.GL11; 30 | 31 | 32 | /** 33 | * @author Vincent Vollers 34 | * 35 | * Some tools to draw very simple unoptimized sprites (ortho (2D) mode) 36 | */ 37 | public class SpriteTool { 38 | /*** 39 | * Draw a sprite starting at x,y 40 | * @param texture 41 | * @param x 42 | * @param y 43 | */ 44 | public static void drawSpriteAbsoluteXY(Texture texture, float x, float y) { 45 | //manager.bindTexture(spriteName); 46 | //XRay.logger.debug(texture.getImage().getWidth() + " " + texture.getImage().getHeight()); 47 | 48 | int width = texture.getImage().getWidth(); 49 | int height = texture.getImage().getHeight(); 50 | texture.bind(); 51 | GL11.glPushMatrix(); 52 | GL11.glTranslatef(x, y, 0.0f); 53 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 54 | 55 | GL11.glTexCoord2f(0, 0); 56 | GL11.glVertex2f(0, 0); 57 | 58 | GL11.glTexCoord2f(1, 0); 59 | GL11.glVertex2f(width, 0); 60 | 61 | GL11.glTexCoord2f(0, 1); 62 | GL11.glVertex2f(0, height); 63 | 64 | GL11.glTexCoord2f(1, 1); 65 | GL11.glVertex2f(width, height); 66 | 67 | GL11.glEnd(); 68 | GL11.glPopMatrix(); 69 | } 70 | 71 | public static void drawCurrentSprite(float x, float y, float width, float height, float startTexX, float startTexY, float endTexX, float endTexY) { 72 | GL11.glPushMatrix(); 73 | GL11.glTranslatef(x, y, 0.0f); 74 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 75 | 76 | GL11.glTexCoord2f(startTexX, startTexY); 77 | GL11.glVertex2f(0, 0); 78 | 79 | GL11.glTexCoord2f(endTexX, startTexY); 80 | GL11.glVertex2f(width, 0); 81 | 82 | GL11.glTexCoord2f(startTexX, endTexY); 83 | GL11.glVertex2f(0, height); 84 | 85 | GL11.glTexCoord2f(endTexX, endTexY); 86 | GL11.glVertex2f(width, height); 87 | 88 | GL11.glEnd(); 89 | GL11.glPopMatrix(); 90 | } 91 | 92 | /*** 93 | * Draw a sprite with the center of the sprite at x,y 94 | * @param frame 95 | * @param x 96 | * @param y 97 | */ 98 | public static void drawSprite(Texture frame, float x, float y) { 99 | float halfWidth = frame.getImage().getWidth() / 2.0f; 100 | float halfHeight = frame.getImage().getHeight() / 2.0f; 101 | 102 | frame.bind(); 103 | GL11.glPushMatrix(); 104 | GL11.glTranslatef(x, y, 0.0f); 105 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 106 | 107 | GL11.glTexCoord2f(0, 0); 108 | GL11.glVertex2f(-halfWidth, -halfHeight); 109 | 110 | GL11.glTexCoord2f(1, 0); 111 | GL11.glVertex2f(halfWidth, -halfHeight); 112 | 113 | GL11.glTexCoord2f(0, 1); 114 | GL11.glVertex2f(-halfWidth, halfHeight); 115 | 116 | GL11.glTexCoord2f(1, 1); 117 | GL11.glVertex2f(halfWidth, halfHeight); 118 | GL11.glEnd(); 119 | GL11.glPopMatrix(); 120 | } 121 | 122 | /*** 123 | * Draw a sprite with its center at x,y and rotate it 124 | * @param frame 125 | * @param x 126 | * @param y 127 | * @param rotation 128 | */ 129 | public static void drawSpriteAndRotate(Texture frame, float x, float y, 130 | float rotation) { 131 | float halfWidth = frame.getImage().getWidth() / 2.0f; 132 | float halfHeight = frame.getImage().getHeight() / 2.0f; 133 | 134 | rotation = (rotation + 90.0f) % 360.0f; 135 | 136 | frame.bind(); 137 | GL11.glPushMatrix(); 138 | GL11.glTranslatef(x, y, 0.0f); 139 | GL11.glRotatef(rotation, 0, 0, 1); 140 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 141 | 142 | GL11.glTexCoord2f(0, 0); 143 | GL11.glVertex2f(-halfWidth, -halfHeight); 144 | 145 | GL11.glTexCoord2f(1, 0); 146 | GL11.glVertex2f(halfWidth, -halfHeight); 147 | 148 | GL11.glTexCoord2f(0, 1); 149 | GL11.glVertex2f(-halfWidth, halfHeight); 150 | 151 | GL11.glTexCoord2f(1, 1); 152 | GL11.glVertex2f(halfWidth, halfHeight); 153 | GL11.glEnd(); 154 | GL11.glPopMatrix(); 155 | } 156 | 157 | /*** 158 | * Draw a sprite with its center at x,y and scale it 159 | * @param frame 160 | * @param x 161 | * @param y 162 | * @param scale 163 | */ 164 | public static void drawSpriteAndScale(Texture frame, float x, float y, float scale) { 165 | float halfWidth = frame.getImage().getWidth() / 2.0f; 166 | float halfHeight = frame.getImage().getHeight() / 2.0f; 167 | 168 | frame.bind(); 169 | GL11.glPushMatrix(); 170 | GL11.glTranslatef(x, y, 0.0f); 171 | GL11.glScalef(scale, scale, 1.0f); 172 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 173 | 174 | GL11.glTexCoord2f(0, 0); 175 | GL11.glVertex2f(-halfWidth, -halfHeight); 176 | 177 | GL11.glTexCoord2f(1, 0); 178 | GL11.glVertex2f(halfWidth, -halfHeight); 179 | 180 | GL11.glTexCoord2f(0, 1); 181 | GL11.glVertex2f(-halfWidth, halfHeight); 182 | 183 | GL11.glTexCoord2f(1, 1); 184 | GL11.glVertex2f(halfWidth, halfHeight); 185 | GL11.glEnd(); 186 | GL11.glPopMatrix(); 187 | } 188 | 189 | /*** 190 | * Draw a sprite with its center at x,y and scale and rotate it 191 | * @param frame 192 | * @param x 193 | * @param y 194 | * @param scale 195 | */ 196 | public static void drawSpriteAndRotateAndScale(Texture frame, float x, 197 | float y, float rotation, float scale) { 198 | float halfWidth = frame.getImage().getWidth() / 2.0f; 199 | float halfHeight = frame.getImage().getHeight() / 2.0f; 200 | 201 | rotation = (rotation + 90.0f) % 360.0f; 202 | 203 | frame.bind(); 204 | GL11.glPushMatrix(); 205 | GL11.glTranslatef(x, y, 0.0f); 206 | GL11.glRotatef(rotation, 0, 0, 1.0f); 207 | GL11.glScalef(scale, scale, 1.0f); 208 | GL11.glBegin(GL11.GL_TRIANGLE_STRIP); 209 | 210 | GL11.glTexCoord2f(0, 0); 211 | GL11.glVertex2f(-halfWidth, -halfHeight); 212 | 213 | GL11.glTexCoord2f(1, 0); 214 | GL11.glVertex2f(halfWidth, -halfHeight); 215 | 216 | GL11.glTexCoord2f(0, 1); 217 | GL11.glVertex2f(-halfWidth, halfHeight); 218 | 219 | GL11.glTexCoord2f(1, 1); 220 | GL11.glVertex2f(halfWidth, halfHeight); 221 | GL11.glEnd(); 222 | GL11.glPopMatrix(); 223 | } 224 | 225 | } 226 | -------------------------------------------------------------------------------- /COPYING-snakeyaml.txt: -------------------------------------------------------------------------------- 1 | http://www.apache.org/licenses/LICENSE-2.0 2 | 3 | Apache License 4 | 5 | Version 2.0, January 2004 6 | 7 | http://www.apache.org/licenses/ 8 | 9 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 10 | 11 | 1. Definitions. 12 | 13 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 14 | 15 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 18 | 19 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 20 | 21 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 22 | 23 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 24 | 25 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 26 | 27 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 28 | 29 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 30 | 31 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 32 | 33 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 34 | 35 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 36 | 37 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 38 | 39 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 40 | 41 | You must cause any modified files to carry prominent notices stating that You changed the files; and 42 | 43 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 44 | 45 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 46 | 47 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 48 | 49 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 50 | 51 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 52 | 53 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 54 | 55 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 56 | 57 | END OF TERMS AND CONDITIONS 58 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/RegionFileCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2011 January 5 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | */ 11 | 12 | /* 13 | * 2011 February 16 14 | * 15 | * This source code is based on the work of Scaevolus (see notice above). 16 | * It has been slightly modified by Mojang AB to limit the maximum cache 17 | * size (relevant to extremely big worlds on Linux systems with limited 18 | * number of file handles). The region files are postfixed with ".mcr" 19 | * (Minecraft region file) instead of ".data" to differentiate from the 20 | * original McRegion files. 21 | * 22 | */ 23 | 24 | /* 25 | * 2011 February 20 26 | * 27 | * Imported by CJ Kucera into X-Ray, from a blog post by Jens Bergensten 28 | * at: http://mojang.com/2011/02/16/minecraft-save-file-format-in-beta-1-3/ 29 | * 30 | * Plus further changes - just see git history to see 'em, if you care. :) 31 | */ 32 | 33 | // A simple cache and wrapper for efficiently multiple RegionFiles simultaneously. 34 | package com.apocalyptech.minecraft.xray; 35 | 36 | import java.io.*; 37 | import java.lang.Math; 38 | import java.lang.Double; 39 | import java.lang.ref.*; 40 | import java.util.*; 41 | import java.util.regex.Pattern; 42 | import java.util.regex.Matcher; 43 | 44 | public class RegionFileCache { 45 | 46 | private static final int MAX_CACHE_SIZE = 256; 47 | 48 | 49 | private static final Map> cache = new HashMap>(); 50 | private static final HashMap> availableCache = new HashMap>(); 51 | 52 | private RegionFileCache() { 53 | } 54 | 55 | /** 56 | * Returns the integer chunk coordinates of the nearest chunk for which we have data, 57 | * from (x, z). 58 | * 59 | * @param world the world path we're looking at 60 | * @param chunkX The current chunk X coordinate of the camera 61 | * @param chunkZ The current chunk Z coordinate of the camera 62 | * @return an IntegerPair describing the chunk coordinates 63 | */ 64 | public static synchronized IntegerPair getClosestRegion(WorldInfo world, int chunkX, int chunkZ) 65 | { 66 | String basePath = world.getBasePath(); 67 | ArrayList available; 68 | if (availableCache.containsKey(basePath)) 69 | { 70 | available = availableCache.get(basePath); 71 | } 72 | else 73 | { 74 | available = new ArrayList(); 75 | availableCache.put(basePath, available); 76 | 77 | File base = new File(basePath, "region"); 78 | File[] regions = base.listFiles(new RegionFileFilter(world)); 79 | Pattern pattern = Pattern.compile(RegionFileFilter.match_regex); 80 | 81 | for (File region : regions) 82 | { 83 | // Note that there seem to be some circumstances where Minecraft will write out an empty 84 | // RegionFile here, so we're going to check on filesize as well. Theoretically an 85 | // empty RegionFile would be 4096 bytes, but the ones that Minecraft writes out are actually 86 | // 8192 for some reason (entirely with null values). Since it's pretty unlikely that we'd 87 | // have a region with only a single chunk (and equally unlikely that it would really make 88 | // that much of a difference even if there were), we're going to discard any regionfile 89 | // which is 8192 bytes or smaller. 90 | if (region.length() <= 8192) 91 | { 92 | continue; 93 | } 94 | 95 | // Continue on... 96 | Matcher matcher = pattern.matcher(region.getName()); 97 | if (matcher.matches()) 98 | { 99 | available.add( 100 | new IntegerPair( 101 | Integer.parseInt(matcher.group(1)), 102 | Integer.parseInt(matcher.group(2)) 103 | ) 104 | ); 105 | } 106 | else 107 | { 108 | XRay.logger.error("Could not match region coordinates for " + region.getName()); 109 | } 110 | } 111 | } 112 | 113 | // Loop through our available regions to find the closest 114 | int curRegionX = (chunkX >> 5); 115 | int curRegionZ = (chunkZ >> 5); 116 | IntegerPair closestPair = null; 117 | double closestDistance = Double.MAX_VALUE; 118 | boolean found = false; 119 | for (IntegerPair pair : available) 120 | { 121 | if (pair.getValueOne() == curRegionX && pair.getValueTwo() == curRegionZ) 122 | { 123 | XRay.logger.trace("Our current region is present, jumping internally"); 124 | closestPair = pair; 125 | break; 126 | } 127 | else 128 | { 129 | int dist_one; 130 | int dist_two; 131 | if (pair.getValueOne() > curRegionX) 132 | { 133 | dist_one = Math.abs(pair.getValueOne() - curRegionX); 134 | } 135 | else 136 | { 137 | dist_one = Math.abs(curRegionX - pair.getValueOne()); 138 | } 139 | if (pair.getValueTwo() > curRegionZ) 140 | { 141 | dist_two = Math.abs(pair.getValueTwo() - curRegionZ); 142 | } 143 | else 144 | { 145 | dist_two = Math.abs(curRegionZ - pair.getValueTwo()); 146 | } 147 | double thisDistance = Math.sqrt(Math.pow(dist_one, 2) + Math.pow(dist_two, 2)); 148 | if (!found || thisDistance < closestDistance) 149 | { 150 | found = true; 151 | closestDistance = thisDistance; 152 | closestPair = pair; 153 | } 154 | } 155 | } 156 | 157 | // Now compute the chunk coordinates we should actually jump to 158 | if (closestPair == null) 159 | { 160 | XRay.logger.debug("No regions found to jump to"); 161 | } 162 | else 163 | { 164 | // This bit would fit better inside RegionFile itself, but the RegionFile 165 | // class doesn't actually know anything about its absolute positioning, 166 | // so we'll just do it here anyway. 167 | RegionFile rf = getRegionFileByRegion(world, closestPair.getValueOne(), closestPair.getValueTwo()); 168 | if (rf != null) 169 | { 170 | int adjustedChunkX = chunkX - (closestPair.getValueOne()*32); 171 | int adjustedChunkZ = chunkZ - (closestPair.getValueTwo()*32); 172 | IntegerPair closestChunk = null; 173 | double closestChunkDistance = Double.MAX_VALUE; 174 | boolean foundChunk = false; 175 | for (int x = 0; x < 32; x++) 176 | { 177 | for (int z = 0; z < 32; z++) 178 | { 179 | if (rf.hasChunk(x, z)) 180 | { 181 | int dist_one; 182 | int dist_two; 183 | if (x > adjustedChunkX) 184 | { 185 | dist_one = Math.abs(x - adjustedChunkX); 186 | } 187 | else 188 | { 189 | dist_one = Math.abs(adjustedChunkX - x); 190 | } 191 | if (z > adjustedChunkZ) 192 | { 193 | dist_two = Math.abs(z - adjustedChunkZ); 194 | } 195 | else 196 | { 197 | dist_two = Math.abs(adjustedChunkZ - z); 198 | } 199 | double thisChunkDistance = Math.sqrt(Math.pow(dist_one, 2) + Math.pow(dist_two, 2)); 200 | if (!foundChunk || thisChunkDistance < closestChunkDistance) 201 | { 202 | foundChunk = true; 203 | closestChunkDistance = thisChunkDistance; 204 | closestChunk = new IntegerPair(x, z); 205 | } 206 | } 207 | } 208 | } 209 | if (foundChunk) 210 | { 211 | return new IntegerPair(closestChunk.getValueOne() + (closestPair.getValueOne()*32), 212 | closestChunk.getValueTwo() + (closestPair.getValueTwo()*32)); 213 | } 214 | } 215 | } 216 | 217 | // If we get here, nothing was found; return null 218 | return null; 219 | } 220 | 221 | public static synchronized RegionFile getRegionFileByRegion(WorldInfo world, int regionX, int regionZ) 222 | { 223 | return getRegionFile(world, (regionX << 5), (regionZ << 5)); 224 | } 225 | 226 | public static synchronized RegionFile getRegionFile(WorldInfo world, int chunkX, int chunkZ) { 227 | File regionDir = new File(new File(world.getBasePath()), "region"); 228 | String extension; 229 | switch(world.data_format) 230 | { 231 | case ANVIL: 232 | extension = ".mca"; 233 | break; 234 | 235 | case MCREGION: 236 | default: 237 | extension = ".mcr"; 238 | } 239 | File file = new File(regionDir, "r." + (chunkX >> 5) + "." + (chunkZ >> 5) + extension); 240 | 241 | Reference ref = cache.get(file); 242 | 243 | if (ref != null && ref.get() != null) { 244 | return ref.get(); 245 | } 246 | 247 | /* Commented for X-Ray because I'd rather not modify anything, even if it's just a 248 | * directory. We should never get here unless stuff exists, anyway. 249 | if (!regionDir.exists()) { 250 | regionDir.mkdirs(); 251 | } 252 | */ 253 | 254 | if (cache.size() >= MAX_CACHE_SIZE) { 255 | RegionFileCache.clear(); 256 | } 257 | 258 | if (file.exists()) 259 | { 260 | RegionFile reg = new RegionFile(file); 261 | cache.put(file, new SoftReference(reg)); 262 | return reg; 263 | } 264 | else 265 | { 266 | return null; 267 | } 268 | } 269 | 270 | public static synchronized void clear() { 271 | for (Reference ref : cache.values()) { 272 | try { 273 | if (ref.get() != null) { 274 | ref.get().close(); 275 | } 276 | } catch (IOException e) { 277 | e.printStackTrace(); 278 | } 279 | } 280 | cache.clear(); 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/BlockTypeFilename.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.util.Map; 30 | import java.util.HashMap; 31 | import java.util.ArrayList; 32 | import java.awt.Color; 33 | import java.io.InputStream; 34 | import java.io.IOException; 35 | 36 | import static com.apocalyptech.minecraft.xray.MinecraftConstants.*; 37 | 38 | /** 39 | */ 40 | public class BlockTypeFilename extends BlockType 41 | { 42 | 43 | // YAML Attributes 44 | private String tex; 45 | private HashMap tex_data; 46 | private HashMap tex_direction; 47 | private HashMap tex_direction_int; 48 | private HashMap tex_extra; 49 | 50 | // Attributes brought over from BlockTypeCollection 51 | public String texpath; 52 | 53 | public BlockTypeFilename() 54 | { 55 | super(); 56 | } 57 | 58 | public void setTex(String tex) 59 | { 60 | this.tex = tex; 61 | } 62 | 63 | public String getTex() 64 | { 65 | return this.tex; 66 | } 67 | 68 | public void setTex_data(HashMap tex_data) 69 | { 70 | this.tex_data = tex_data; 71 | } 72 | 73 | public HashMap getTex_data() 74 | { 75 | return this.tex_data; 76 | } 77 | 78 | public void setTex_direction(HashMap tex_direction) 79 | { 80 | this.tex_direction = tex_direction; 81 | } 82 | 83 | public HashMap getTex_direction() 84 | { 85 | return this.tex_direction; 86 | } 87 | 88 | public void setTex_extra(HashMap tex_extra) 89 | { 90 | this.tex_extra = tex_extra; 91 | } 92 | 93 | public HashMap getTex_extra() 94 | { 95 | return this.tex_extra; 96 | } 97 | 98 | /** 99 | * Pulls data from the master collection 100 | */ 101 | public void pullDataFromCollection(BlockTypeCollection collection) 102 | { 103 | super.pullDataFromCollection(collection); 104 | this.texpath = collection.getTexpath(); 105 | } 106 | 107 | /** 108 | * Returns the full filename for the given texture file 109 | */ 110 | private String getFullTextureFilename(String filename) 111 | { 112 | return this.texpath + "/" + filename; 113 | } 114 | 115 | /** 116 | * Gets a list of all texture filenames we're using 117 | */ 118 | public ArrayList getTextureFilenames() 119 | { 120 | HashMap tempMap = new HashMap(); 121 | ArrayList list = new ArrayList(); 122 | list.add(this.tex); 123 | if (this.tex_data != null) 124 | { 125 | for (String tex : this.tex_data.values()) 126 | { 127 | if (!tempMap.containsKey(tex)) 128 | { 129 | tempMap.put(tex, null); 130 | list.add(tex); 131 | } 132 | } 133 | } 134 | if (this.tex_direction_int != null) 135 | { 136 | for (String tex : this.tex_direction_int.values()) 137 | { 138 | if (!tempMap.containsKey(tex)) 139 | { 140 | tempMap.put(tex, null); 141 | list.add(tex); 142 | } 143 | } 144 | } 145 | if (this.tex_extra != null) 146 | { 147 | for (String tex : this.tex_extra.values()) 148 | { 149 | if (!tempMap.containsKey(tex)) 150 | { 151 | tempMap.put(tex, null); 152 | list.add(tex); 153 | } 154 | } 155 | } 156 | return list; 157 | } 158 | 159 | /** 160 | * Sets our "real" texture values 161 | * 162 | * TODO: Exception error reporting 163 | */ 164 | public void setTextureFilenameMapping(HashMap texmap) 165 | throws BlockTypeLoadException 166 | { 167 | // First the "main" texture 168 | if (texmap.containsKey(this.tex)) 169 | { 170 | this.tex_idx = texmap.get(this.tex); 171 | } 172 | else 173 | { 174 | throw new BlockTypeLoadException("No texture mapping found for " + this.tex); 175 | } 176 | 177 | // Now data the data mapping 178 | if (this.tex_data != null && this.tex_data.size() > 0) 179 | { 180 | this.texture_data_map = new HashMap(); 181 | for (Map.Entry entry : this.tex_data.entrySet()) 182 | { 183 | if (texmap.containsKey(entry.getValue())) 184 | { 185 | this.texture_data_map.put(entry.getKey().byteValue(), texmap.get(entry.getValue())); 186 | } 187 | else 188 | { 189 | throw new BlockTypeLoadException("No texture mapping found for " + entry.getValue()); 190 | } 191 | } 192 | } 193 | 194 | // Now direction data mapping 195 | if (this.tex_direction_int != null && this.tex_direction_int.size() > 0) 196 | { 197 | this.texture_dir_map = new HashMap(); 198 | for (Map.Entry entry : this.tex_direction_int.entrySet()) 199 | { 200 | if (texmap.containsKey(entry.getValue())) 201 | { 202 | this.texture_dir_map.put(entry.getKey(), texmap.get(entry.getValue())); 203 | } 204 | else 205 | { 206 | throw new BlockTypeLoadException("No texture mapping found for " + entry.getValue()); 207 | } 208 | } 209 | } 210 | 211 | // Now the "extra" textures 212 | if (this.tex_extra != null && this.tex_extra.size() > 0) 213 | { 214 | this.texture_extra_map = new HashMap(); 215 | for (Map.Entry entry : this.tex_extra.entrySet()) 216 | { 217 | if (texmap.containsKey(entry.getValue())) 218 | { 219 | this.texture_extra_map.put(entry.getKey(), texmap.get(entry.getValue())); 220 | } 221 | else 222 | { 223 | throw new BlockTypeLoadException("No texture mapping found for " + entry.getValue()); 224 | } 225 | } 226 | } 227 | } 228 | 229 | /** 230 | * Attempts to open the file, to make sure that it's readable before we go 231 | * any further. This should be the full path, post-normalization. 232 | */ 233 | private static void checkTextureAvailability(String filename) 234 | throws BlockTypeLoadException 235 | { 236 | try 237 | { 238 | InputStream stream = MinecraftEnvironment.getMinecraftTexturepackData(filename); 239 | if (stream == null) 240 | { 241 | throw new BlockTypeLoadException("File " + filename + " is not found"); 242 | } 243 | stream.close(); 244 | } 245 | catch (IOException e) 246 | { 247 | throw new BlockTypeLoadException("Error while opening " + filename + ": " + e.toString(), e); 248 | } 249 | } 250 | 251 | /** 252 | * Normalizes our data from what we get from YAML, to a format that's 253 | * easier to deal with in X-Ray. 254 | * 255 | * TODO: Exception error reporting 256 | */ 257 | public void normalizeData() 258 | throws BlockTypeLoadException 259 | { 260 | // First check our super 261 | super.normalizeData(); 262 | 263 | // Now check for some required attributes 264 | if (this.tex == null || this.tex.length() == 0) 265 | { 266 | throw new BlockTypeLoadException("tex is a required attribute"); 267 | } 268 | 269 | // Now do the actual normalizing... Modify our textures to use the full path 270 | this.tex = this.getFullTextureFilename(this.tex); 271 | checkTextureAvailability(this.tex); 272 | 273 | if (this.tex_data != null && this.tex_data.size() > 0) 274 | { 275 | for (Map.Entry entry : this.tex_data.entrySet()) 276 | { 277 | entry.setValue(this.getFullTextureFilename(entry.getValue())); 278 | checkTextureAvailability(entry.getValue()); 279 | } 280 | } 281 | if (this.tex_direction != null && this.tex_direction.size() > 0) 282 | { 283 | this.tex_direction_int = new HashMap(); 284 | for (Map.Entry entry: this.tex_direction.entrySet()) 285 | { 286 | DIRECTION_REL dir; 287 | try 288 | { 289 | dir = DIRECTION_REL.valueOf(entry.getKey()); 290 | } 291 | catch (IllegalArgumentException e) 292 | { 293 | throw new BlockTypeLoadException("Invalid relative direction: " + entry.getKey()); 294 | } 295 | this.tex_direction_int.put(dir, this.getFullTextureFilename(entry.getValue())); 296 | checkTextureAvailability(this.tex_direction_int.get(dir)); 297 | } 298 | } 299 | if (this.tex_extra != null && this.tex_extra.size() > 0) 300 | { 301 | for (Map.Entry entry : this.tex_extra.entrySet()) 302 | { 303 | entry.setValue(this.getFullTextureFilename(entry.getValue())); 304 | checkTextureAvailability(entry.getValue()); 305 | } 306 | } 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/ChunkOriginal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.lang.Math; 30 | import java.util.Map; 31 | import java.util.Random; 32 | import java.util.HashMap; 33 | import java.util.ArrayList; 34 | import java.util.regex.PatternSyntaxException; 35 | 36 | import org.lwjgl.opengl.GL11; 37 | 38 | import com.apocalyptech.minecraft.xray.dtf.ShortArrayTag; 39 | import com.apocalyptech.minecraft.xray.dtf.ByteArrayTag; 40 | import com.apocalyptech.minecraft.xray.dtf.CompoundTag; 41 | import com.apocalyptech.minecraft.xray.dtf.StringTag; 42 | import com.apocalyptech.minecraft.xray.dtf.ListTag; 43 | import com.apocalyptech.minecraft.xray.dtf.IntTag; 44 | import com.apocalyptech.minecraft.xray.dtf.Tag; 45 | 46 | import static com.apocalyptech.minecraft.xray.MinecraftConstants.*; 47 | 48 | /** 49 | * The original style chunk, basically from Alpha on upwards, until the 50 | * weekly release 12w07a (and, eventually, Minecraft 1.2). All data 51 | * for the chunk is stored directly in the main tags, with an effective 52 | * height limit of 128. 53 | */ 54 | public class ChunkOriginal extends Chunk { 55 | 56 | private static final int BLOCKSPERROW = 128; 57 | private static final int BLOCKSPERCOLUMN = BLOCKSPERROW * 16; 58 | 59 | private ShortArrayTag blockData; 60 | private ByteArrayTag mapData; 61 | 62 | public ChunkOriginal(MinecraftLevel level, Tag data) { 63 | 64 | super(level, data); 65 | 66 | this.maxHeight = 127; 67 | this.ceilingHeight = 127; 68 | 69 | blockData = (ShortArrayTag) this.levelTag.getTagWithName("Blocks"); 70 | mapData = (ByteArrayTag) this.levelTag.getTagWithName("Data"); 71 | 72 | this.finishConstructor(); 73 | } 74 | 75 | /** 76 | * Will return an array of values which are suitable for feeding into a 77 | * minimap. 78 | */ 79 | public short[][] getMinimapValues() 80 | { 81 | short[][] minimap = new short[16][16]; 82 | boolean in_nether = this.level.world.isDimension(-1); 83 | boolean found_air; 84 | boolean found_solid; 85 | boolean drew_block; 86 | 87 | int blockOffset; 88 | short block; 89 | for (int zz = 0; zz < 16; zz++) 90 | { 91 | for (int xx = 0; xx < 16; xx++) 92 | { 93 | // determine the top most visible block 94 | found_air = !in_nether; 95 | drew_block = false; 96 | found_solid = false; 97 | for (int yy = this.maxHeight; yy >= 0; yy--) 98 | { 99 | blockOffset = yy + (zz * 128) + (xx * 128 * 16); 100 | block = blockData.value[blockOffset]; 101 | 102 | if (block > 0) 103 | { 104 | if (in_nether && !found_solid) 105 | { 106 | found_air = false; 107 | } 108 | found_solid = true; 109 | if (found_air) 110 | { 111 | minimap[xx][zz] = block; 112 | drew_block = true; 113 | break; 114 | } 115 | } 116 | else 117 | { 118 | found_air = true; 119 | } 120 | } 121 | 122 | // Make sure we don't have holes in our Nether minimap 123 | if (in_nether && found_solid && !drew_block) 124 | { 125 | minimap[xx][zz] = MinecraftConstants.BLOCK_BEDROCK.id; 126 | } 127 | } 128 | } 129 | 130 | return minimap; 131 | } 132 | 133 | /** 134 | * Gets the Block ID of the block immediately to the given facing. This might 135 | * load in the adjacent chunk, if needed. Will return -1 if that adjacent 136 | * chunk can't be found. 137 | */ 138 | protected short getAdjBlockId(int x, int y, int z, FACING facing, int blockOffset) { 139 | switch(facing) { 140 | case TOP: 141 | return getAdjUpBlockId(x, y, z, blockOffset); 142 | case BOTTOM: 143 | return getAdjDownBlockId(x, y, z, blockOffset); 144 | case NORTH: 145 | return getAdjNorthBlockId(x, y, z, blockOffset); 146 | case SOUTH: 147 | return getAdjSouthBlockId(x, y, z, blockOffset); 148 | case WEST: 149 | return getAdjWestBlockId(x, y, z, blockOffset); 150 | case EAST: 151 | return getAdjEastBlockId(x, y, z, blockOffset); 152 | } 153 | 154 | return -1; 155 | } 156 | 157 | /** 158 | * Gets the Block ID of the block immediately to the west. This might 159 | * load in the adjacent chunk, if needed. Will return -1 if that adjacent 160 | * chunk can't be found. 161 | */ 162 | protected short getAdjWestBlockId(int x, int y, int z, int blockOffset) 163 | { 164 | if (x > 0) 165 | { 166 | return blockData.value[blockOffset-BLOCKSPERCOLUMN]; 167 | } 168 | else 169 | { 170 | Chunk otherChunk = level.getChunk(this.x-1, this.z); 171 | if (otherChunk == null) 172 | { 173 | return -1; 174 | } 175 | else 176 | { 177 | return otherChunk.getBlock(15, y, z); 178 | } 179 | } 180 | } 181 | 182 | /** 183 | * Gets the Block ID of the block immediately to the east. This might 184 | * load in the adjacent chunk, if needed. Will return -1 if that adjacent 185 | * chunk can't be found. 186 | */ 187 | protected short getAdjEastBlockId(int x, int y, int z, int blockOffset) 188 | { 189 | if (x < 15) 190 | { 191 | return blockData.value[blockOffset+BLOCKSPERCOLUMN]; 192 | } 193 | else 194 | { 195 | Chunk otherChunk = level.getChunk(this.x+1, this.z); 196 | if (otherChunk == null) 197 | { 198 | return -1; 199 | } 200 | else 201 | { 202 | return otherChunk.getBlock(0, y, z); 203 | } 204 | } 205 | } 206 | 207 | /** 208 | * Gets the Block ID of the block immediately to the south. This might 209 | * load in the adjacent chunk, if needed. Will return -1 if that adjacent 210 | * chunk can't be found. 211 | */ 212 | protected short getAdjNorthBlockId(int x, int y, int z, int blockOffset) 213 | { 214 | if (z > 0) 215 | { 216 | return blockData.value[blockOffset-BLOCKSPERROW]; 217 | } 218 | else 219 | { 220 | Chunk otherChunk = level.getChunk(this.x, this.z-1); 221 | if (otherChunk == null) 222 | { 223 | return -1; 224 | } 225 | else 226 | { 227 | return otherChunk.getBlock(x, y, 15); 228 | } 229 | } 230 | } 231 | 232 | /** 233 | * Gets the Block ID of the block immediately to the north. This might 234 | * load in the adjacent chunk, if needed. Will return -1 if that adjacent 235 | * chunk can't be found. 236 | */ 237 | protected short getAdjSouthBlockId(int x, int y, int z, int blockOffset) 238 | { 239 | if (z < 15) 240 | { 241 | return blockData.value[blockOffset+BLOCKSPERROW]; 242 | } 243 | else 244 | { 245 | Chunk otherChunk = level.getChunk(this.x, this.z+1); 246 | if (otherChunk == null) 247 | { 248 | return -1; 249 | } 250 | else 251 | { 252 | return otherChunk.getBlock(x, y, 0); 253 | } 254 | } 255 | } 256 | 257 | /** 258 | * Gets the Block ID of the block immediately up. 259 | * Will return -1 if we're already at the top 260 | */ 261 | protected short getAdjUpBlockId(int x, int y, int z, int blockOffset) 262 | { 263 | if (y >= this.maxHeight) 264 | { 265 | return -1; 266 | } 267 | else 268 | { 269 | return blockData.value[blockOffset+1]; 270 | } 271 | } 272 | 273 | /** 274 | * Gets the Block ID of the block immediately down. 275 | * Will return -1 if we're already at the bottom 276 | */ 277 | protected short getAdjDownBlockId(int x, int y, int z, int blockOffset) 278 | { 279 | if (y <= 0) 280 | { 281 | return -1; 282 | } 283 | else 284 | { 285 | return blockData.value[blockOffset-1]; 286 | } 287 | } 288 | 289 | /** 290 | * Gets the block ID at the specified coordinate in the chunk. This is 291 | * only really used in the getAdj*BlockId() methods. 292 | */ 293 | public short getBlock(int x, int y, int z) { 294 | return blockData.value[y + (z * 128) + (x * 128 * 16)]; 295 | } 296 | 297 | /** 298 | * Gets the block data at the specified coordinates. 299 | */ 300 | public byte getData(int x, int y, int z) { 301 | int offset = y + (z * 128) + (x * 128 * 16); 302 | int halfOffset = offset / 2; 303 | if(offset % 2 == 0) { 304 | return (byte) (mapData.value[halfOffset] & 0xF); 305 | } else { 306 | // We shouldn't have to &0xF here, but if we don't the value 307 | // returned could be negative, even though that would be silly. 308 | return (byte) ((mapData.value[halfOffset] >> 4) & 0xF); 309 | } 310 | } 311 | 312 | /** 313 | * Advances our block loop 314 | */ 315 | protected short nextBlock() 316 | { 317 | this.lOffset++; 318 | if (this.lOffset >= 32768) 319 | { 320 | return -2; 321 | } 322 | this.ly = this.lOffset % 128; 323 | this.lz = (this.lOffset / 128) % 16; 324 | this.lx = this.lOffset / 2048; 325 | return this.blockData.value[this.lOffset]; 326 | } 327 | 328 | } 329 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/dialog/WarningDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray.dialog; 28 | 29 | import java.awt.Component; 30 | import java.awt.Container; 31 | import java.awt.Dimension; 32 | import java.awt.GridBagConstraints; 33 | import java.awt.GridBagLayout; 34 | import java.awt.Image; 35 | import java.awt.Insets; 36 | import java.util.List; 37 | import java.awt.Font; 38 | import java.awt.Toolkit; 39 | import java.awt.event.ActionEvent; 40 | import java.awt.event.ActionListener; 41 | import java.awt.event.ItemEvent; 42 | import java.awt.event.ItemListener; 43 | import java.awt.event.WindowEvent; 44 | import java.awt.event.WindowListener; 45 | import java.awt.event.KeyEvent; 46 | import java.util.ArrayList; 47 | import java.util.Map; 48 | import java.util.TreeMap; 49 | import java.util.TreeSet; 50 | import java.util.HashMap; 51 | import java.util.Properties; 52 | 53 | import javax.swing.Box; 54 | import javax.swing.ComboBoxModel; 55 | import javax.swing.DefaultComboBoxModel; 56 | import javax.swing.JButton; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JSpinner; 59 | import javax.swing.SpinnerNumberModel; 60 | import javax.swing.JFrame; 61 | import javax.swing.JLabel; 62 | import javax.swing.JList; 63 | import javax.swing.JPanel; 64 | import javax.swing.JTextArea; 65 | import javax.swing.JRootPane; 66 | import javax.swing.KeyStroke; 67 | import javax.swing.JSeparator; 68 | import javax.swing.JComponent; 69 | import javax.swing.JCheckBox; 70 | import javax.swing.JScrollPane; 71 | import java.awt.Color; 72 | import javax.swing.SwingConstants; 73 | import javax.swing.AbstractAction; 74 | import javax.swing.border.EmptyBorder; 75 | import javax.swing.border.CompoundBorder; 76 | import javax.swing.plaf.basic.BasicComboBoxRenderer; 77 | import javax.swing.plaf.metal.MetalBorders.TextFieldBorder; 78 | 79 | /** 80 | */ 81 | public class WarningDialog extends JFrame { 82 | private static final long serialVersionUID = 1185056716578355842L; 83 | private static final int FRAMEWIDTH = 400; 84 | private static final int FRAMEHEIGHT = 250; 85 | 86 | private JCheckBox showCheckbox; 87 | 88 | private JButton okButton; 89 | 90 | private GridBagLayout gridBagLayoutManager; 91 | private JPanel basicPanel; 92 | private JScrollPane mainLabel; 93 | 94 | public static boolean selectedShow; 95 | 96 | public static Image iconImage; 97 | 98 | /*** 99 | * Centers this dialog on the screen 100 | */ 101 | private void centerDialogOnScreen() { 102 | Toolkit t = Toolkit.getDefaultToolkit(); 103 | Dimension screenSize = t.getScreenSize(); 104 | 105 | int x = (screenSize.width / 2) - (this.getWidth()/ 2); 106 | int y = (screenSize.height/ 2) - (this.getHeight()/ 2); 107 | 108 | gridBagLayoutManager = new GridBagLayout(); 109 | 110 | this.setLocation(x,y); 111 | this.setAlwaysOnTop(true); 112 | } 113 | 114 | /*** 115 | * Layouts all the controls and labels on the dialog using a gridbaglayout 116 | */ 117 | private void layoutControlsOnDialog(boolean showCheckboxBool) { 118 | basicPanel = new JPanel(); 119 | 120 | this.getContentPane().setLayout(gridBagLayoutManager); 121 | basicPanel.setLayout(gridBagLayoutManager); 122 | GridBagConstraints c = new GridBagConstraints(); 123 | 124 | JLabel headerLabel = new JLabel("Warning"); 125 | headerLabel.setFont(new Font("Arial", Font.BOLD, 18)); 126 | 127 | float flabel = 0.1f; 128 | float flist = 1.9f; 129 | 130 | int current_grid_y = 0; 131 | 132 | c.insets = new Insets(5,5,5,5); 133 | c.weighty = .1f; 134 | 135 | // Checkbox to see if we'll show this warning in the future 136 | showCheckbox = new JCheckBox("Show this warning next time"); 137 | showCheckbox.setSelected(true); 138 | 139 | // Now actually add the buttons 140 | c.insets = new Insets(5, 5, 5, 5); 141 | c.gridx = 0; 142 | c.gridwidth = 1; 143 | c.weightx = 1f; 144 | c.weighty = 0f; 145 | c.anchor = GridBagConstraints.CENTER; 146 | current_grid_y++; 147 | c.gridy = current_grid_y; 148 | addComponent(basicPanel, headerLabel, c); 149 | current_grid_y++; 150 | c.gridy = current_grid_y; 151 | c.anchor = GridBagConstraints.NORTHWEST; 152 | c.weighty = 1f; 153 | c.fill = GridBagConstraints.BOTH; 154 | addComponent(basicPanel, mainLabel, c); 155 | if (showCheckboxBool) 156 | { 157 | current_grid_y++; 158 | c.gridy = current_grid_y; 159 | c.weighty = 0f; 160 | c.weightx = 1f; 161 | c.anchor = GridBagConstraints.EAST; 162 | c.fill = GridBagConstraints.NONE; 163 | addComponent(basicPanel, showCheckbox, c); 164 | } 165 | 166 | // Add our JPanel to the window 167 | c.weightx = 1.0f; 168 | c.weighty = .1f; 169 | c.gridwidth = 2; 170 | c.gridx = 0; c.gridy = 0; 171 | c.fill = GridBagConstraints.BOTH; 172 | addComponent(this.getContentPane(), basicPanel,c); 173 | 174 | // Now add the button 175 | c.insets = new Insets(5,15,5,15); 176 | c.gridwidth = 1; 177 | 178 | c.weightx = 1f; 179 | c.weighty = 0f; 180 | c.gridx = 0; 181 | c.gridy = 1; 182 | c.anchor = GridBagConstraints.SOUTHEAST; 183 | c.fill = GridBagConstraints.HORIZONTAL; 184 | addComponent(this.getContentPane(), okButton,c); 185 | } 186 | 187 | /*** 188 | * Adds a component to the container and updates the constraints for that component 189 | * @param root The contiainer to add the component to 190 | * @param comp The component to add to the container 191 | * @param constraints The constraints which affect the component 192 | */ 193 | private void addComponent(Container root, Component comp, GridBagConstraints constraints) { 194 | gridBagLayoutManager.setConstraints(comp,constraints); 195 | root.add(comp); 196 | } 197 | 198 | /*** 199 | * Builds the OK Button and attaches the actions to it 200 | */ 201 | private void buildButtons(String warningText) { 202 | JRootPane rootPane = this.getRootPane(); 203 | 204 | // The "Jump" button 205 | okButton = new JButton("OK"); 206 | okButton.addActionListener(new ActionListener() { 207 | public void actionPerformed(ActionEvent e) { 208 | dialogOK(); 209 | } 210 | }); 211 | 212 | // Key mapping for the OK button 213 | KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false); 214 | rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterStroke, "ENTER"); 215 | KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); 216 | rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, "ENTER"); 217 | rootPane.getActionMap().put("ENTER", new AbstractAction() { 218 | public void actionPerformed(ActionEvent e) { 219 | dialogOK(); 220 | } 221 | }); 222 | 223 | // Main label 224 | JTextArea labelArea = new JTextArea(warningText); 225 | labelArea.setLineWrap(true); 226 | labelArea.setWrapStyleWord(true); 227 | labelArea.setEditable(false); 228 | labelArea.setMargin(new Insets(8, 8, 8, 8)); 229 | labelArea.setBorder(new CompoundBorder(new TextFieldBorder(), new EmptyBorder(6, 6, 6, 6))); 230 | mainLabel = new JScrollPane(labelArea); 231 | mainLabel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 232 | mainLabel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 233 | 234 | } 235 | 236 | /** 237 | * Actions to perform if the "OK" button is hit, or otherwise triggered. 238 | */ 239 | private void dialogOK() 240 | { 241 | setSelectedValues(); 242 | setVisible(false); 243 | dispose(); 244 | synchronized(WarningDialog.this) { 245 | WarningDialog.this.notify(); 246 | } 247 | } 248 | 249 | /*** 250 | * Sets the selected values to the static properties of this resolution dialog 251 | */ 252 | private void setSelectedValues() { 253 | WarningDialog.selectedShow = this.showCheckbox.isSelected(); 254 | } 255 | 256 | /*** 257 | * Creates a new WarningDialog 258 | * @param windowName the title of the dialog 259 | */ 260 | protected WarningDialog(String windowName, String warningText, boolean showCheckbox, int width, int height) 261 | { 262 | super(windowName); 263 | 264 | if(WarningDialog.iconImage != null) 265 | this.setIconImage(WarningDialog.iconImage); 266 | 267 | this.setSize(width, height); 268 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 269 | this.setMinimumSize(new Dimension(width, height)); 270 | 271 | centerDialogOnScreen(); 272 | 273 | buildButtons(warningText); 274 | layoutControlsOnDialog(showCheckbox); 275 | 276 | validate(); 277 | 278 | this.setVisible(true); 279 | } 280 | 281 | /*** 282 | * Pops up the dialog window 283 | * @param windowName the title of the dialog 284 | */ 285 | public static void presentDialog(String windowName, String warningText) 286 | { 287 | presentDialog(windowName, warningText, true, FRAMEWIDTH, FRAMEHEIGHT); 288 | } 289 | 290 | /*** 291 | * Pops up the dialog window 292 | * @param windowName the title of the dialog 293 | */ 294 | public static void presentDialog(String windowName, String warningText, boolean showCheckbox, int width, int height) 295 | { 296 | WarningDialog dialog = new WarningDialog(windowName, warningText, showCheckbox, width, height); 297 | try 298 | { 299 | synchronized(dialog) 300 | { 301 | dialog.wait(); 302 | } 303 | } 304 | catch (InterruptedException e) 305 | { 306 | e.printStackTrace(); 307 | } 308 | } 309 | } 310 | -------------------------------------------------------------------------------- /src/com/apocalyptech/minecraft/xray/WorldInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2010-2012, Vincent Vollers and Christopher J. Kucera 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the Minecraft X-Ray team nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL VINCENT VOLLERS OR CJ KUCERA BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package com.apocalyptech.minecraft.xray; 28 | 29 | import java.io.File; 30 | import java.io.IOException; 31 | import java.io.FilenameFilter; 32 | import java.lang.Comparable; 33 | import java.lang.NumberFormatException; 34 | import java.util.HashMap; 35 | import java.util.TreeMap; 36 | import java.util.ArrayList; 37 | import java.util.Collections; 38 | 39 | /** 40 | * Class to aid in maintaining a list of possible worlds for us to use. 41 | */ 42 | public class WorldInfo implements Comparable 43 | { 44 | private String basepath; 45 | private String dirName; 46 | private String levelName; 47 | private boolean userChosen; 48 | private int dimension; 49 | public TreeMap mp_players; 50 | 51 | public static enum MAP_TYPE { 52 | ORIGINAL, 53 | MCREGION, 54 | ANVIL 55 | } 56 | 57 | public static HashMap known_dimensions; 58 | 59 | // Some static initializations 60 | static 61 | { 62 | known_dimensions = new HashMap(); 63 | known_dimensions.put(-1, "Nether"); 64 | known_dimensions.put(1, "The End"); 65 | } 66 | 67 | // Store what format our map is stored in 68 | public MAP_TYPE data_format = MAP_TYPE.MCREGION; 69 | 70 | private class PlayerDatFilter implements FilenameFilter 71 | { 72 | public PlayerDatFilter() { 73 | // Nothing, really 74 | } 75 | 76 | public boolean accept(File directory, String filename) { 77 | return (filename.endsWith(".dat")); 78 | } 79 | } 80 | 81 | /** 82 | * Instansiate a new object. "userChosen" refers to when the user has specified 83 | * a userChosen path, instead of one of the standard Minecraft singleplayer world 84 | * locations. 85 | * 86 | * @param basepath 87 | * @param dimension 88 | * @param userChosen 89 | */ 90 | public WorldInfo(String basepath, String dirName, int dimension, boolean userChosen) 91 | { 92 | this.basepath = basepath; 93 | this.dimension = dimension; 94 | this.userChosen = userChosen; 95 | this.dirName = dirName; 96 | this.populateMPPlayerList(); 97 | 98 | // Load in the minecraft level, to read its name 99 | if (basepath != null) 100 | { 101 | this.levelName = MinecraftLevel.getLevelName(this); 102 | } 103 | else 104 | { 105 | this.levelName = null; 106 | } 107 | } 108 | 109 | /** 110 | * Instansiate a userChosen WorldInfo - path will be added later when the user 111 | * selects it. 112 | */ 113 | public WorldInfo() 114 | { 115 | this(null, null, 0, true); 116 | } 117 | 118 | public void populateMPPlayerList() 119 | { 120 | this.mp_players = new TreeMap(); 121 | if (this.basepath != null) 122 | { 123 | File playerdir = this.getPlayerListDir(); 124 | if (playerdir != null && playerdir.exists() && playerdir.isDirectory()) 125 | { 126 | String basename; 127 | File[] players = playerdir.listFiles(new PlayerDatFilter()); 128 | for (File player : players) 129 | { 130 | basename = player.getName(); 131 | this.mp_players.put(basename.substring(0, basename.lastIndexOf('.')), player); 132 | } 133 | } 134 | } 135 | } 136 | 137 | /** 138 | * Finalizes the world location for a userChosen world. This will 139 | * unset the "userChosen" attribute. 140 | * 141 | * @param newpath 142 | */ 143 | public void finalizeWorldLocation(File newpath) throws Exception, NumberFormatException 144 | { 145 | if (this.userChosen) 146 | { 147 | this.basepath = newpath.getCanonicalPath(); 148 | this.dirName = newpath.getName(); 149 | File test = new File(this.getBasePath(), "level.dat"); 150 | if (test.exists()) 151 | { 152 | this.dimension = 0; 153 | } 154 | else 155 | { 156 | test = new File(this.getBasePath(), "../level.dat"); 157 | if (test.exists()) 158 | { 159 | this.dimension = Integer.parseInt(this.getDirName().substring(3)); 160 | } 161 | else 162 | { 163 | throw new Exception("We couldn't find a level.dat for world at " + this.getBasePath()); 164 | } 165 | } 166 | this.userChosen = false; 167 | } 168 | this.populateMPPlayerList(); 169 | } 170 | 171 | /** 172 | * Gets the base path 173 | * 174 | * @return 175 | */ 176 | public String getBasePath() 177 | { 178 | return this.basepath; 179 | } 180 | 181 | /** 182 | * Gets the base path as a File object 183 | * 184 | */ 185 | public File getBaseFile() 186 | { 187 | return new File(this.getBasePath()); 188 | } 189 | 190 | public File getLevelDatFile() 191 | { 192 | if (this.isOverworld()) 193 | { 194 | return new File(this.getBasePath(), "level.dat"); 195 | } 196 | else 197 | { 198 | return new File(this.getBasePath(), "../level.dat"); 199 | } 200 | } 201 | 202 | public File getPlayerListDir() 203 | { 204 | if (this.isOverworld()) 205 | { 206 | return new File(this.getBasePath(), "players"); 207 | } 208 | else 209 | { 210 | return new File(this.getBasePath(), "../players"); 211 | } 212 | } 213 | 214 | /** 215 | * Returns our directory name (this value is meaningless for userChosen worlds) 216 | * 217 | * @return 218 | */ 219 | public String getDirName() 220 | { 221 | return this.dirName; 222 | } 223 | 224 | /** 225 | * Returns our level name 226 | * 227 | * @return 228 | */ 229 | public String getLevelName() 230 | { 231 | return this.levelName; 232 | } 233 | 234 | /** 235 | * A userChosen world is one that lives outside the usual Minecraft directory 236 | * structure. 237 | * 238 | * @return 239 | */ 240 | public boolean isCustom() 241 | { 242 | return this.userChosen; 243 | } 244 | 245 | /** 246 | * Are we a dimension world? Note that userChosen worlds will always return false 247 | * until their path is set with finalizeWorldLocation() 248 | * 249 | * @return 250 | */ 251 | public boolean isDimension(int dimension) 252 | { 253 | return (this.dimension == dimension); 254 | } 255 | 256 | /** 257 | * Return which dimension we are 258 | */ 259 | public int getDimension() 260 | { 261 | return this.dimension; 262 | } 263 | 264 | /** 265 | * Returns whether this is a dimension that we "know" about (mostly just for 266 | * the text label) 267 | */ 268 | public boolean isKnownDimension() 269 | { 270 | return (known_dimensions.containsKey(this.dimension)); 271 | } 272 | 273 | /** 274 | * Returns a text description of this dimension 275 | */ 276 | public String getDimensionDesc() 277 | { 278 | if (this.isKnownDimension()) 279 | { 280 | return (String)known_dimensions.get(this.dimension); 281 | } 282 | else if (this.isDimension(0)) 283 | { 284 | return "Overworld"; 285 | } 286 | else 287 | { 288 | return "Dimension " + Integer.toString(this.dimension); 289 | } 290 | } 291 | 292 | /** 293 | * Are we an overworld? Note that userChosen worlds will always return true 294 | * until their path is set with finalizeWorldLocation() 295 | */ 296 | public boolean isOverworld() 297 | { 298 | return (this.dimension == 0); 299 | } 300 | 301 | /** 302 | * Do we have a dimension subdirectory to read? 303 | * 304 | * @return 305 | */ 306 | public boolean hasDimension(int dimension) 307 | { 308 | if (!this.userChosen && this.dimension == dimension) 309 | { 310 | return false; 311 | } 312 | else 313 | { 314 | File test = new File(this.getBasePath(), "DIM" + Integer.toString(dimension)); 315 | return (test.exists() && test.canRead() && test.isDirectory()); 316 | } 317 | } 318 | 319 | /** 320 | * Do we have an overworld? 321 | * 322 | * @return 323 | */ 324 | public boolean hasOverworld() 325 | { 326 | if (!this.userChosen && this.dimension != 0) 327 | { 328 | File test = new File(this.getBasePath(), "../level.dat"); 329 | return (test.exists() && test.canRead()); 330 | } 331 | else 332 | { 333 | return false; 334 | } 335 | } 336 | 337 | /** 338 | * Returns an array of new WorldInfo objects pointing to any associated 339 | * extra dimensions, if we have one. 340 | * 341 | * @return A new WorldInfo array 342 | */ 343 | public ArrayList getDimensionInfo() 344 | { 345 | ArrayList ret_array = new ArrayList(); 346 | 347 | File dir = this.getBaseFile(); 348 | if (dir != null && dir.exists() && dir.isDirectory()) 349 | { 350 | File[] dimensions = dir.listFiles(new DimensionFilter()); 351 | for (File dim_dir : dimensions) 352 | { 353 | try 354 | { 355 | int dimension = DimensionFilter.get_dimension(dim_dir.getName()); 356 | ret_array.add(new WorldInfo(dim_dir.getCanonicalPath(), this.dirName, dimension, this.userChosen)); 357 | } 358 | catch (DimensionFilterException e) 359 | { 360 | // whatever, just skip 361 | } 362 | catch (IOException e) 363 | { 364 | XRay.logger.warn("Exception attempting to read world at " + this.dirName + ": " + e.toString()); 365 | // whatever, just skip 366 | } 367 | } 368 | } 369 | 370 | Collections.sort(ret_array); 371 | return ret_array; 372 | } 373 | 374 | /** 375 | * Returns a new WorldInfo object pointing to the overworld, if we currently 376 | * live in a subdirectory of another world. 377 | * 378 | * @return A new WorldInfo, or null 379 | */ 380 | public WorldInfo getOverworldInfo() 381 | { 382 | if (this.hasOverworld()) 383 | { 384 | File info = new File(this.getBasePath(), ".."); 385 | try 386 | { 387 | return new WorldInfo(info.getCanonicalPath(), this.dirName, 0, this.userChosen); 388 | } 389 | catch (IOException e) 390 | { 391 | return null; 392 | } 393 | } 394 | else 395 | { 396 | return null; 397 | } 398 | } 399 | 400 | /** 401 | * Method for Comparable interface, so we can sort based on dimension. 402 | */ 403 | public int compareTo(WorldInfo anotherInstance) 404 | { 405 | return this.getDimension() - anotherInstance.getDimension(); 406 | } 407 | 408 | /** 409 | * Gets an ordered list of all dimensions for this world, including the one 410 | * we're on, and the overworld, etc. 411 | */ 412 | public ArrayList getAllDimensions() 413 | { 414 | ArrayList dims; 415 | if (this.isOverworld()) 416 | { 417 | dims = this.getDimensionInfo(); 418 | dims.add(this); 419 | } 420 | else 421 | { 422 | dims = this.getOverworldInfo().getDimensionInfo(); 423 | dims.add(this.getOverworldInfo()); 424 | } 425 | Collections.sort(dims); 426 | return dims; 427 | } 428 | } 429 | -------------------------------------------------------------------------------- /COPYING-log4j.txt: -------------------------------------------------------------------------------- 1 | http://logging.apache.org/log4j/1.2/license.html 2 | 3 | 4 | Apache License 5 | Version 2.0, January 2004 6 | http://www.apache.org/licenses/ 7 | 8 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 9 | 10 | 1. Definitions. 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, 13 | and distribution as defined by Sections 1 through 9 of this document. 14 | 15 | "Licensor" shall mean the copyright owner or entity authorized by 16 | the copyright owner that is granting the License. 17 | 18 | "Legal Entity" shall mean the union of the acting entity and all 19 | other entities that control, are controlled by, or are under common 20 | control with that entity. For the purposes of this definition, 21 | "control" means (i) the power, direct or indirect, to cause the 22 | direction or management of such entity, whether by contract or 23 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 24 | outstanding shares, or (iii) beneficial ownership of such entity. 25 | 26 | "You" (or "Your") shall mean an individual or Legal Entity 27 | exercising permissions granted by this License. 28 | 29 | "Source" form shall mean the preferred form for making modifications, 30 | including but not limited to software source code, documentation 31 | source, and configuration files. 32 | 33 | "Object" form shall mean any form resulting from mechanical 34 | transformation or translation of a Source form, including but 35 | not limited to compiled object code, generated documentation, 36 | and conversions to other media types. 37 | 38 | "Work" shall mean the work of authorship, whether in Source or 39 | Object form, made available under the License, as indicated by a 40 | copyright notice that is included in or attached to the work 41 | (an example is provided in the Appendix below). 42 | 43 | "Derivative Works" shall mean any work, whether in Source or Object 44 | form, that is based on (or derived from) the Work and for which the 45 | editorial revisions, annotations, elaborations, or other modifications 46 | represent, as a whole, an original work of authorship. For the purposes 47 | of this License, Derivative Works shall not include works that remain 48 | separable from, or merely link (or bind by name) to the interfaces of, 49 | the Work and Derivative Works thereof. 50 | 51 | "Contribution" shall mean any work of authorship, including 52 | the original version of the Work and any modifications or additions 53 | to that Work or Derivative Works thereof, that is intentionally 54 | submitted to Licensor for inclusion in the Work by the copyright owner 55 | or by an individual or Legal Entity authorized to submit on behalf of 56 | the copyright owner. For the purposes of this definition, "submitted" 57 | means any form of electronic, verbal, or written communication sent 58 | to the Licensor or its representatives, including but not limited to 59 | communication on electronic mailing lists, source code control systems, 60 | and issue tracking systems that are managed by, or on behalf of, the 61 | Licensor for the purpose of discussing and improving the Work, but 62 | excluding communication that is conspicuously marked or otherwise 63 | designated in writing by the copyright owner as "Not a Contribution." 64 | 65 | "Contributor" shall mean Licensor and any individual or Legal Entity 66 | on behalf of whom a Contribution has been received by Licensor and 67 | subsequently incorporated within the Work. 68 | 69 | 2. Grant of Copyright License. Subject to the terms and conditions of 70 | this License, each Contributor hereby grants to You a perpetual, 71 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 72 | copyright license to reproduce, prepare Derivative Works of, 73 | publicly display, publicly perform, sublicense, and distribute the 74 | Work and such Derivative Works in Source or Object form. 75 | 76 | 3. Grant of Patent License. Subject to the terms and conditions of 77 | this License, each Contributor hereby grants to You a perpetual, 78 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 79 | (except as stated in this section) patent license to make, have made, 80 | use, offer to sell, sell, import, and otherwise transfer the Work, 81 | where such license applies only to those patent claims licensable 82 | by such Contributor that are necessarily infringed by their 83 | Contribution(s) alone or by combination of their Contribution(s) 84 | with the Work to which such Contribution(s) was submitted. If You 85 | institute patent litigation against any entity (including a 86 | cross-claim or counterclaim in a lawsuit) alleging that the Work 87 | or a Contribution incorporated within the Work constitutes direct 88 | or contributory patent infringement, then any patent licenses 89 | granted to You under this License for that Work shall terminate 90 | as of the date such litigation is filed. 91 | 92 | 4. Redistribution. You may reproduce and distribute copies of the 93 | Work or Derivative Works thereof in any medium, with or without 94 | modifications, and in Source or Object form, provided that You 95 | meet the following conditions: 96 | 97 | (a) You must give any other recipients of the Work or 98 | Derivative Works a copy of this License; and 99 | 100 | (b) You must cause any modified files to carry prominent notices 101 | stating that You changed the files; and 102 | 103 | (c) You must retain, in the Source form of any Derivative Works 104 | that You distribute, all copyright, patent, trademark, and 105 | attribution notices from the Source form of the Work, 106 | excluding those notices that do not pertain to any part of 107 | the Derivative Works; and 108 | 109 | (d) If the Work includes a "NOTICE" text file as part of its 110 | distribution, then any Derivative Works that You distribute must 111 | include a readable copy of the attribution notices contained 112 | within such NOTICE file, excluding those notices that do not 113 | pertain to any part of the Derivative Works, in at least one 114 | of the following places: within a NOTICE text file distributed 115 | as part of the Derivative Works; within the Source form or 116 | documentation, if provided along with the Derivative Works; or, 117 | within a display generated by the Derivative Works, if and 118 | wherever such third-party notices normally appear. The contents 119 | of the NOTICE file are for informational purposes only and 120 | do not modify the License. You may add Your own attribution 121 | notices within Derivative Works that You distribute, alongside 122 | or as an addendum to the NOTICE text from the Work, provided 123 | that such additional attribution notices cannot be construed 124 | as modifying the License. 125 | 126 | You may add Your own copyright statement to Your modifications and 127 | may provide additional or different license terms and conditions 128 | for use, reproduction, or distribution of Your modifications, or 129 | for any such Derivative Works as a whole, provided Your use, 130 | reproduction, and distribution of the Work otherwise complies with 131 | the conditions stated in this License. 132 | 133 | 5. Submission of Contributions. Unless You explicitly state otherwise, 134 | any Contribution intentionally submitted for inclusion in the Work 135 | by You to the Licensor shall be under the terms and conditions of 136 | this License, without any additional terms or conditions. 137 | Notwithstanding the above, nothing herein shall supersede or modify 138 | the terms of any separate license agreement you may have executed 139 | with Licensor regarding such Contributions. 140 | 141 | 6. Trademarks. This License does not grant permission to use the trade 142 | names, trademarks, service marks, or product names of the Licensor, 143 | except as required for reasonable and customary use in describing the 144 | origin of the Work and reproducing the content of the NOTICE file. 145 | 146 | 7. Disclaimer of Warranty. Unless required by applicable law or 147 | agreed to in writing, Licensor provides the Work (and each 148 | Contributor provides its Contributions) on an "AS IS" BASIS, 149 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 150 | implied, including, without limitation, any warranties or conditions 151 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 152 | PARTICULAR PURPOSE. You are solely responsible for determining the 153 | appropriateness of using or redistributing the Work and assume any 154 | risks associated with Your exercise of permissions under this License. 155 | 156 | 8. Limitation of Liability. In no event and under no legal theory, 157 | whether in tort (including negligence), contract, or otherwise, 158 | unless required by applicable law (such as deliberate and grossly 159 | negligent acts) or agreed to in writing, shall any Contributor be 160 | liable to You for damages, including any direct, indirect, special, 161 | incidental, or consequential damages of any character arising as a 162 | result of this License or out of the use or inability to use the 163 | Work (including but not limited to damages for loss of goodwill, 164 | work stoppage, computer failure or malfunction, or any and all 165 | other commercial damages or losses), even if such Contributor 166 | has been advised of the possibility of such damages. 167 | 168 | 9. Accepting Warranty or Additional Liability. While redistributing 169 | the Work or Derivative Works thereof, You may choose to offer, 170 | and charge a fee for, acceptance of support, warranty, indemnity, 171 | or other liability obligations and/or rights consistent with this 172 | License. However, in accepting such obligations, You may act only 173 | on Your own behalf and on Your sole responsibility, not on behalf 174 | of any other Contributor, and only if You agree to indemnify, 175 | defend, and hold each Contributor harmless for any liability 176 | incurred by, or claims asserted against, such Contributor by reason 177 | of your accepting any such warranty or additional liability. 178 | 179 | END OF TERMS AND CONDITIONS 180 | 181 | APPENDIX: How to apply the Apache License to your work. 182 | 183 | To apply the Apache License to your work, attach the following 184 | boilerplate notice, with the fields enclosed by brackets "[]" 185 | replaced with your own identifying information. (Don't include 186 | the brackets!) The text should be enclosed in the appropriate 187 | comment syntax for the file format. We also recommend that a 188 | file or class name and description of purpose be included on the 189 | same "printed page" as the copyright notice for easier 190 | identification within third-party archives. 191 | 192 | Copyright 1999-2005 The Apache Software Foundation 193 | 194 | Licensed under the Apache License, Version 2.0 (the "License"); 195 | you may not use this file except in compliance with the License. 196 | You may obtain a copy of the License at 197 | 198 | http://www.apache.org/licenses/LICENSE-2.0 199 | 200 | Unless required by applicable law or agreed to in writing, software 201 | distributed under the License is distributed on an "AS IS" BASIS, 202 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 203 | See the License for the specific language governing permissions and 204 | limitations under the License. 205 | --------------------------------------------------------------------------------