#replacing and giving blocks
1 messages · Page 1 of 1 (latest)
this should work
function destroyRegionToContainer(container: Container, dimension: Dimension, v1: Vector3, v2: Vector3): void {
const startLocation = { x: Math.min(v1.x, v2.x ), y: Math.min(v1.y, v2.y ), z: Math.min(v1.z, v2.z ) };
const endLocation = { x: Math.max(v1.x, v2.x ), y: Math.max(v1.y, v2.y ), z: Math.max(v1.z, v2.z ) };
for (let x = startLocation.x; x <= endLocation.x; x++) {
for (let y = startLocation.y; y <= endLocation.y; y++) {
for (let z = startLocation.z; z <= endLocation.z; z++) {
const block = dimension.getBlock({ x: x, y: y, z: z });
if (block === undefined || block?.typeId === "minecraft:air") continue;
const itemStack = block.getItemStack();
if (itemStack === undefined) continue;
container.addItem(itemStack);
block.setPermutation(BlockPermutation.resolve("minecraft:air"));
}
}
}
}
wait stable you guys dont have typeid
function destroyRegionToContainer(container: Container, dimension: Dimension, v1: Vector3, v2: Vector3): void {
const startLocation = { x: Math.min(v1.x, v2.x ), y: Math.min(v1.y, v2.y ), z: Math.min(v1.z, v2.z ) };
const endLocation = { x: Math.max(v1.x, v2.x ), y: Math.max(v1.y, v2.y ), z: Math.max(v1.z, v2.z ) };
const permutation = BlockPermutation.resolve("minecraft:air");
for (let x = startLocation.x; x <= endLocation.x; x++) {
for (let y = startLocation.y; y <= endLocation.y; y++) {
for (let z = startLocation.z; z <= endLocation.z; z++) {
const block = dimension.getBlock({ x: x, y: y, z: z });
if (block === undefined || block.permutation.matches("minecraft:air")) continue;
const itemStack = block.getItemStack();
if (itemStack === undefined) continue;
container.addItem(itemStack);
block.setPermutation(permutation);
}
}
}
}
i’m in beta
ah saw you stable so thought you meant stable ver
just use this then