Gets the percentage of real blocks within within a bounding box, along a specified vector.
(Vec3 vec, AxisAlignedBB bb)
| 2223 | * Gets the percentage of real blocks within within a bounding box, along a specified vector. |
| 2224 | */ |
| 2225 | public float getBlockDensity(Vec3 vec, AxisAlignedBB bb) |
| 2226 | { |
| 2227 | double d0 = 1.0D / ((bb.maxX - bb.minX) * 2.0D + 1.0D); |
| 2228 | double d1 = 1.0D / ((bb.maxY - bb.minY) * 2.0D + 1.0D); |
| 2229 | double d2 = 1.0D / ((bb.maxZ - bb.minZ) * 2.0D + 1.0D); |
| 2230 | double d3 = (1.0D - Math.floor(1.0D / d0) * d0) / 2.0D; |
| 2231 | double d4 = (1.0D - Math.floor(1.0D / d2) * d2) / 2.0D; |
| 2232 | |
| 2233 | if (d0 >= 0.0D && d1 >= 0.0D && d2 >= 0.0D) |
| 2234 | { |
| 2235 | int i = 0; |
| 2236 | int j = 0; |
| 2237 | |
| 2238 | for (float f = 0.0F; f <= 1.0F; f = (float)((double)f + d0)) |
| 2239 | { |
| 2240 | for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float)((double)f1 + d1)) |
| 2241 | { |
| 2242 | for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float)((double)f2 + d2)) |
| 2243 | { |
| 2244 | double d5 = bb.minX + (bb.maxX - bb.minX) * (double)f; |
| 2245 | double d6 = bb.minY + (bb.maxY - bb.minY) * (double)f1; |
| 2246 | double d7 = bb.minZ + (bb.maxZ - bb.minZ) * (double)f2; |
| 2247 | |
| 2248 | if (this.rayTraceBlocks(new Vec3(d5 + d3, d6, d7 + d4), vec) == null) |
| 2249 | { |
| 2250 | ++i; |
| 2251 | } |
| 2252 | |
| 2253 | ++j; |
| 2254 | } |
| 2255 | } |
| 2256 | } |
| 2257 | |
| 2258 | return (float)i / (float)j; |
| 2259 | } |
| 2260 | else |
| 2261 | { |
| 2262 | return 0.0F; |
| 2263 | } |
| 2264 | } |
| 2265 | |
| 2266 | /** |
| 2267 | * Attempts to extinguish a fire |
no test coverage detected