Form Error handling & small code cleanup

This commit is contained in:
ForestOfLight
2025-04-13 14:27:41 -07:00
Unverified
parent b74362166f
commit 1a56192682
7 changed files with 31 additions and 23 deletions
+10 -5
View File
@@ -10,9 +10,8 @@ export class Raycaster {
let location = startLocation;
let distance = 0;
while (distance < maxDistance) {
const locatedStructures = structureCollection.getStructures(dimension.id, location, { useLayers });
if (locatedStructures.length !== 0) {
const structure = locatedStructures[0];
const structure = structureCollection.getStructure(dimension.id, location, { useLayers });
if (structure) {
const block = structure.getBlock(structure.toStructureCoords(location));
if (block?.type.id !== 'minecraft:air') {
blocks.push({
@@ -22,8 +21,14 @@ export class Raycaster {
if (getFirst)
break;
}
if (collideWithWorldBlocks && !dimension.getBlock(location)?.isAir)
break;
try {
if (collideWithWorldBlocks && !dimension.getBlock(location)?.isAir)
break;
} catch (e) {
if (e.name === 'LocationOutOfWorldBoundariesError')
break;
throw e;
}
}
location = {
x: location.x + (direction.x*this.STEP_SIZE),