October 2014
Beginner to intermediate
285 pages
6h 24m
English
Canary provides a very handy feature in net.canarymod.BlockIterator. A BlockIterator lets you find all the blocks along a line in the game. Most useful is probably the version where you pass in a LineTracer (made from a Player) and a boolean, which is declared in the Canary API like this:[25]
| | public BlockIterator(LineTracer tracer, boolean include_air) |
That gives you a BlockIterator object, which you can use to retrieve blocks along the line of sight from that entity. The boolean flag says to include Air blocks, and it works like this:
| | BlockIterator sightItr = new BlockIterator(new LineTracer(me), true); |
| | while (sightItr.hasNext()) { |
| | Block b = sightItr.next(); |
| | // do something with this block, ... |
Read now
Unlock full access