Files

54 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.
# pirt2.js — runProjectile() (satır 166)
[← pirt2.js](index.md) · [← Master](../../wiki.md)
Parça 2/4 · [önceki](runProjectile.md) · [sonraki](runProjectile-3.md)
```javascript
hitPos = ray.getHitPosition();
}
} else if (ray.isBlock()) {
didHit = true;
hitPos = ray.getHitPosition();
}
}
if (didHit && hitPos !== null) {
var cx = Math.floor(hitPos.x);
var cy = Math.floor(hitPos.y);
var cz = Math.floor(hitPos.z);
var radius = SPELL_CONFIG.CRATER_RADIUS;
var rSq = radius * radius;
c.setValue("hitCx", cx);
c.setValue("hitCy", cy);
c.setValue("hitCz", cz);
// 1. Krateri o bölgede temizle (Patlama oyuğu oluşturur - kalıcı!)
for (var dx = -radius; dx <= radius; dx++) {
for (var dy = -radius; dy <= radius; dy++) {
for (var dz = -radius; dz <= radius; dz++) {
if (dx*dx + dy*dy + dz*dz <= rSq) {
var bx = cx + dx;
var by = cy + dy;
var bz = cz + dz;
if (by >= 0 && by <= 255) {
var state = world.getBlock(bx, by, bz);
if (state !== null && !state.isAir()) {
world.removeBlock(bx, by, bz);
}
}
}
}
}
}
// Merkezde gerçek bir yıldırımı tetikle
world.spawnEntity("minecraft:lightning_bolt", hitPos.x, hitPos.y, hitPos.z);
// Hasar uygula
var hitEntities = world.getEntities(cx, cy, cz, SPELL_CONFIG.DAMAGE_RADIUS * 1.0);
if (hitEntities !== null) {
```