From 9a40363c1f133c2aeb15c29c21874a3758ef2763 Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Sun, 20 Apr 2025 20:41:39 -0700 Subject: [PATCH] add github usage & an error type --- .../scripts/classes/Errors/InstanceNotPlacedError.js | 6 ++++++ .../scripts/classes/Instance/StructureInstance.js | 9 +++++---- README.md | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 Construct [BP]/scripts/classes/Errors/InstanceNotPlacedError.js diff --git a/Construct [BP]/scripts/classes/Errors/InstanceNotPlacedError.js b/Construct [BP]/scripts/classes/Errors/InstanceNotPlacedError.js new file mode 100644 index 0000000..9d6738d --- /dev/null +++ b/Construct [BP]/scripts/classes/Errors/InstanceNotPlacedError.js @@ -0,0 +1,6 @@ +export class InstanceNotPlacedError extends Error { + constructor(message) { + super(message); + this.name = 'InstanceNotPlacedError'; + } +} \ No newline at end of file diff --git a/Construct [BP]/scripts/classes/Instance/StructureInstance.js b/Construct [BP]/scripts/classes/Instance/StructureInstance.js index 4835317..76d7738 100644 --- a/Construct [BP]/scripts/classes/Instance/StructureInstance.js +++ b/Construct [BP]/scripts/classes/Instance/StructureInstance.js @@ -4,6 +4,7 @@ import { StructureVerifier } from "../Verifier/StructureVerifier"; import { Structure } from "../Structure/Structure"; import { InstanceOptions } from "./InstanceOptions"; import { TicksPerSecond } from "@minecraft/server"; +import { InstanceNotPlacedError } from "../Errors/InstanceNotPlacedError"; export class StructureInstance { options; @@ -70,7 +71,7 @@ export class StructureInstance { getActiveBounds() { if (!this.options.isEnabled) - throw new Error(`[Construct] Instance '${this.options.instanceName}' is not placed.`); + throw new InstanceNotPlacedError(`[Construct] Instance '${this.options.instanceName}' is not placed.`); if (this.hasLayerSelected()) return this.getLayerBounds(this.getLayer()); return this.getBounds(); @@ -78,7 +79,7 @@ export class StructureInstance { getLayerBounds(layer) { if (!this.options.isEnabled) - throw new Error(`[Construct] Instance '${this.options.instanceName}' is not placed.`); + throw new InstanceNotPlacedError(`[Construct] Instance '${this.options.instanceName}' is not placed.`); const min = this.structure.getMin(); const max = this.structure.getMax(); return { @@ -105,7 +106,7 @@ export class StructureInstance { getActiveBlocks() { if (!this.options.isEnabled) - throw new Error(`[Construct] Instance '${this.options.instanceName}' is not placed.`); + throw new InstanceNotPlacedError(`[Construct] Instance '${this.options.instanceName}' is not placed.`); if (this.hasLayerSelected()) return this.getLayerBlocks(this.getLayer()); return this.getAllBlocks(); @@ -126,7 +127,7 @@ export class StructureInstance { getAllActiveLocations() { if (!this.options.isEnabled) - throw new Error(`[Construct] Instance '${this.options.instanceName}' is not placed.`); + throw new InstanceNotPlacedError(`[Construct] Instance '${this.options.instanceName}' is not placed.`); if (this.hasLayerSelected()) return this.structure.getLayerLocations(this.getLayer()-1); else diff --git a/README.md b/README.md index c2c27a8..63d238a 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Give yourself the tools to ease the survival building process with Construct: an ## Usage +Construct's latest release can be downloaded from its [Releases Page](https://github.com/ForestOfLight/Construct/releases) right here on GitHub. Install it just like any other addon, though make sure the Beta APIs experiment is enabled! + ### Construct Menu The main Construct menu can be accessed using a `paper` item. Using it will open a GUI where you can manage your structures instances. You can create new instances of structures, edit existing ones, and delete them when you no longer need them. There are plenty options available to customize your building style, including the ability build in layers.