You have to use (int) Math.random(). You should put it in Chunk by Chunk (16x16x128 Blocks). You also have to save in which Chunk you already puttet the Ore in (That's a bit difficulty because you have to save a lot). Math.random gives a random number (integer). Example:
var done1;
var ax;
var az;
var num;
var x;
var y;
var z;
y = (int) Math.random()*40+1 //puts a random number until 40 in the variable y
If you don't use Math.random, the ore will spawn at regularly places, and that's not what you are searching for, right?
I think this will not help you a lot. So here's a larger example:
function modTick(){
ax = getPlayerX();
az = getPlayerZ(); //better define these and all coming variables at the start of the Script
if(ax>0 && az>0 && ax<16 && az<16 && done1==0){ //if you are in the first Chunk and you already didn't puttet ore in
done1=1;
num= (int) Math.random*5+1;
num = num + 3; //the number is now 3 until 8
while(num>0){
x = (int) Math.random*16+1; //get the coordinates for the ores, between 1 and 16 because chunk is 16 Blocks big
y =(int) Math.random*30+1; //y is the high and in the example it should spawn between the high of 3 and 33
y = y + 3; //y +3, otherwise we could delete Bedrock
z = (int) Math.random*16+1; //the last missing coordinate
Level.setTile(x, y, z, the ores Id); //place the Block :-)
} //the loop will place again and again until num==0;
}
}
Note: MCPE uses another method to place ore, but for that you would need to make a native (C++) Mod.
Mine? Please note: I made a little change yesterday, and: I just programmed it for the first chunk, you would need to add chunks. Also the Level.setTile() can't work in the moment because you have to put your Id in. If you use BlockLauncher I would need to see the mistake-message.
I Plan to Make A Mod With A New Ore Called Indium But I Cant Make The Ore Spawn
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou have to use (int) Math.random(). You should put it in Chunk by Chunk (16x16x128 Blocks). You also have to save in which Chunk you already puttet the Ore in (That's a bit difficulty because you have to save a lot). Math.random gives a random number (integer). Example:
var done1;
var ax;
var az;
var num;
var x;
var y;
var z;
y = (int) Math.random()*40+1 //puts a random number until 40 in the variable y
If you don't use Math.random, the ore will spawn at regularly places, and that's not what you are searching for, right?
I think this will not help you a lot. So here's a larger example:
function modTick(){
ax = getPlayerX();
az = getPlayerZ(); //better define these and all coming variables at the start of the Script
if(ax>0 && az>0 && ax<16 && az<16 && done1==0){ //if you are in the first Chunk and you already didn't puttet ore in
done1=1;
num= (int) Math.random*5+1;
num = num + 3; //the number is now 3 until 8
while(num>0){
x = (int) Math.random*16+1; //get the coordinates for the ores, between 1 and 16 because chunk is 16 Blocks big
y =(int) Math.random*30+1; //y is the high and in the example it should spawn between the high of 3 and 33
y = y + 3; //y +3, otherwise we could delete Bedrock
z = (int) Math.random*16+1; //the last missing coordinate
Level.setTile(x, y, z, the ores Id); //place the Block :-)
} //the loop will place again and again until num==0;
}
}
Note: MCPE uses another method to place ore, but for that you would need to make a native (C++) Mod.
I hope this helps you.
Nevermind I Just Saw It
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDoes that mean you don´t want to make such a mod anymore? If you want, I can help you where you need.
How Do You Doo C++
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumLook at the wiki from byteandahalf: https://github.com/byteandahalf/MCPE-NativeMods/wiki/1:-Making-native-mods-for-Minecraft-Pocket-Edition
The Code Isnt Working
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumMine? Please note: I made a little change yesterday, and: I just programmed it for the first chunk, you would need to add chunks. Also the Level.setTile() can't work in the moment because you have to put your Id in. If you use BlockLauncher I would need to see the mistake-message.
Ok Ill Test It Again
Error is
int done1;
org.mozilla.javascript.EvaluatorException: missing ;
before statement (Radium Mod.js#27)
My Whole Script
https://www.dropbox.com/s/flzjylyvlyobn79/Radium Mod.js?dl=0
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumsorry, my mistake.
That would just work at real Java (not at JavaScript)...
int done1; should define a variable. Put it at the start as var done1;
This also is important for the other variabes.
I changed the first post of me now again...