for(var i=0;i<3;i++){ // order pairs by size to let the next loop work
ordered[0].push(Math.min(points[0][i], points[1][i]));
ordered[1].push(Math.max(points[0][i], points[1][i]));
}
if(dist < radius+1 || tools[tool] == "Voxel Disk"){
var d,e,f;
switch(side){
case 0:
d = a + x;
e = b;
f = c + y;
break;
case 1:
d = a + x;
e = b + y;
f = c;
break;
case 2:
d = a;
e = b + x;
f = c + y;
break;
default:
clientMessage("No case for " + side + "; " + side);
break;
}
setTile(d, e, f, block.id, block.damage);
}
}
}
} else if(tool >= tools.indexOf("Voxel")){//3D
for(var x=-radius;x<radius+1;x++){
for(var y=-radius;y<radius+1;y++){
for(var z=-radius;z<radius+1;z++){
var d = a + x;
var e = b + y;
var f = c + z;
if(tools[tool] == "Ball"){
var dist = Math.sqrt(x*x+y*y+z*z);
if(dist<radius+1)// limit and remove nubs
setTile(d, e, f, block.id, block.damage);
} else {
setTile(d, e, f, block.id, block.damage);
}
}
}
}
}
}
function modTick(){
if(Arrow != null && ticks == 1){//time to move
last = {
x:Entity.getX(Arrow),
y:Entity.getY(Arrow),
z:Entity.getZ(Arrow)
};
}
if(Arrow != null && ticks == 2){//more movement time
var coords = {
x:Entity.getX(Arrow),
y:Entity.getY(Arrow),
z:Entity.getZ(Arrow)
};
var vel = {
x:coords.x - last.x,
y:coords.y - last.y,
z:coords.z - last.z
};
if(vel.x + vel.y + vel.z == 0){
var side = 0;
var leftover = {
x:coords.x % 1,
y:coords.y % 1,
z:coords.z % 1
};
var min = Math.min(leftover.x,leftover.y,leftover.z);
if(leftover.y == min) {
side = 0;
} else if(leftover.z == min) {
side = 1;
} else if(leftover.x == min) {
side = 2;
}
replace(
Math.floor(coords.x),
Math.floor(coords.y),
Math.floor(coords.z),
side
);
//Hooks
function useItem(x,y,z,itemId,blockId,side){
if(itemId == item)
replace(x, y, z, Math.ceil((side+1)/2));
}
function procCmd(cmd){
cmd = cmd.toLowerCase();
cmd = cmd.split(" ");
if(cmd[0] == "voxel"){
var arguments = [parseInt(cmd[2]),parseInt(cmd[3])];
if(arguments[0] >= 0){
switch(cmd[1]){
case "tool":
if(arguments[0] < tools.length && arguments[0] > 0){
tool = arguments[0];
clientMessage("Tool set to: " + tools[tool]);
points = [];
} else {
clientMessage("Tool is out of range");
}
break;
case "block":
if(arguments[1] >= 0){}else{
arguments[1] = 0;
}
block = {
id:arguments[0],
damage:arguments[1]
};
clientMessage("Block set to: " + arguments[0] + ":" + arguments[1]);
break;
case "radius":
if(arguments[0] > 0){
radius = arguments[0];
clientMessage("Radius set to: " + arguments[0]);
} else {
clientMessage("Radius is too small");
}
break;
default:
clientMessage("Unrecognized command");
break;
}
} else {//guide
switch(cmd[1]){
case "tool":
clientMessage("Available Tools:");
for(var i=1;i<tools.length;i++)
clientMessage(" " + (i) + ": " + tools[i]);
break;
case "radius":
clientMessage("Radius: " + radius);
break;
case "block":
if(tool != tools.indexOf("GetBlock"))
lastTool = tool;
tool = tools.indexOf("GetBlock");
clientMessage("Click on a block");
break;
default:
clientMessage("Commands:");
clientMessage(" /voxel tool <integer>");
clientMessage(" /voxel radius <integer>");
clientMessage(" /voxel block <integer> <integer>");
break;
}
}
}
}
//Modified from Byteandahalf's button template
function newLevel() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
//This will allow our button to run on the current UI thread of MCPE
try {
buttonWindow = new android.widget.PopupWindow();
var layout = new android.widget.RelativeLayout(activity);
layout.addView(button);
buttonWindow.setContentView(layout);
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
buttonWindow.showAtLocation(activity.getWindow().getDecorView(), android.view.Gravity.LEFT | android.view.Gravity.TOP, 0, 0);
}catch(problem){
print("Button could not be displayed: " + problem); //Print our error if we failed to make the button
}
}}));
}
function leaveGame() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
//VoxelSniper remake
var block = {
id:1,
damage:0
};
var last = {x:0,y:0,z:0};
var tools = [
"GetBlock",
"Ruler",
"Selection Rectangle",
"Selection Replace",
"Disk",
"Voxel Disk",
"Voxel",
"Ball"
];
var points = [];
var tool = tools.indexOf("Selection Rectangle");
var lastTool = tool;
var radius = 3;
var item = 292;
var buttonWindow = null;
var Arrow = null;
var ticks = 0;
function shoot(){
try{
var player = {
x:Player.getX(),
y:Player.getY(),
z:Player.getZ(),
yaw:(Entity.getYaw(getPlayerEnt())+90)*Math.PI/180,
pitch:Entity.getPitch(getPlayerEnt())*Math.PI/180
};
var pitch = Math.abs(Math.cos(player.pitch));
var vector = [Math.cos(player.yaw)*pitch,-player.pitch*.87,Math.sin(player.yaw)*pitch];
Arrow = Level.spawnMob(player.x+vector[0]*3, player.y+vector[1]*3, player.z+vector[2]*3,80);
Entity.setVelX(Arrow, vector[0]*100);
Entity.setVelY(Arrow, vector[1]*100);
Entity.setVelZ(Arrow, vector[2]*100);
//clientMessage(vector.join(","));
ticks = 0;
}catch(err) {
clientMessage(err);
}
}
function replace(a, b, c, side){
if(tools[tool] == "GetBlock"){
tool = lastTool;
block = {
id:getTile(a,b,c),
damage:Level.getData(a,b,c)
};
clientMessage("Block set to: " + block.id + ":" + block.damage);
} else if(tools[tool] == "Ruler" || tools[tool] == "Selection Rectangle" || tools[tool] == "Selection Replace" || tools[tool] == "Oval"){
points.push([a, b, c]);
clientMessage("Selected (" + points[0].join(",") + ")");
if(points.length == 2){
if(tools[tool] == "Ruler"){
var x = points[0][0] - points[1][0];
var y = points[0][1] - points[1][1];
var z = points[0][2] - points[1][2];
clientMessage("Distance: " + Math.sqrt(x*x+y*y+z*z));
} else {
var ordered = [[],[]];
for(var i=0;i<3;i++){ // order pairs by size to let the next loop work
ordered[0].push(Math.min(points[0][i], points[1][i]));
ordered[1].push(Math.max(points[0][i], points[1][i]));
}
for(var x=ordered[0][0];x<=ordered[1][0];x++){
for(var y=ordered[0][1];y<=ordered[1][1];y++){
for(var z=ordered[0][2];z<=ordered[1][2];z++){
if(tools[tool] == "Selection Rectangle" || getTile(x,y,z) != 0){
setTile(x, y, z, block.id, block.damage);
}
}
}
}
}
points = [];
}
} else if(tools[tool] == "Disk" || tools[tool] == "Voxel Disk"){
for(var x=-radius;x<=radius;x++){
for(var y=-radius;y<=radius;y++){
var dist = Math.sqrt(x*x+y*y);
if(dist < radius+1 || tools[tool] == "Voxel Disk"){
var d,e,f;
switch(side){
case 0:
d = a + x;
e = b;
f = c + y;
break;
case 1:
d = a + x;
e = b + y;
f = c;
break;
case 2:
d = a;
e = b + x;
f = c + y;
break;
default:
clientMessage("No case for " + side + "; " + side);
break;
}
setTile(d, e, f, block.id, block.damage);
}
}
}
} else if(tool >= tools.indexOf("Voxel")){//3D
for(var x=-radius;x<radius+1;x++){
for(var y=-radius;y<radius+1;y++){
for(var z=-radius;z<radius+1;z++){
var d = a + x;
var e = b + y;
var f = c + z;
if(tools[tool] == "Ball"){
var dist = Math.sqrt(x*x+y*y+z*z);
if(dist<radius+1)// limit and remove nubs
setTile(d, e, f, block.id, block.damage);
} else {
setTile(d, e, f, block.id, block.damage);
}
}
}
}
}
}
function modTick(){
if(Arrow != null && ticks == 1){//time to move
last = {
x:Entity.getX(Arrow),
y:Entity.getY(Arrow),
z:Entity.getZ(Arrow)
};
}
if(Arrow != null && ticks == 2){//more movement time
var coords = {
x:Entity.getX(Arrow),
y:Entity.getY(Arrow),
z:Entity.getZ(Arrow)
};
var vel = {
x:coords.x - last.x,
y:coords.y - last.y,
z:coords.z - last.z
};
if(vel.x + vel.y + vel.z == 0){
var side = 0;
var leftover = {
x:coords.x % 1,
y:coords.y % 1,
z:coords.z % 1
};
var min = Math.min(leftover.x,leftover.y,leftover.z);
if(leftover.y == min) {
side = 0;
} else if(leftover.z == min) {
side = 1;
} else if(leftover.x == min) {
side = 2;
}
replace(
Math.floor(coords.x),
Math.floor(coords.y),
Math.floor(coords.z),
side
);
Entity.remove(Arrow);
Arrow = null;
}
}
ticks++;
}
//Hooks
function useItem(x,y,z,itemId,blockId,side){
if(itemId == item)
replace(x, y, z, Math.ceil((side+1)/2));
}
function procCmd(cmd){
cmd = cmd.toLowerCase();
cmd = cmd.split(" ");
if(cmd[0] == "voxel"){
var arguments = [parseInt(cmd[2]),parseInt(cmd[3])];
if(arguments[0] >= 0){
switch(cmd[1]){
case "tool":
if(arguments[0] < tools.length && arguments[0] > 0){
tool = arguments[0];
clientMessage("Tool set to: " + tools[tool]);
points = [];
} else {
clientMessage("Tool is out of range");
}
break;
case "block":
if(arguments[1] >= 0){}else{
arguments[1] = 0;
}
block = {
id:arguments[0],
damage:arguments[1]
};
clientMessage("Block set to: " + arguments[0] + ":" + arguments[1]);
break;
case "radius":
if(arguments[0] > 0){
radius = arguments[0];
clientMessage("Radius set to: " + arguments[0]);
} else {
clientMessage("Radius is too small");
}
break;
default:
clientMessage("Unrecognized command");
break;
}
} else {//guide
switch(cmd[1]){
case "tool":
clientMessage("Available Tools:");
for(var i=1;i<tools.length;i++)
clientMessage(" " + (i) + ": " + tools[i]);
break;
case "radius":
clientMessage("Radius: " + radius);
break;
case "block":
if(tool != tools.indexOf("GetBlock"))
lastTool = tool;
tool = tools.indexOf("GetBlock");
clientMessage("Click on a block");
break;
default:
clientMessage("Commands:");
clientMessage(" /voxel tool <integer>");
clientMessage(" /voxel radius <integer>");
clientMessage(" /voxel block <integer> <integer>");
break;
}
}
}
}
//Modified from Byteandahalf's button template
function newLevel() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
//This will allow our button to run on the current UI thread of MCPE
try {
buttonWindow = new android.widget.PopupWindow();
var layout = new android.widget.RelativeLayout(activity);
var button = new android.widget.Button(activity);
button.setText("Snipe");
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) {
shoot();
}
}));
layout.addView(button);
buttonWindow.setContentView(layout);
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
buttonWindow.showAtLocation(activity.getWindow().getDecorView(), android.view.Gravity.LEFT | android.view.Gravity.TOP, 0, 0);
}catch(problem){
print("Button could not be displayed: " + problem); //Print our error if we failed to make the button
}
}}));
}
function leaveGame() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
if(buttonWindow != null){
buttonWindow.dismiss();
buttonWindow = null;
}
}}));
}
Here is my Advent of Ascension textures I'm working on:
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2620544-advent-of-ascension-new-textures
I play Pixel Worlds! (Quit for a while)
Deleted old cringy signature.
Subscribe to my channel: Neoslayer PW
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumhttps://drive.google.com/file/d/0B50ApLKOyu8bQkZzcW9uclJ0UzA/edit?usp=sharing
Also, wrong section.
You see, I'm not an amazing modder likyou guys, so I tried to remove the gui and it resulted in an error. I would never make a good modder.
Here is my Advent of Ascension textures I'm working on:
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2620544-advent-of-ascension-new-textures
I play Pixel Worlds! (Quit for a while)
Deleted old cringy signature.
Subscribe to my channel: Neoslayer PW
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYes, you can make a good modder! Go take some JavaScript tutorials, and you'll be able to mod.
Here is my Advent of Ascension textures I'm working on:
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2620544-advent-of-ascension-new-textures
I play Pixel Worlds! (Quit for a while)
Deleted old cringy signature.
Subscribe to my channel: Neoslayer PW