add github usage & an error type

This commit is contained in:
ForestOfLight
2025-04-20 20:41:39 -07:00
Unverified
parent 2fc881c22a
commit 9a40363c1f
3 changed files with 13 additions and 4 deletions
@@ -0,0 +1,6 @@
export class InstanceNotPlacedError extends Error {
constructor(message) {
super(message);
this.name = 'InstanceNotPlacedError';
}
}
@@ -4,6 +4,7 @@ import { StructureVerifier } from "../Verifier/StructureVerifier";
import { Structure } from "../Structure/Structure"; import { Structure } from "../Structure/Structure";
import { InstanceOptions } from "./InstanceOptions"; import { InstanceOptions } from "./InstanceOptions";
import { TicksPerSecond } from "@minecraft/server"; import { TicksPerSecond } from "@minecraft/server";
import { InstanceNotPlacedError } from "../Errors/InstanceNotPlacedError";
export class StructureInstance { export class StructureInstance {
options; options;
@@ -70,7 +71,7 @@ export class StructureInstance {
getActiveBounds() { getActiveBounds() {
if (!this.options.isEnabled) 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()) if (this.hasLayerSelected())
return this.getLayerBounds(this.getLayer()); return this.getLayerBounds(this.getLayer());
return this.getBounds(); return this.getBounds();
@@ -78,7 +79,7 @@ export class StructureInstance {
getLayerBounds(layer) { getLayerBounds(layer) {
if (!this.options.isEnabled) 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 min = this.structure.getMin();
const max = this.structure.getMax(); const max = this.structure.getMax();
return { return {
@@ -105,7 +106,7 @@ export class StructureInstance {
getActiveBlocks() { getActiveBlocks() {
if (!this.options.isEnabled) 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()) if (this.hasLayerSelected())
return this.getLayerBlocks(this.getLayer()); return this.getLayerBlocks(this.getLayer());
return this.getAllBlocks(); return this.getAllBlocks();
@@ -126,7 +127,7 @@ export class StructureInstance {
getAllActiveLocations() { getAllActiveLocations() {
if (!this.options.isEnabled) 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()) if (this.hasLayerSelected())
return this.structure.getLayerLocations(this.getLayer()-1); return this.structure.getLayerLocations(this.getLayer()-1);
else else
+2
View File
@@ -26,6 +26,8 @@ Give yourself the tools to ease the survival building process with Construct: an
## Usage ## 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 ### 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. 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.