Plex-FAWE/contrib/craftscripts/roof.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2012-10-20 04:01:44 +00:00
// $Id$
/*
* Copyright (c) 2011 Bentech
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
importPackage(Packages.com.sk89q.worldedit);
2018-12-20 03:43:01 +00:00
importPackage(Packages.com.sk89q.worldedit.math);
2012-10-20 04:01:44 +00:00
importPackage(Packages.com.sk89q.worldedit.blocks);
var blocks = context.remember();
var session = context.getSession();
2018-12-20 03:43:01 +00:00
var player = context.getPlayer();
var region = session.getRegionSelector(player.getWorld()).getRegion();
2012-10-20 04:01:44 +00:00
context.checkArgs(1, 1, "<type>");
var blocktype = context.getBlock(argv[1]);
2018-12-20 03:43:01 +00:00
var cycles = region.getLength();
2012-10-20 04:01:44 +00:00
if (region.getWidth() > cycles) {
2012-10-20 04:01:44 +00:00
cycles = region.getWidth();
}
cycles = cycles / 2;
for (var c = 0; c < cycles; c++) {
for (var w = 0; w < region.getWidth() - (c * 2); w++) {
for (var l = 0; l < region.getLength() - (c * 2); l++) {
2018-12-20 03:43:01 +00:00
if (w === 0 || w === (region.getWidth() - (c * 2)) - 1 || l === 0 || l === (region.getLength() - (c * 2)) - 1) {
var vec = BlockVector3.at(
2012-10-20 04:01:44 +00:00
region.getMinimumPoint().getX() + (w + c),
region.getMaximumPoint().getY() + c,
region.getMinimumPoint().getZ() + (l + c));
2018-12-20 03:43:01 +00:00
2012-10-20 04:01:44 +00:00
blocks.setBlock(vec, blocktype);
}
}
}
}