Skip to content

Instantly share code, notes, and snippets.

@Coding-Kiwi
Created January 14, 2014 18:49

Revisions

  1. @KiwiLetsPlay KiwiLetsPlay created this gist Jan 14, 2014.
    13 changes: 13 additions & 0 deletions gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    private static final boolean seesMoon(LivingEntity e) {
    final BlockIterator bi = new BlockIterator(e.getWorld(), e.getEyeLocation().toVector(),
    e.getLocation().getDirection(), 0.0, 0);
    boolean sees = true;
    while (bi.hasNext()) {
    final Block block = bi.next();
    if (block.getType() != Material.AIR) {
    sees = false;
    if (block.getType() == Material.BEDROCK && !bi.hasNext()) {sees = true;}
    }
    }
    return sees;
    }