Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Boulder Brush CraftScript for WorldEdit
- * Original brush script by inHaze <http://bit.ly/inHaze>
- * Modified by Fefinix (changed the bush shape)
- *
- * 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);
- importPackage(Packages.com.sk89q.worldedit.blocks);
- importPackage(Packages.com.sk89q.worldedit.tools);
- importPackage(Packages.com.sk89q.worldedit.tools.brushes);
- importPackage(Packages.com.sk89q.worldedit.patterns);
- importPackage(Packages.com.sk89q.worldedit.foundation);
- var material = argv.length > 1 ? context.getBlock(argv[1]) : 1;
- var xSize = argv.length > 2 ? parseInt(argv[2]) : 9;
- var ySize = argv.length > 3 ? parseInt(argv[3]) : 6;
- var zSize = argv.length > 4 ? parseInt(argv[4]) : 11;
- var yOff = argv.length > 5 ? parseInt(argv[5]) : 0;
- var thickInput = argv.length > 6 ? parseInt(argv[6]) : -1;
- var fModInput = argv.length > 7 ? parseInt(argv[7]) : -1;
- var fMod = [0,0,0];
- var thick = 0;
- if (thickInput == -1) {thick = Math.floor(Math.sqrt(Math.min(xSize,ySize,zSize)))} else {thick = thickInput};
- var strength = 1;
- //var tool = undefined;
- //var matPat = undefined;
- var brush = new Brush({
- strength : strength,
- build : function(editSession,posB,size) {
- var session = context.remember();
- var pos = player.getBlockTrace(300, true);
- var xPer = (Math.random() * 2 * 3.14);
- var yPer = (Math.random() * 2 * 3.14);
- var zPer = (Math.random() * 2 * 3.14);
- if (fModInput == -1) {
- fMod[1] = ((Math.random() * Math.max(xSize,ySize,zSize)/2) + Math.max(xSize,ySize,zSize)*0.4 +1);
- fMod[2] = ((Math.random() * Math.max(xSize,ySize,zSize)/2) + Math.max(xSize,ySize,zSize)*0.4 +1);
- fMod[3] = ((Math.random() * Math.max(xSize,ySize,zSize)/2) + Math.max(xSize,ySize,zSize)*0.4 +1);
- }
- else {
- fMod[1] = fModInput;
- fMod[2] = fModInput;
- fMod[3] = fModInput;
- };
- var s = [1, 1, 1, 1, 1, 1, 1, 1, 1];
- var s2 = 0;
- for (var i = 0; i <= 2; i++){
- s2 = Math.floor(Math.random()*3);
- s[s2+i*3] = -1;
- }
- for (var x = -(xSize+thick); x <= (xSize+thick); x++) {
- for (var y = -(ySize+thick); y <= (ySize+thick); y++) {
- for (var z = -(zSize+thick); z <= (zSize+thick); z++) {
- if ((Math.pow((x),2)/Math.pow((thick*Math.sin((x*s[0]+y*s[1]+z*s[2])/fMod[1]-xPer)+xSize),2)+Math.pow(z,2)/Math.pow((thick*Math.sin((x*s[3]+y*s[4]+z*s[5])/fMod[2]+zPer)+zSize),2)+Math.pow(y,2)/Math.pow((thick*Math.sin((x*s[6]+y*s[7]+z*s[8])/fMod[3]+yPer)+ySize),2)) < 1) {
- var pt = pos.add((x), (y+yOff+thick), (z));
- editSession.setBlock(pt, material);
- }
- }
- }
- }
- return true;
- },
- })
- if (argv.length <= 1) {
- CommandText();
- }
- else {
- tool = context.getSession().getBrushTool(player.getItemInHand());
- //matPat = new SingleBlockPattern(material);
- //tool.setFill(matPat);
- tool.setBrush(brush,"worldedit.brush.boulder");
- player.printError("Boulder brush bound to " + ItemType.toHeldName(player.getItemInHand()) + "." );
- player.print("[X: " + xSize +" | Y: " + ySize + " | Z: " + zSize + " | Mat: " + material + "]");
- }
- function CommandText() {
- player.print(" ");
- player.print("§5Boulder Brush Script by Fefinix, huge thanks to inHaze!");
- player.print(" ");
- player.print("§cUsage: /cs boulder [§6mat§c]<§ex§c><§ey§c><§ez§c><§eyOff§c><§ethick§c><§efMod§c>");
- player.print("§6mat§7 - §6Required§7. Boulder material.");
- player.print("§ex§7 - §eOptional§7. Radius in x direction. Default:9");
- player.print("§ey§7 - §eOptional§7. Radius in y direction. Default:6");
- player.print("§ez§7 - §eOptional§7. Radius in z direction. Default:11");
- player.print("§eyOff§7 - §eOptional§7. Vertical offset. Default:0");
- player.print("§ethick§7 - §eOptional§7. Surface bumpyness. 0 = Ellipsoid.");
- player.print("§efMod§7 - §eOptional§7. Shape mod. Higher value = smoother surface.");
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement