Skip to content

Instantly share code, notes, and snippets.

@tkc49
Last active October 8, 2017 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkc49/ed6f76f259bcfc83d3455943a8307c57 to your computer and use it in GitHub Desktop.
Save tkc49/ed6f76f259bcfc83d3455943a8307c57 to your computer and use it in GitHub Desktop.
Magikcraft Spells, by tkc49.
const magik = magikcraft.io;
function arain(radius, typ){
radius = parseInt(radius) || 20;
typ = typ || "ANVIL";
for (var i = 0; i < 200; i++) {
rndAnvil(radius, typ);
}
}
function rndAnvil(radius,typ) {
var height = radius;
rndBlock(radius, height).setType(org.bukkit.Material[typ])
}
// Standard Normal variate using Box-Muller transform.
//http://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve
function randn_bm() {
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1].
var v = 1 - Math.random();
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
}
function rnorm_unit(count) {
var ret = 0;
for (var i = 0; i < count; i++) {
ret += Math.random();
}
return ret/count;
}
function rnorm(mean, sd) {
return randn_bm() * sd + mean;
}
function runif(from, to) {
return scale(Math.random(), from, to);
}
function scale(r, from, to) {
return Math.floor(r*(to - from)+from)
}
function rndBlock(radius, height) {
return magik.getSender().location.getBlock().getRelative(rnorm(0, radius/5), height+runif(0, radius*3), rnorm(0, radius/5));
}
const magik = magikcraft.io;
function cam_capture(seconds = "--help", fps = 20) {
if (seconds === "--help") {
magik.dixit("Usage: /cast cam_capture [secs]");
magik.dixit("Usage: /cast cam_capture [secs] [fps]");
return;
}
global.film = {};
film.frames = [];
film.metadata = {
fps,
seconds
};
const interval = 1000 / fps;
const totalFrames = fps * seconds;
magik.dixit(`Recording ${seconds}s at ${fps} fps`);
let count = 0;
const camera = magik.setInterval(()=>{
const location = magik.getSender().getLocation();
film.frames.push(location);
count ++;
if (count > totalFrames) {
magik.clearInterval(camera);
magik.dixit('Finished recording!');
}
}, interval);
}
const magik = magikcraft.io;
function comet(){
const Fireball = magik.type('entity.Fireball');
const TNT = magik.type("entity.EntityType").PRIMED_TNT;
const sender = magik.getSender();
magik.dixit(sender.getName);
//var arrow = player.getWorld().spawnEntity(sender.location, org.bukkit.entity.EntityType.ZOMBIE);
for (var i = 0; i < 50; i++) {
const loc = rndBlock(15,15).location;
const arrow = sender.getWorld().spawnEntity(loc, TNT);
// //arrow.setShooter(sender);
// var v = sender.getEyeLocation().getDirection().multiply(2);
// v.setX(0);
// v.setY(0);
// v.setZ(0);
// //arrow.setVelocity(v);
// //arrow.setMetadata("ArrowType", new MyMetadata(this, "stick"));
}
}
function randn_bm() {
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1].
const v = 1 - Math.random();
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
}
function rnorm_unit(count) {
let ret = 0;
for (let i = 0; i < count; i++) {
ret += Math.random();
}
return ret/count;
}
function rnorm(mean, sd) {
return randn_bm() * sd + mean;
}
function runif(from, to) {
return scale(Math.random(), from, to);
}
function scale(r, from, to) {
return Math.floor(r*(to - from)+from)
}
function rndBlock(radius, height) {
return magik.getSender().getLocation().getBlock().getRelative(rnorm(0, radius/5), rnorm(0, radius/5), rnorm(0, radius/5));
}
const magik = magikcraft.io;
function feedme(){
magik.satio();
}
const magik = magikcraft.io;
$count = 0;
function fireboal() {
fire();
}
function fire(){
magik.setTimeout(function(){
magik.infierno();
}, 2000);
$count++;
if($count <= 3){
fire();
}
}
const magik = magikcraft.io;
function fireworks() {
// 見てる先を取得
var there = magik.aspecto();
magik.doNTimes(
function () {
// fireworkをローンチする
magik.stella(there);
//magik.iacta(name);
}, 1000, 300);
//magik.iacta(name);
magik.stella(there);
}
const magik = magikcraft.io;
function fly() {
magik.volare();
}
const magik = magikcraft.io;
function jump() {
magik.ex
}
const magik = magikcraft.io;
function lightning() {
magik.shakti();
}
const magik = magikcraft.io;
function rocket() {
const there = magik.aspecto();
// magik.stella (there);
}
const magik = magikcraft.io;
function test() {
magik.dixit(sender.getName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment