Files

43 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ezoic_radyasyon.js — destroySphere() (satır 111)
[← ezoic_radyasyon.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](destroySphere-2.md)
```javascript
function destroySphere(ctx, cx, cy, cz, radius, throwBlocks) {
var w = ctx.getWorld();
var airState = mappet.createBlockState("minecraft:air", 0);
var r2 = radius * radius;
var bxStart = Math.floor(cx - radius), bxEnd = Math.floor(cx + radius);
var byStart = Math.floor(cy - radius), byEnd = Math.floor(cy + radius);
var bzStart = Math.floor(cz - radius), bzEnd = Math.floor(cz + radius);
for (var x = bxStart; x <= bxEnd; x++) {
for (var y = byStart; y <= byEnd; y++) {
for (var z = bzStart; z <= bzEnd; z++) {
var ddx = x + 0.5 - cx;
var ddy = y + 0.5 - cy;
var ddz = z + 0.5 - cz;
var d2 = ddx*ddx + ddy*ddy + ddz*ddz;
if (d2 > r2) continue;
var bs = w.getBlock(x, y, z);
if (!bs) continue;
var bid = bs.getBlockId();
if (bid === "minecraft:air" || bid === "minecraft:bedrock" || bid === "minecraft:barrier") continue;
if (w.getTileEntity(x, y, z) !== null) continue;
var meta = bs.getMeta();
w.setBlock(airState, x, y, z);
if (throwBlocks && Math.random() < 0.35) {
var dist = Math.sqrt(d2);
if (dist < 0.01) dist = 0.01;
var force = 0.6 + Math.random() * 0.5;
spawnSafeFallingBlock(ctx,
x + 0.5, y + 0.5, z + 0.5, bid, meta,
(ddx/dist) * force,
0.35 + Math.random() * 0.4,
(ddz/dist) * force);
}
```