Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comet.js #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions comet.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
var magik = magikcraft.io;
const magik = magikcraft.io;

function comet(){
var Fireball = Java.type('org.bukkit.entity.Fireball')
const Fireball = magik.type('entity.Fireball');
const TNT = magik.type("entity.EntityType").PRIMED_TNT;
const sender = magik.getSender();
//var arrow = player.getWorld().spawnEntity(sender.location, org.bukkit.entity.EntityType.ZOMBIE);

for (var i = 0; i < 50; i++) {
var loc = rndBlock(15,15).location;
var arrow = player.getWorld().spawnEntity(loc, org.bukkit.entity.EntityType.PRIMED_TNT);
for (let 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);
const v = sender.getEyeLocation().getDirection().multiply(2);
v.setX(0);
v.setY(0);
v.setZ(0);
Expand All @@ -19,17 +21,15 @@ function comet(){

}


function randn_bm() {
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1].
var v = 1 - Math.random();
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) {
var ret = 0;
for (var i = 0; i < count; i++) {
let ret = 0;
for (let i = 0; i < count; i++) {
ret += Math.random();
}
return ret/count;
Expand All @@ -44,5 +44,5 @@ function scale(r, from, to) {
return Math.floor(r*(to - from)+from)
}
function rndBlock(radius, height) {
return sender.location.getBlock().getRelative(rnorm(0, radius/5), rnorm(0, radius/5), rnorm(0, radius/5));
return magik.getSender().getLocation().getBlock().getRelative(rnorm(0, radius/5), rnorm(0, radius/5), rnorm(0, radius/5));
}