mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-09-03 21:03:10 +02:00
add ladder
This commit is contained in:
parent
a03e46e56b
commit
84cdb0f6fa
2 changed files with 33 additions and 7 deletions
|
@ -78,7 +78,7 @@ export function autoBuild(blueprint) {
|
||||||
let minZ = Infinity, maxZ = -Infinity;
|
let minZ = Infinity, maxZ = -Infinity;
|
||||||
|
|
||||||
for (const level of blueprint.levels) {
|
for (const level of blueprint.levels) {
|
||||||
console.log(level.level)
|
// console.log(level.level)
|
||||||
const baseX = level.coordinates[0];
|
const baseX = level.coordinates[0];
|
||||||
const baseY = level.coordinates[1];
|
const baseY = level.coordinates[1];
|
||||||
const baseZ = level.coordinates[2];
|
const baseZ = level.coordinates[2];
|
||||||
|
|
|
@ -198,7 +198,6 @@ function generateSequentialRooms(m=20, n=20, p=20, rooms=8) {
|
||||||
const z = newZ + di;
|
const z = newZ + di;
|
||||||
|
|
||||||
// If this is at a matrix border, don't modify it
|
// If this is at a matrix border, don't modify it
|
||||||
// todo: change to be window
|
|
||||||
if (x === 0 || x === m - 1 ||
|
if (x === 0 || x === m - 1 ||
|
||||||
y === 0 || y === n - 1 ||
|
y === 0 || y === n - 1 ||
|
||||||
z === 0 || z === p - 1) {
|
z === 0 || z === p - 1) {
|
||||||
|
@ -227,6 +226,8 @@ function generateSequentialRooms(m=20, n=20, p=20, rooms=8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDoor(matrix, x, y, z) {
|
function addDoor(matrix, x, y, z) {
|
||||||
|
matrix[z][x][y] = 'stone';
|
||||||
|
|
||||||
// Place the lower half of the door
|
// Place the lower half of the door
|
||||||
matrix[z + 1][x][y] = 'dark_oak_door[half=lower, hinge=left]';
|
matrix[z + 1][x][y] = 'dark_oak_door[half=lower, hinge=left]';
|
||||||
|
|
||||||
|
@ -282,6 +283,29 @@ function generateSequentialRooms(m=20, n=20, p=20, rooms=8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addLadder(matrix, x, y, z) {
|
||||||
|
let currentZ = z+1;
|
||||||
|
|
||||||
|
// turn the floor into air where person would go up
|
||||||
|
matrix[currentZ][x+1][y] = 'air'
|
||||||
|
|
||||||
|
// Build the first 3 ladder segments from floor level downwards
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
matrix[currentZ][x][y] = 'ladder[facing=north]';
|
||||||
|
currentZ-=1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue building ladder downwards until a floor is hit or we reach the bottom
|
||||||
|
while (currentZ >= 0 && matrix[currentZ][x][y] === 'air') {
|
||||||
|
// Place ladder
|
||||||
|
matrix[currentZ][x][y] = 'ladder[facing=north]';
|
||||||
|
|
||||||
|
// Move down
|
||||||
|
currentZ--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Places rooms until we can't, or we place all
|
// Places rooms until we can't, or we place all
|
||||||
// attempts random configurations of rooms in random directions.
|
// attempts random configurations of rooms in random directions.
|
||||||
|
@ -328,9 +352,12 @@ function generateSequentialRooms(m=20, n=20, p=20, rooms=8) {
|
||||||
newY = lastRoom.y;
|
newY = lastRoom.y;
|
||||||
newZ = lastRoom.z + lastRoom.depth - 1;
|
newZ = lastRoom.z + lastRoom.depth - 1;
|
||||||
if (validateAndBuildBorder(matrix, newX, newY, newZ, newLength, newWidth, newDepth, m, n, p)) {
|
if (validateAndBuildBorder(matrix, newX, newY, newZ, newLength, newWidth, newDepth, m, n, p)) {
|
||||||
addStairs(matrix, lastRoom.x + Math.floor(lastRoom.length / 2),
|
// addStairs(matrix, lastRoom.x + Math.floor(lastRoom.length / 2),
|
||||||
|
// lastRoom.y + Math.floor(lastRoom.width / 2),
|
||||||
|
// lastRoom.z, 'north'); // Adjust direction based on layout
|
||||||
|
addLadder(matrix, lastRoom.x + Math.floor(lastRoom.length / 2),
|
||||||
lastRoom.y + Math.floor(lastRoom.width / 2),
|
lastRoom.y + Math.floor(lastRoom.width / 2),
|
||||||
lastRoom.z, 'north'); // Adjust direction based on layout
|
newZ); // Adding the ladder
|
||||||
lastRoom = { x: newX, y: newY, z: newZ, length: newLength, width: newWidth, depth: newDepth };
|
lastRoom = { x: newX, y: newY, z: newZ, length: newLength, width: newWidth, depth: newDepth };
|
||||||
roomPlaced = true;
|
roomPlaced = true;
|
||||||
placedRooms++;
|
placedRooms++;
|
||||||
|
@ -411,7 +438,6 @@ function generateSequentialRooms(m=20, n=20, p=20, rooms=8) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// todo: change the outer layer of the matrix to be window (or just air?)
|
|
||||||
// Replace outer stone layer with glass
|
// Replace outer stone layer with glass
|
||||||
for (let z = 0; z < p; z++) {
|
for (let z = 0; z < p; z++) {
|
||||||
for (let x = 0; x < m; x++) {
|
for (let x = 0; x < m; x++) {
|
||||||
|
@ -536,9 +562,9 @@ bot.on('spawn', async () => {
|
||||||
bot.chat(command);
|
bot.chat(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(commands.slice(-10));
|
// console.log(commands.slice(-10));
|
||||||
bot.chat('I have built the house!');
|
bot.chat('I have built the house!');
|
||||||
bot.chat('/tp @a ' + nearbyPosition.x + ' ' + nearbyPosition.y + ' ' + nearbyPosition.z);
|
bot.chat('/tp @a ' + nearbyPosition.x + ' ' + nearbyPosition.y + ' ' + nearbyPosition.z+1);
|
||||||
|
|
||||||
// Print out the location nearby the blueprint
|
// Print out the location nearby the blueprint
|
||||||
console.log(`tp ${nearbyPosition.x} ${nearbyPosition.y} ${nearbyPosition.z}`)
|
console.log(`tp ${nearbyPosition.x} ${nearbyPosition.y} ${nearbyPosition.z}`)
|
||||||
|
|
Loading…
Add table
Reference in a new issue