public void updateFlag() { DyeColor[] woolColors = TownyWarConfig.getWoolColors(); if (flagColorId < woolColors.length) { System.out.println( String.format( "Flag at %s turned %s.", getCellString(), woolColors[flagColorId].toString())); int woolId = Material.WOOL.getId(); byte woolData = woolColors[flagColorId].getData(); flagBlock.setTypeIdAndData(woolId, woolData, true); for (Block block : beaconFlagBlocks) block.setTypeIdAndData(woolId, woolData, true); } }
public byte[] generate(World world, Random rand, int chunkX, int chunkZ) { byte[] blocks = new byte[32768]; int x, y, z; for (x = 0; x < 16; x++) { for (z = 0; z < 16; z++) { blocks[this.coordsToInt(x, 0, z)] = (byte) Material.BEDROCK.getId(); for (y = 1; y < 20; y++) { blocks[this.coordsToInt(x, y, z)] = (byte) Material.DIRT.getId(); } // this will make a checkerboard if ((x + z) % 2 == 1) blocks[this.coordsToInt(x, 20, z)] = (byte) Material.OBSIDIAN.getId(); else blocks[this.coordsToInt(x, 20, z)] = (byte) Material.WOOL.getId(); // chess pieces, randomly per side if (rand.nextInt(20) < 2) { if (rand.nextInt(20) < 10) { blocks[this.coordsToInt(x, 21, z)] = (byte) Material.STONE.getId(); blocks[this.coordsToInt(x, 22, z)] = (byte) Material.STONE.getId(); blocks[this.coordsToInt(x, 23, z)] = (byte) Material.STONE.getId(); } else { blocks[this.coordsToInt(x, 21, z)] = (byte) Material.SAND.getId(); blocks[this.coordsToInt(x, 22, z)] = (byte) Material.SAND.getId(); blocks[this.coordsToInt(x, 23, z)] = (byte) Material.SAND.getId(); } } // lava/glass ceiling blocks[this.coordsToInt(x, 40, z)] = (byte) Material.GLASS.getId(); blocks[this.coordsToInt(x, 41, z)] = (byte) Material.LAVA.getId(); } } return blocks; }
public static int matchItemData(int id, String filter) { // Missing some key code, need to be finished sometime in future. try { return Integer.parseInt(filter); } catch (NumberFormatException ignored) { } if (Material.WOOD.getId() == id) { for (TreeSpecies search : TreeSpecies.values()) { if (filter.equalsIgnoreCase(search.toString())) { return search.getData(); } } return 0; } else if (Material.WOOL.getId() == id) { for (DyeColor search : DyeColor.values()) { if (filter.equalsIgnoreCase(search.toString())) { return search.getWoolData(); } } return 0; } else if (Material.INK_SACK.getId() == id) { for (DyeColor search : DyeColor.values()) { if (filter.equalsIgnoreCase(search.toString())) { return search.getDyeData(); } } return 0; } else if (Material.STEP.getId() == id) { Step s = new Step(); for (Material search : s.getTextures()) { if (filter.equalsIgnoreCase(search.toString())) { return s.getTextures().indexOf(search); } } return 0; } else if (Material.DOUBLE_STEP.getId() == id) { Step s = new Step(); for (Material search : s.getTextures()) { if (filter.equalsIgnoreCase(search.toString())) { return s.getTextures().indexOf(search); } } return 0; } else if (Material.SMOOTH_BRICK.getId() == id) { SmoothBrick s = new SmoothBrick(); for (Material search : s.getTextures()) { if (filter.equalsIgnoreCase(search.toString())) { return s.getTextures().indexOf(search); } } return 0; } return 0; }