private boolean blockRegolith(BlockType block, BlockType self) { if (block.equals(BlockTypes.DIRT) || block.equals(BlockTypes.GRASS) || block.equals(BlockTypes.GRAVEL) || block.equals(BlockTypes.SAND) || block.equals(self)) return true; else return false; }
private boolean blockStone(BlockType intermediate) { if (intermediate.equals(BlockTypes.STONE)) return true; else return false; }
private boolean blockAir(BlockType intermediate) { if (intermediate.equals(BlockTypes.AIR) || intermediate.equals(BlockTypes.WATER)) { return true; } else return false; }
public void registerBlocks() { blockMap = new BlockState[256][]; blockMapReverse = new HashMap<BlockState, PlotBlock>(); HashMap<String, BlockState> states = new HashMap<>(); PS.get().copyFile("ids.txt", "config"); PS.get().copyFile("data.txt", "config"); try { File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt"); List<String> id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8); File data_file = new File(getDirectory(), "config" + File.separator + "data.txt"); List<String> data_lines = Files.readAllLines(data_file.toPath(), StandardCharsets.UTF_8); Field[] fields = BlockTypes.class.getDeclaredFields(); for (Field field : fields) { BlockType type = (BlockType) field.get(null); BlockState state = type.getDefaultState(); if (state != null) { try { states.put(type.getId() + ":" + 0, state); } catch (Exception e) { } } } String packaze = "org.spongepowered.api.data.type."; for (int i = 0; i < data_lines.size(); i++) { String classname = packaze + data_lines.get(i).trim(); try { Class<?> clazz = Class.forName(classname); fields = clazz.getDeclaredFields(); for (Field field : fields) { CatalogType type = (CatalogType) field.get(null); String minecraft_id = type.getId(); BlockState state = states.get(minecraft_id + ":" + 0); if (state == null) { continue; } } } catch (Throwable e) { } } PlotBlock block = null; for (int i = 0; i < id_lines.size(); i++) { String line = id_lines.get(i).trim(); switch (i % 3) { case 0: { block = Configuration.BLOCK.parseString(line); break; } case 1: { break; } case 2: { String minecraft_id = line; BlockState state = states.remove(minecraft_id + ":" + block.data); if (state == null) { continue; } registerBlock(block, state); break; } } } for (Entry<String, BlockState> state : states.entrySet()) { log("REGISTERING: " + registerBlock(state.getValue()) + " | " + state.getValue().getType()); } } catch (Exception e) { e.printStackTrace(); } }