Files

48 lines
1.9 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.
# pirt3.js — runProjectile() (satır 166)
[← pirt3.js](index.md) · [← Master](../../wiki.md)
Parça 2/6 · [önceki](runProjectile.md) · [sonraki](runProjectile-3.md)
```javascript
var radius = SPELL_CONFIG.CRATER_RADIUS;
var rSq = radius * radius;
c.setValue("hitCx", cx);
c.setValue("hitCy", cy);
c.setValue("hitCz", cz);
var blocks = [];
var idMap = {};
var idList = [];
var minY = 999;
var maxY = -999;
// 1. Krater oluşmadan önce zemin bloklarını kaydet
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()) {
var id = state.getBlockId();
var idIdx = idMap[id];
if (idIdx === undefined) {
idIdx = idList.length;
idMap[id] = idIdx;
idList.push(id);
}
blocks.push(bx);
blocks.push(by);
blocks.push(bz);
blocks.push(idIdx);
blocks.push(state.getMeta());
if (by < minY) minY = by;
```