Generating ores is not easy with ModPE, but not impossible, you can use this Code to spawn random generated ores with ModPE, it don´t destroys bedrock and it generates ore with random big veins.
The Screenshot shows how it looks in a flat world (only the old version generates ore in a flat world), in a normal world the ore generates under the surface.
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
/*
You can change:
The Ore Block (line 22) (You can add more, too)
The high where it start generating the ore (line 186 and line 188)
How big a vein is (line 190)
The function setTile2 (line 164), but this is not important, but, if you want, you can change what for blocks it replace with ore and what for blocks not
Copy - Paste the part where it generates ore (line 180 - 229) for more veines of one ore in one chunk and for other ores
Change the probability to generate one ore-vein (line 181)
*/
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function setTile2(p1, p2, p3, p4, p5){ //This function gives more possibilities to place ore, in this case it only places ore when it destroys Stone for that
if(Level.getTile(p1, p2, p3)==1){ //if there, where the ore should be placed, is stone...
Level.setTile(p1, p2, p3, p4, p5);
}
}
function spawnOres(){ //this function spawns your ore in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part (from start to generate copper until end of generating copper (line229)) for more ores or generating one ore twice
if(Math.floor(Math.random()*20)>7){ //probability that the following lines will generate ore
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40) in this case, change the high to the high you want, the high should be at least 5, because it should not destroy Bedrock
if(Level.getBiomeName(curX, curZ)=="Ocean"){ //a new, lower high when it generates ore in the ocean biome
cY=Math.floor(Math.random()*25)+5; //random high (from 5 to 30)
}
count=Math.floor(Math.random()*12)+3; //how many of one ore spawn (from 3 to 15)
setTile2(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
setTile2(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
}
//end of generating copper
//end of generating ores
}
//
}
Old version:
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function spawnOres(){ //this function spawns your ore in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part for more ores or generating one ore twice
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40)
count=Math.floor(Math.random()*12)+3; //how many of one ore spawn (from 3 to 15)
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
//end of generating copper
//end of generating ores
}
//
}
Two questions, one is when you copy and paste, do you have to put the second code in a new function, or change the variables. Wont the variables be duplicates and make the script crash?, the second one is how do i set rarity of the multiple ores?
Two questions, one is when you copy and paste, do you have to put the second code in a new function, or change the variables. Wont the variables be duplicates and make the script crash?, the second one is how do i set rarity of the multiple ores?
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function spawnOres(){ //this function spawns your our in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part for more ores or generating one ore twice
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40)
count=Math.floor(Math.random()*12)+3; // 3 until 15 blocks
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
/*now the same again
|
|
\/
*/
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40) count=Math.floor(Math.random()*2)+4; // <-- how big a vein is, now a vein is 4 until 6 blocks
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
//end of generating copper
//end of generating ores
}
//
}
in my mod, i just check if the 7th block below the player is stone to check if their in the right deminsion and superflat, and before it generates the enderite ore, it checks if theirs already some there, it generates every five minutes. but it generates to many, so im gonna make it only generate 1 block of ore each time.
-it only replaces stone to generate ore, so ore can only be under the surface, it should not generate ore in flat worlds, because the minimum Y is 5 and there´s no stone in a flat world, and it should not generate ore in the water of oceans
-another Y to start generating ore in the ocean-biome, this Y should be lower
-added a probability to generate one vein
-changed comments, so you can understand it better
Generating ores is not easy with ModPE, but not impossible, you can use this Code to spawn random generated ores with ModPE, it don´t destroys bedrock and it generates ore with random big veins.
The Screenshot shows how it looks in a flat world (only the old version generates ore in a flat world), in a normal world the ore generates under the surface.
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
/*
You can change:
The Ore Block (line 22) (You can add more, too)
The high where it start generating the ore (line 186 and line 188)
How big a vein is (line 190)
The function setTile2 (line 164), but this is not important, but, if you want, you can change what for blocks it replace with ore and what for blocks not
Copy - Paste the part where it generates ore (line 180 - 229) for more veines of one ore in one chunk and for other ores
Change the probability to generate one ore-vein (line 181)
*/
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function doTick(){
if(Player.getDimension()==DimensionId.NORMAL){ //only generate in the normal dimension, not in the Nether
curX=Math.floor(Player.getX());
curZ=Math.floor(Player.getZ());
for(var i=0; i<16; i++){
if(curX<0){
changeBack=true;
curX=curX*(-1);
}
if(curX%16!=0){
curX--;
}
if(changeBack){
curX=curX*(-1);
}
changeBack=false;
if(curZ<0){
changeBack=true;
curZ=curZ*(-1);
}
if(curZ%16!=0){
curZ--;
}
if(changeBack){
curZ=curZ*(-1);
}
changeBack=false;
}
curX++;
curZ++;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
}
}
function setTile2(p1, p2, p3, p4, p5){ //This function gives more possibilities to place ore, in this case it only places ore when it destroys Stone for that
if(Level.getTile(p1, p2, p3)==1){ //if there, where the ore should be placed, is stone...
Level.setTile(p1, p2, p3, p4, p5);
}
}
function spawnOres(){ //this function spawns your ore in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part (from start to generate copper until end of generating copper (line229)) for more ores or generating one ore twice
if(Math.floor(Math.random()*20)>7){ //probability that the following lines will generate ore
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40) in this case, change the high to the high you want, the high should be at least 5, because it should not destroy Bedrock
if(Level.getBiomeName(curX, curZ)=="Ocean"){ //a new, lower high when it generates ore in the ocean biome
cY=Math.floor(Math.random()*25)+5; //random high (from 5 to 30)
}
count=Math.floor(Math.random()*12)+3; //how many of one ore spawn (from 3 to 15)
setTile2(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
setTile2(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
}
//end of generating copper
//end of generating ores
}
//
}
Old version:
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function doTick(){
if(Player.getDimension()==DimensionId.NORMAL){
curX=Math.floor(Player.getX());
curZ=Math.floor(Player.getZ());
for(var i=0; i<16; i++){
if(curX<0){
changeBack=true;
curX=curX*(-1);
}
if(curX%16!=0){
curX--;
}
if(changeBack){
curX=curX*(-1);
}
changeBack=false;
if(curZ<0){
changeBack=true;
curZ=curZ*(-1);
}
if(curZ%16!=0){
curZ--;
}
if(changeBack){
curZ=curZ*(-1);
}
changeBack=false;
}
curX++;
curZ++;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
}
}
function spawnOres(){ //this function spawns your ore in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part for more ores or generating one ore twice
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40)
count=Math.floor(Math.random()*12)+3; //how many of one ore spawn (from 3 to 15)
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
//end of generating copper
//end of generating ores
}
//
}
Download(if you don´t want to copy-paste):
http://1drv.ms/1QFm12E
I hope this helps you!
If you have questions ask here
Your tutorial looks pretty similar to my template I didnt know the try{ thingy. good idea, im gonna add this to my mods if you dont care
Oh and I will sure give you some credits
Subscribe to my YT channel to be informed about upcoming updates/new mods/Texturepacks and much more
https://www.youtube.com/channel/UCy-gPnisSCWH9bvCKJsVeoQ
Can I use this in my mod?
Two questions, one is when you copy and paste, do you have to put the second code in a new function, or change the variables. Wont the variables be duplicates and make the script crash?, the second one is how do i set rarity of the multiple ores?
var tick=0;
var curX=0;
var curY=0;
var curZ=0;
var cX=0;
var cY=0;
var cZ=0;
var count=0;
var changeBack=false;
try{
Block.defineBlock(220, "Copper Ore", [["copper_ore", 0]], 1, false, 0); //define a block, in this example it should be copper ore
}catch(error){
print("Import the texture pack first!");
print("Import the texture pack first!");
}
function modTick(){
tick++;
if(tick%100==0){//every 5 seconds the function doTick() is called
doTick();
}
}
function doTick(){
if(Player.getDimension()==DimensionId.NORMAL){
curX=Math.floor(Player.getX());
curZ=Math.floor(Player.getZ());
for(var i=0; i<16; i++){
if(curX<0){
changeBack=true;
curX=curX*(-1);
}
if(curX%16!=0){
curX--;
}
if(changeBack){
curX=curX*(-1);
}
changeBack=false;
if(curZ<0){
changeBack=true;
curZ=curZ*(-1);
}
if(curZ%16!=0){
curZ--;
}
if(changeBack){
curZ=curZ*(-1);
}
changeBack=false;
}
curX++;
curZ++;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curZ=curZ+16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curX=curX-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curZ=curZ-16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
curX=curX+16;
spawnOres();
}
}
function spawnOres(){ //this function spawns your our in one chunk
if(Level.getTile(curX, 1, curZ)!=57){
Level.setTile(curX, 1, curZ, 57, 0);
Level.setTile(curX, 0, curZ, 7, 0);
Level.setTile(curX, 2, curZ, 7, 0);
Level.setTile(curX+1, 1, curZ, 7, 0);
Level.setTile(curX-1, 1, curZ, 7, 0);
Level.setTile(curX, 1, curZ+1, 7, 0);
Level.setTile(curX, 1, curZ-1, 7, 0);
//start generating ores
//start to generate copper - copy-paste this part for more ores or generating one ore twice
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40)
count=Math.floor(Math.random()*12)+3; // 3 until 15 blocks
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
/*now the same again
|
|
\/
*/
cX=curX;
cZ=curZ;
cX=cX+Math.floor(Math.random()*10)+2; //random X
cZ=cZ+Math.floor(Math.random()*10)+2; //random Z
cY=Math.floor(Math.random()*30)+10; //random high (from 10 to 40)
count=Math.floor(Math.random()*2)+4; // <-- how big a vein is, now a vein is 4 until 6 blocks
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
for(var i=0; i<count; i++){
if(Math.floor(Math.random()*3)+1==2){
cX++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cX--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cZ++;
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cZ--;
}
}
if(Math.floor(Math.random()*3)+1==2){
cY++;
if(cY>50){
cY--;
}
}else{
if(Math.floor(Math.random()*3)+1==2){
//nothing to do here
}else{
cY--;
if(cY<5){
cY++;
}
}
}
Level.setTile(cX, cY, cZ, 220, 0); //220 is the Id of the ore
}
//end of generating copper
//end of generating ores
}
//
}
I didn´t knew your template.
It´s a tutorial, so everybody can use it without credit
Thank You
Woah that is seriously long code Heres how my ore Generator code is:
function GenerateOre(id, minY, maxY, x, z, minChance, maxChance) {
var rnd = Math.floor(Math.random() * 100) + 1;
var y = 0;
for (var i = maxY; i >= minY; i--) {
if (Level.getTile(x, i, z) == 1 && rnd >= minChance && rnd <= maxChance) {
y = i;
break;
setTile(x, y, z, id)
}
}
}
var count = 0;
function modTick() {
count++;
//Ore Generator
randomX = Math.floor(Math.random() * Player.getX() + Math.floor(Math.random() * Player.getX()) + Math.floor(Math.random() * 10));
randomZ = Math.floor(Math.random() * Player.getZ() + Math.floor(Math.random() * Player.getZ()) + Math.floor(Math.random() * 10));
if (count == 100) {
count = 0;
GenerateOre(14, 6, 25, randomX, randomZ, 1, 60);
GenerateOre(14, 6, 25, randomX, randomZ, 1, 70);
}
}
Just Having A Break in creating mods
And how does your code save which chunk is already filled with ore?
in my mod, i just check if the 7th block below the player is stone to check if their in the right deminsion and superflat, and before it generates the enderite ore, it checks if theirs already some there, it generates every five minutes. but it generates to many, so im gonna make it only generate 1 block of ore each time.
Lol, this siggy was so cringe, 2013 me was cringe
Well modTick should do the rest of finding a randomX and Z and it is very useful using a rareness option which makes it nnot that OP
Just Having A Break in creating mods
It may be laggless but u have to do it in one ore if u keep coping and paste it it wont function correctly couse its using ModTICK
You dont copy paste the whole thing. Just the part where it says copper ore
How to do two things:
Stop from spawning in flat worlds
Stop from spawning in oceans
I love being ignored
Lol, this siggy was so cringe, 2013 me was cringe
I made a new version:
-it only replaces stone to generate ore, so ore can only be under the surface, it should not generate ore in flat worlds, because the minimum Y is 5 and there´s no stone in a flat world, and it should not generate ore in the water of oceans
-another Y to start generating ore in the ocean-biome, this Y should be lower
-added a probability to generate one vein
-changed comments, so you can understand it better
I hope I ignored no one
does this use function modTick(){}
?
Lol, this siggy was so cringe, 2013 me was cringe
yes
Thanks dude this mod script is great! Ill credit you for it.
Lol