├── README.md └── main ├── Side.java ├── BlockFace.java └── TextureFinder.java /README.md: -------------------------------------------------------------------------------- 1 | # TextureFinderJava 2 | -------------------------------------------------------------------------------- /main/Side.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | public enum Side { 4 | TOP, BOTTOM, WEST, EAST, SOUTH, NORTH 5 | } 6 | -------------------------------------------------------------------------------- /main/BlockFace.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | public class BlockFace 4 | { 5 | private int x, y, z, rotation; 6 | private Side side; 7 | 8 | public BlockFace(int x, int y, int z, Side side, int rotation) 9 | { 10 | this.x=x; 11 | this.y=y; 12 | this.z=z; 13 | this.side=side; 14 | this.rotation=rotation; 15 | } 16 | 17 | public int getX() {return x;} 18 | public int getY() {return y;} 19 | public int getZ() {return z;} 20 | public Side getSide() {return side;} 21 | public int getRotation() {return rotation;} 22 | } 23 | -------------------------------------------------------------------------------- /main/TextureFinder.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Random; 5 | 6 | public class TextureFinder 7 | { 8 | private static Random rand = new Random(); 9 | 10 | public static long getCoordinateRandom(int x, int y, int z) 11 | { 12 | long i = (long)(x * 3129871) ^ (long)z * 116129781L ^ (long)y; 13 | i = i * i * 42317861L + i * 11L; 14 | return i; 15 | } 16 | public static int getTextureType(int x, int y, int z, int version/*version selection, 3 == 1.13, 1.14, 2 == 1.12 and before*/) 17 | { 18 | if(version==2) 19 | return Math.abs((int)getCoordinateRandom(x, y, z) >> 16)%16; 20 | else 21 | { 22 | rand.setSeed(getCoordinateRandom(x, y, z)>>16); 23 | return (int)(Math.abs((int)((int)rand.nextLong())) % 16); 24 | } 25 | } 26 | 27 | public static boolean compatibleRotation(int generatedType, BlockFace bface) 28 | { 29 | if(generatedType == 0) 30 | { 31 | return bface.getRotation()==3; 32 | } 33 | if(generatedType == 1) 34 | { 35 | return (bface.getRotation()==3 && (bface.getSide()==Side.TOP||bface.getSide()==Side.SOUTH))|| 36 | (bface.getRotation()==2 && (bface.getSide()==Side.WEST))|| 37 | (bface.getRotation()==1 && (bface.getSide()==Side.BOTTOM||bface.getSide()==Side.NORTH))|| 38 | (bface.getRotation()==0 && (bface.getSide()==Side.EAST)); 39 | } 40 | if(generatedType == 2) 41 | { 42 | return (bface.getRotation()==3 && (bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM))|| 43 | (bface.getRotation()==1 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM)); 44 | } 45 | if(generatedType == 3) 46 | { 47 | return (bface.getRotation()==3 && (bface.getSide()==Side.BOTTOM||bface.getSide()==Side.SOUTH))|| 48 | (bface.getRotation()==2 && (bface.getSide()==Side.EAST))|| 49 | (bface.getRotation()==1 && (bface.getSide()==Side.TOP||bface.getSide()==Side.NORTH))|| 50 | (bface.getRotation()==0 && (bface.getSide()==Side.WEST)); 51 | } 52 | if(generatedType == 4) 53 | { 54 | return (bface.getRotation()==3 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM))|| 55 | (bface.getRotation()==2 && (bface.getSide()==Side.BOTTOM))|| 56 | (bface.getRotation()==0 && (bface.getSide()==Side.TOP)); 57 | } 58 | if(generatedType == 5) 59 | { 60 | return (bface.getRotation()==3 && (bface.getSide()==Side.WEST))|| 61 | (bface.getRotation()==2 && (bface.getSide()==Side.NORTH))|| 62 | (bface.getRotation()==1 && (bface.getSide()==Side.EAST))|| 63 | (bface.getRotation()==0 && (bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM||bface.getSide()==Side.SOUTH)); 64 | } 65 | if(generatedType == 6) 66 | { 67 | return (bface.getRotation()==1 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM))|| 68 | (bface.getRotation()==2 && (bface.getSide()==Side.BOTTOM))|| 69 | (bface.getRotation()==0 && (bface.getSide()==Side.TOP)); 70 | } 71 | if(generatedType == 7) 72 | { 73 | return (bface.getRotation()==3 && (bface.getSide()==Side.WEST))|| 74 | (bface.getRotation()==2 && (bface.getSide()==Side.SOUTH||bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM))|| 75 | (bface.getRotation()==1 && (bface.getSide()==Side.EAST))|| 76 | (bface.getRotation()==0 && (bface.getSide()==Side.NORTH)); 77 | } 78 | if(generatedType == 8) 79 | { 80 | return (bface.getRotation()==1 && (bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM))|| 81 | (bface.getRotation()==3 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM)); 82 | } 83 | if(generatedType == 9) 84 | { 85 | return (bface.getRotation()==3 && (bface.getSide()==Side.BOTTOM||bface.getSide()==Side.NORTH))|| 86 | (bface.getRotation()==2 && (bface.getSide()==Side.EAST))|| 87 | (bface.getRotation()==1 && (bface.getSide()==Side.TOP||bface.getSide()==Side.SOUTH))|| 88 | (bface.getRotation()==0 && (bface.getSide()==Side.WEST)); 89 | } 90 | if(generatedType == 10) 91 | { 92 | return bface.getRotation()==1; 93 | } 94 | if(generatedType == 11) 95 | { 96 | return (bface.getRotation()==3 && (bface.getSide()==Side.TOP||bface.getSide()==Side.NORTH))|| 97 | (bface.getRotation()==2 && (bface.getSide()==Side.WEST))|| 98 | (bface.getRotation()==1 && (bface.getSide()==Side.BOTTOM||bface.getSide()==Side.SOUTH))|| 99 | (bface.getRotation()==0 && (bface.getSide()==Side.EAST)); 100 | } 101 | if(generatedType == 12) 102 | { 103 | return (bface.getRotation()==3 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM))|| 104 | (bface.getRotation()==2 && (bface.getSide()==Side.TOP))|| 105 | (bface.getRotation()==0 && (bface.getSide()==Side.BOTTOM)); 106 | } 107 | if(generatedType == 13) 108 | { 109 | return (bface.getRotation()==3 && (bface.getSide()==Side.EAST))|| 110 | (bface.getRotation()==2 && (bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM||bface.getSide()==Side.SOUTH))|| 111 | (bface.getRotation()==1 && (bface.getSide()==Side.WEST))|| 112 | (bface.getRotation()==0 && (bface.getSide()==Side.NORTH)); 113 | } 114 | if(generatedType == 14) 115 | { 116 | return (bface.getRotation()==1 && (bface.getSide()!=Side.TOP&&bface.getSide()!=Side.BOTTOM))|| 117 | (bface.getRotation()==2 && (bface.getSide()==Side.TOP))|| 118 | (bface.getRotation()==0 && (bface.getSide()==Side.BOTTOM)); 119 | } 120 | if(generatedType == 15) 121 | { 122 | return (bface.getRotation()==3 && (bface.getSide()==Side.EAST))|| 123 | (bface.getRotation()==2 && (bface.getSide()==Side.NORTH))|| 124 | (bface.getRotation()==1 && (bface.getSide()==Side.WEST))|| 125 | (bface.getRotation()==0 && (bface.getSide()==Side.SOUTH||bface.getSide()==Side.TOP||bface.getSide()==Side.BOTTOM)); 126 | } 127 | return false; 128 | } 129 | 130 | public static void main(String[] args) 131 | { 132 | ArrayList formation = new ArrayList(); 133 | 134 | ArrayList> rotations = new ArrayList>(); 135 | 136 | /* 137 | * BUILD FORMATION 138 | * --------------- 139 | * EXAMPLE BELOW 140 | */ 141 | formation.add(new BlockFace(0, 0, 0, Side.BOTTOM, 3)); 142 | formation.add(new BlockFace(1, 0, 0, Side.BOTTOM, 1)); 143 | formation.add(new BlockFace(2, 0, 0, Side.BOTTOM, 3)); 144 | 145 | formation.add(new BlockFace(0, 0, 1, Side.BOTTOM, 1)); 146 | formation.add(new BlockFace(1, 0, 1, Side.BOTTOM, 3)); 147 | formation.add(new BlockFace(2, 0, 1, Side.BOTTOM, 0)); 148 | 149 | formation.add(new BlockFace(0, 0, 2, Side.BOTTOM, 0)); 150 | formation.add(new BlockFace(1, 0, 2, Side.BOTTOM, 1)); 151 | formation.add(new BlockFace(2, 0, 2, Side.BOTTOM, 3)); 152 | 153 | formation.add(new BlockFace(0, 0, 3, Side.BOTTOM, 2)); 154 | formation.add(new BlockFace(1, 0, 3, Side.BOTTOM, 1)); 155 | formation.add(new BlockFace(2, 0, 3, Side.BOTTOM, 3)); 156 | 157 | formation.add(new BlockFace(0, 0, 4, Side.BOTTOM, 3)); 158 | formation.add(new BlockFace(1, 0, 4, Side.BOTTOM, 2)); 159 | formation.add(new BlockFace(2, 0, 4, Side.BOTTOM, 3)); 160 | 161 | 162 | boolean useAllRotations = true;//set this to true if you don't know which direction is north 163 | 164 | rotations.add(formation); 165 | 166 | if(useAllRotations) 167 | { 168 | for(int i = 0; i < 3; i++) 169 | { 170 | rotations.add(rotate90deg(rotations.get(rotations.size()-1))); 171 | } 172 | } 173 | 174 | /*for(ArrayList f : rotations) 175 | { 176 | for(BlockFace b : f) 177 | { 178 | System.out.println(b.getX() + " " + b.getY() + " " + b.getZ() + " " + b.getSide().toString() + " " + b.getRotation()); 179 | } 180 | System.out.println(); 181 | }*/ 182 | 183 | 184 | 185 | long first=System.currentTimeMillis(); 186 | 187 | /* 188 | * SEARCH PARAMETERS 189 | * MODIFY THESE 190 | */ 191 | 192 | int xmin=-10000, xmax=10000; 193 | int zmin=-10000, zmax=10000; 194 | int ymin=59, ymax=59; 195 | 196 | for(int x = xmin; x <= xmax; x++) 197 | for(int z = zmin; z <= zmax; z++) 198 | for(int y = ymin; y <= ymax; y++) 199 | { 200 | for(ArrayList f : rotations) 201 | { 202 | 203 | boolean found=true; 204 | for(BlockFace b : f) 205 | { 206 | 207 | int texture = getTextureType(x + b.getX(), y+b.getY(), z+b.getZ(), 3/*version selection, 3 == 1.13, 1.14, 2 == 1.12 and before*/); 208 | 209 | if(!compatibleRotation(texture, b)) 210 | { 211 | found=false; 212 | break; 213 | } 214 | } 215 | if(found) System.out.println("X: "+x+ " Y: "+y+ " Z: "+z); 216 | 217 | } 218 | } 219 | 220 | 221 | System.out.println(((System.currentTimeMillis()-first)/1000) + " seconds"); 222 | } 223 | 224 | public static ArrayList rotate90deg(ArrayList formation) 225 | { 226 | ArrayList result = new ArrayList(); 227 | 228 | for(BlockFace b : formation) 229 | { 230 | Side newside = Side.NORTH; 231 | int rotation = -1; 232 | 233 | if (b.getSide() == Side.TOP) newside = Side.TOP; 234 | if (b.getSide() == Side.BOTTOM) newside = Side.BOTTOM; 235 | if (b.getSide() == Side.WEST) newside = Side.SOUTH; 236 | if (b.getSide() == Side.EAST) newside = Side.NORTH; 237 | if (b.getSide() == Side.SOUTH) newside = Side.EAST; 238 | if (b.getSide() == Side.NORTH) newside = Side.WEST; 239 | 240 | if(b.getSide() == Side.TOP) 241 | { 242 | rotation = (b.getRotation()+3)%4; 243 | } 244 | else if(b.getSide() == Side.BOTTOM) 245 | { 246 | rotation = (b.getRotation()+1)%4; 247 | } 248 | else 249 | { 250 | rotation = b.getRotation(); 251 | } 252 | 253 | result.add(new BlockFace(b.getZ(), b.getY(), -1*b.getX(), newside, rotation)); 254 | } 255 | 256 | return result; 257 | } 258 | } 259 | --------------------------------------------------------------------------------