-
Notifications
You must be signed in to change notification settings - Fork 1
Structure Load
LLytho edited this page Oct 21, 2022
·
3 revisions
// for 1.18 pls use: onEvent("morejs.structure.load", (event) => { ... })
MoreJSEvents.structureLoad((event) => {
/**
* `event.id`: The id of the structure.
* `event.structureSize`: The size of the structure.
* `event.palettesSize`: The size of the palettes.
* `event.entitiesSize`: The size of the entities.
* `event.removePalette(index)`: Removes the palette at the given index. Throws exception if invalid index!
* `event.getPalette(index)`: Returns the palette at the given index. Throws exception if invalid index!
* `event.forEachPalettes((palette) => { ... })`: Iterates over all palettes.
* `event.entities`: The entities in the structure.
*/
const palette = event.getPalette(0);
palette.clear(); // clear all blocks in the palette
/**
* Adds a block at 0, 0, 0 to the palette.
*/
palette.add([0, 0, 0], Block.id("minecraft:diamond_block"));
// palette.add(pos, block, nbt); -> adds a block with nbt to the palette
/**
* Block data holds the block data for a block at a certain position in the structure.
* - `.block`: Returns the block
* - `.id`: Returns the id of the block
* - `.setBlock(id)`: Sets the block
* - `.setBlock(id, properties)`: Sets the block and sets the properties
* - `.properties`: Returns the properties of the block
* - `.hasNbt()`: Returns true if the block has nbt data
* - `.nbt`: Returns the nbt data
*/
const blockData = palette.get([0, 0, 0]); // get the block data at [0, 0, 0]
palette.forEach((blockData) => {
// iterate over all blocks in the palette.
});
palette.removeIf((blockData) => {
// Check for the blockData and return true if this block should be removed.
return true / false;
});
});