#problem with blocksBetween

1 messages · Page 1 of 1 (latest)

granite pagoda
#
loc1.blocksBetween(loc2),
``` does blocksBetween get removed?
untold flame
#

BlockLocation class was removed check the #1085606630135181423

#

changelog

untold flame
#

if u want basic implementation

#

find every min and max axis of each dimension and use for loops to foreach it

granite pagoda
#

like this ```js
function betweenXYZ(XYZa, XYZb, XYZc) {
return XYZc.every(
(c, i) => c >= Math.min(XYZa[i], XYZb[i]) && c <= Math.max(XYZa[i], XYZb[i])
)
}

untold flame
#

u need location from and location to

#

so two locations

granite pagoda
#

XYZa, XYZb

#

its a and b

untold flame
#

oh

#

idk what .every do so cant confirm

granite pagoda
#

do you have any changes about XYZc i want to remove it

untold flame
#

i have no idea what it does

granite pagoda
untold flame
#

Idk ¯_(ツ)_/¯

#

i could send my if u want, but use urs if that works

granite pagoda
#

nope i tried it with foreach did also not working

granite pagoda
untold flame
#
function *square({x:x1,y = 0,z:z1}, {x:x2 = 0,z:z2 = 0} = {}){
   const xMin = (x1 - x2)/2, xMax = xMin + x2, zMin = (z1 - z2)/2, zMax = zMin + z2;
   for (let x = 0; x < x1; x++)
       if(x < xMin || x > xMax) for (let z = 0; z < z1; z++)
           if(z < zMin || z > zMax) yield {x,y,z}
}
function *cube({x,y:yS,z},{x:x2 = 0,y:y2 = 0,z:z2 = 0} = {}){
   const yMin = (yS - y2)/2, yMax = yMin + y2;
   for (let y = 0; y < yS; y++)
       if(y < yMin || y > yMax) yield* this.square({x,y,z},{x:x2,z:z2});
}

usage

for(const loc of cube(location1, location2)){
  //code here use for each location
}
granite pagoda
# untold flame ```js function *square({x:x1,y = 0,z:z1}, {x:x2 = 0,z:z2 = 0} = {}){ const xM...
    fillBlocks(randomPerms) {
        const blockDATA = [],
            { dim, blockGroups, current, positions: [loc1, loc2] } = this,
            locations = cube(loc1, loc2),
            { floor, random } = Math,
            { length: randSize } = randomPerms,
            { length: size } = blockGroups;
        if (!size) {
            const firstPerms = Array.from(locations, loc => (
                {
                    loc, perm: dim.getBlock(loc).permutation.clone()
                }
            ))
            blockGroups.push(firstPerms)
        }
        for (const loc of cube(loc1, loc2)) {
            const perm = randomPerms[floor(random() * randSize)]
            dim.getBlock(loc).setPermutation(perm)
            blockDATA.push({ loc, perm })
        }
        if (current > size) blockGroups.splice(current, size)
        blockGroups.push(blockDATA)
        this.blockGroups = blockGroups
        this.current = blockGroups.length - 1
    }
```can you change it idk where
untold flame
#

ur already have it

#

¯_(ツ)_/¯

granite pagoda
#

but its doesn't wrl

#

work

untold flame
#

any errors?

granite pagoda
#

nope

untold flame
#

try console.warn("test") inside the loop

granite pagoda
#

its doesn't show any error

#

s

#

ore the console warn

#

i think its bc of this ```js
{ dim, blockGroups, current, positions: [loc1, loc2] } = this,
locations = cube(loc1, loc2),
/\

untold flame
#

oh

#

but its still should work

granite pagoda
#

nope

#

idk why

#

i tried this what the guy said its also not working

untold flame
#

u should for each locations between once

granite pagoda
#
    fillBlocks(randomPerms) {
        const blockDATA = [],
            { dim, blockGroups, current, positions: [loc1, loc2] } = this,
            
            locations = loc1.blocksBetween(loc2),
            { floor, random } = Math,
            { length: randSize } = randomPerms,
            { length: size } = blockGroups;
        if (!size) {
            const firstPerms = Array.from(locations, loc => (
                {
                    loc, perm: dim.getBlock(loc).permutation.clone()
                }
            ))
            blockGroups.push(firstPerms)
        }
        for (const loc of locations) {
            const perm = randomPerms[floor(random() * randSize)]
            dim.getBlock(loc).setPermutation(perm)
            blockDATA.push({ loc, perm })
        }
        if (current > size) blockGroups.splice(current, size)
        blockGroups.push(blockDATA)
        this.blockGroups = blockGroups
        this.current = blockGroups.length - 1
    }
```ID get it
#

im to dump

severe scarab
#
import { Vector } from "@minecraft/server";

Object.defineProperty(Vector, 'blocksBetween', {
    value(loc1,loc2) {
        const locations = []
        const { x: min_x, y: min_y, z: min_z } = this.min(loc1, loc2)
        const { x: max_x, y: max_y, z: max_z } = this.max(loc1, loc2)

        for (let x = min_x; x < max_x + 1; x++) {
            for (let y = min_y; y < max_y + 1; y++) {
                for (let z = min_z; z < max_z + 1; z++) {
                    locations.push({ x, y, z })
                }
            }
        }
        return locations
    }
})

import './file1'
import './file2'
import './file3'
```usage```js
const locsA = Vector.blocksBetween({ x, y, z }, { x: 0, y: 0, z: 0 })
const locsB = Vector.blocksBetween({ x: 0, y: 0, z: 0 }, new Vector(0, 0, 0))
const locsC = Vector.blocksBetween(new Vector(0, 0, 0), { x, y, z })
```just leaving this here
granite pagoda
severe scarab
#

sounds great