Java Code Examples for cn.nukkit.utils.BlockIterator#next()
The following examples show how to use
cn.nukkit.utils.BlockIterator#next() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityLiving.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public Block[] getLineOfSight(int maxDistance, int maxLength, Integer[] transparent) { if (maxDistance > 120) { maxDistance = 120; } if (transparent != null && transparent.length == 0) { transparent = null; } List<Block> blocks = new ArrayList<>(); BlockIterator itr = new BlockIterator(this.level, this.getPosition(), this.getDirectionVector(), this.getEyeHeight(), maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } int id = block.getId(); if (transparent == null) { if (id != 0) { break; } } else { if (Arrays.binarySearch(transparent, id) < 0) { break; } } } return blocks.stream().toArray(Block[]::new); }
Example 2
Source File: EntityLiving.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Block[] getLineOfSight(int maxDistance, int maxLength, Integer[] transparent) { if (maxDistance > 120) { maxDistance = 120; } if (transparent != null && transparent.length == 0) { transparent = null; } List<Block> blocks = new ArrayList<>(); BlockIterator itr = new BlockIterator(this.level, this.getPosition(), this.getDirectionVector(), this.getEyeHeight(), maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } int id = block.getId(); if (transparent == null) { if (id != 0) { break; } } else { if (Arrays.binarySearch(transparent, id) < 0) { break; } } } return blocks.toArray(new Block[0]); }
Example 3
Source File: EntityLiving.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Block[] getLineOfSight(int maxDistance, int maxLength, Integer[] transparent) { if (maxDistance > 120) { maxDistance = 120; } if (transparent != null && transparent.length == 0) { transparent = null; } List<Block> blocks = new ArrayList<>(); BlockIterator itr = new BlockIterator(this.level, this.getPosition(), this.getDirectionVector(), this.getEyeHeight(), maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } int id = block.getId(); if (transparent == null) { if (id != 0) { break; } } else { if (Arrays.binarySearch(transparent, id) < 0) { break; } } } return blocks.stream().toArray(Block[]::new); }