public boolean cast(Player player, String[] command) { if (removeReagents(player, reagents)) { // reagents removed - cast spell // get targeted block HitBlox hit = new HitBlox(player); Block target = hit.getTargetBlock(); // remove blocks around target block Server s = etc.getServer(); for (int x = target.getX() - BLAST_RADIUS; x <= target.getX() + BLAST_RADIUS; x++) { for (int y = target.getY() - BLAST_RADIUS; y <= target.getY() + BLAST_RADIUS; y++) { for (int z = target.getZ() - BLAST_RADIUS; z <= target.getZ() + BLAST_RADIUS; z++) { s.setBlockAt(0, x, y, z); } } } // send alerts player.sendMessage(TEXT_COLOR + STR_CAST); sendMessageToPlayersInRange(player, STR_CAST_OTHERS); return true; } else { // reagents missing player.sendMessage(TEXT_COLOR + STR_NO_REAGENTS); return false; } }
@SuppressWarnings("unchecked") @Override public int loop() { synchronized (lock) { try { if (!ui.isVisible()) handler.stopMod(getName()); World world = minecraft.getWorld(); JTable list = ui.getList(); DefaultTableModel model = (DefaultTableModel) list.getModel(); TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter(); if (world != null) { Player currentPlayer = minecraft.getPlayer(); int playerX = (int) java.lang.Math.round(currentPlayer.getX()); int playerY = (int) java.lang.Math.round(currentPlayer.getY()); int playerZ = (int) java.lang.Math.round(currentPlayer.getZ()); ArrayList<Block> blocks = new ArrayList<Block>(); for (int x = playerX - radius; x < playerX + radius; x++) for (int y = playerY - radius; y < playerY + radius; y++) for (int z = playerZ - radius; z < playerZ + radius; z++) if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z)); label: for (int row = 0; row < model.getRowCount(); row++) { int x = (Integer) model.getValueAt(row, 1); int y = (Integer) model.getValueAt(row, 2); int z = (Integer) model.getValueAt(row, 3); for (Block block : blocks) { if (x == block.getX() && y == block.getY() && z == block.getZ()) { model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0); continue label; } } model.removeRow(row); } label: for (Block block : blocks) { for (int row = 0; row < model.getRowCount(); row++) { int x = (Integer) model.getValueAt(row, 1); int y = (Integer) model.getValueAt(row, 2); int z = (Integer) model.getValueAt(row, 3); if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label; } model.addRow( new Object[] { getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()), block.getX(), block.getY(), block.getZ() }); } sorter.sort(); list.repaint(); } else { for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i); } } catch (Exception exception) { } } return 500; }
public void onBlockRightClicked(Player player, Block blockClicked, Item item) { SensorBlock s = GetSensorAt(new Location(blockClicked.getX(), blockClicked.getY(), blockClicked.getZ())); if (s != null) { s.OnRightClickSign(); } }
public boolean onBlockBreak(Player player, Block block) { if (block.blockType == Block.Type.WallSign) { // remove sensor with that sign location SensorBlock s = GetSensorAt(new Location(block.getX(), block.getY(), block.getZ())); if (s != null) { mSensorList.remove(s); player.sendMessage(mMessagePrefix + "You removed a sensor."); Save(); } } return false; }
public void onArmSwing(Player player) { // If holding a block, left click to place anywhere! if ((player.canUseCommand("/ion_cannon")) && (cannons.containsKey(player.getName()))) { HitBlox blox = new HitBlox(player); Block block = blox.getTargetBlock(); if (block == null) return; player.sendMessage("BOOM"); int size = ((Integer) cannons.get(player.getName())).intValue(); cannons.remove(player.getName()); // int beamType = 1; int beamType = 46; int borderType = 57; // int i = block.getY(); for (int i = 0; i < 128; i++) { circleMidpoint(block.getX(), block.getZ(), size, i, borderType); circleMidpoint(block.getX(), block.getZ(), size - 1, i, beamType); } circleMidpoint(block.getX(), block.getZ(), size, 0, 7); cylinderModpoint(block.getX(), block.getZ(), size + 1, 0, 7); etc.getServer().setBlockAt(51, block.getX(), 127, block.getZ()); } }
public boolean onBlockCreate( Player player, Block blockPlaced, Block blockClicked, int itemInHand) { if ((itemInHand == 283) && player.canUseCommand("/saveStargate")) { Integer whichPoint = StargateData.setPoint( player.getName(), blockClicked.getX(), blockClicked.getY(), blockClicked.getZ()); if (whichPoint == 2) { player.sendMessage("First corner of teleport area set"); } else if (whichPoint == 3) { player.sendMessage("Second corner of teleport area set"); } else if (whichPoint == 4) { player.sendMessage("First corner of landing area set"); } else { player.sendMessage("Second corner of landing area set"); } return true; } return false; }
public void runeCreated(Player player, Block blockPlaced, Block blockClicked, int itemInHand) { int[][][] steps = { {{4, 4, 4, 4, 4}, {4, 0, 0, 4, 4}, {4, 50, 4, 67, 4}, {4, 0, 0, 0, 4}, {4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4}, {4, 4, 67, 0, 4}, {4, 0, 4, 0, 4}, {4, 0, 50, 0, 4}, {4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4}, {4, 0, 0, 0, 4}, {4, 67, 4, 50, 4}, {4, 4, 0, 0, 4}, {4, 4, 4, 4, 4}}, {{4, 4, 4, 4, 4}, {4, 0, 50, 0, 4}, {4, 0, 4, 0, 4}, {4, 0, 67, 4, 4}, {4, 4, 4, 4, 4}} }; player.sendMessage("StairTower!"); for (int y = 0; y < 16; y++) for (int x = 0; x < 5; x++) for (int z = 0; z < 5; z++) { if (y >= 2 || (z != 4 || x != 2)) etc.getServer() .setBlockAt( steps[y % 4][z][x], blockClicked.getX() + x - 2, blockClicked.getY() + 1 + y, blockClicked.getZ() + z - 2); } }
/** * Checks if the provided block is being indirectly powered through redstone * * @param block Block to check * @return true if the block is being indirectly powered */ public boolean isBlockIndirectlyPowered(Block block) { return isBlockIndirectlyPowered(block.getX(), block.getY(), block.getZ()); }
/** * Loads the chunk containing the given block. If the chunk does not exist, it will be generated. * * @param block the Block to check */ public void loadChunk(Block block) { loadChunk(block.getX(), block.getY(), block.getZ()); }
/** * Checks to see whether or not the chunk containing the given block is loaded into memory. * * @param block the Block to check * @return true if the chunk is loaded */ public boolean isChunkLoaded(Block block) { return isChunkLoaded(block.getX(), block.getY(), block.getZ()); }
/** * Forces the server to update the physics for blocks around the given block * * @param block the block that changed */ public void updateBlockPhysics(Block block) { updateBlockPhysics(block.getX(), block.getY(), block.getZ(), block.getData()); }
/** * Returns the only complex block at the specified location. Null if there's no complex block * there. * * @param block * @return complex block */ public ComplexBlock getOnlyComplexBlock(Block block) { return getOnlyComplexBlock(block.getX(), block.getY(), block.getZ()); }
/** * Sets the block * * @param block * @return */ public boolean setBlock(Block block) { return setBlockAt(block.getType(), block.getX(), block.getY(), block.getZ()) && setBlockData(block.getX(), block.getY(), block.getZ(), block.getData()); }