Jump to content

Recommended Posts

Posted

Ok so In my mod I need my ore to be generating in my custom dimension. Heres what I thought might work for code, because it works for the surface so try plugging in my dimension Ids in the switch statement and go from there.

 

 

package net.shinemod;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class OreWorldGen implements IWorldGenerator 
{

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
switch(world.provider.dimensionId) {
case -1:
generateNether();
break;
case 0:
generateSurface(world, random, chunkX*16, chunkZ*16);
break;
case 1:
generateEnd();
break;
case 20:
generateShine(world, random, chunkX * 16, chunkZ * 16);
break;
case 21:
generateEclipse(world, random, chunkX * 16, chunkZ * 16);
break;
}
}







private void generateEclipse(World world, Random rand, int chunkX, int chunkZ) 
{
	//BlackWhite ORE

	 for (int i = 0; i < 10; i++) 
	 {
	 //16x16 area up to y = 64
	 int randPosX = chunkX + rand.nextInt(16);
	 int randPosY = rand.nextInt(64);
	 int randPosZ = chunkZ + rand.nextInt(16);
	 // 10 blocks per vein
	 (new WorldGenMinable(mod_tutorial.EclipseBlock.blockID, 10)).generate(world, rand,
	 randPosX, randPosY, randPosZ);
	 }

}

private void generateShine(World world, Random rand, int chunkX, int chunkZ) 
{
//BlackWhite ORE

 for (int i = 0; i < 10; i++) 
 {
 //16x16 area up to y = 64
 int randPosX = chunkX + rand.nextInt(16);
 int randPosY = rand.nextInt(20);
 int randPosZ = chunkZ + rand.nextInt(16);
 // 10 blocks per vein
 (new WorldGenMinable(mod_tutorial.BlackWhiteOre.blockID, 2)).generate(world, rand,
 randPosX, randPosY, randPosZ);
 }

 for (int i = 0; i < 10; i++) 
 {
 //16x16 area up to y = 64
 int randPosX = chunkX + rand.nextInt(16);
 int randPosY = rand.nextInt(16);
 int randPosZ = chunkZ + rand.nextInt(16);
 // 10 blocks per vein
 (new WorldGenMinable(mod_tutorial.RainbowOre.blockID, 1)).generate(world, rand,
 randPosX, randPosY, randPosZ);
 }

 for (int i = 0; i < 10; i++) 
	 {
	 //16x16 area up to y = 64
	 int randPosX = chunkX + rand.nextInt(16);
	 int randPosY = rand.nextInt(64);
	 int randPosZ = chunkZ + rand.nextInt(16);
	 // 10 blocks per vein
	 (new WorldGenMinable(mod_tutorial.EclipseBlock.blockID, 10)).generate(world, rand,
	 randPosX, randPosY, randPosZ);
	 }

}


public void generateNether() 
{

}

public void generateSurface(World world, Random rand, int chunkX, int chunkZ) 
{
// 30 veins of ore per chunk
//YELLOW ORE 

for (int i = 0; i < 12; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(64);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.YellowOre.blockID, ).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//BLUE ORE

for (int i = 0; i < 10; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(60);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.BlueOre.blockID, 7)).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//RED ORE

for (int i = 0; i < 10; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(54);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.RedOre.blockID, 6)).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//GREEN ORE

for (int i = 0; i < 8; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(46);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.GreenOre.blockID, 4)).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//Silver ORE

for (int i = 0; i < 11; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(64);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.SilverOre.blockID, ).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//PINK ORE

for (int i = 0; i < 7; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(42);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.PinkOre.blockID, 5)).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//PURPLE ORE

for (int i = 0; i < 5; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(37);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.PurpleOre.blockID, 4)).generate(world, rand,
randPosX, randPosY, randPosZ);
}

//BLACK ORE

for (int i = 0; i < 5; i++) 
{
//16x16 area up to y = 64
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(34);
int randPosZ = chunkZ + rand.nextInt(16);
// 10 blocks per vein
(new WorldGenMinable(mod_tutorial.BlackOre.blockID, 4)).generate(world, rand,
randPosX, randPosY, randPosZ);
}
}

public void generateEnd() 
{

}

}

 

Note that overworld generation does work, yet none of my dimensions do. Also since my dimension has a custom biome, only 1 Custom biome I figured I might as well try to generate ores from my biome using the decorate method.

 

package net.shinemod.dimensions;

import java.util.Random;


import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.src.ModLoader;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.SpawnListEntry;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenTaiga1;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.shinemod.mod_tutorial;
import net.shinemod.creatures.ShineChicken;
import net.shinemod.creatures.ShineCow;
import net.shinemod.creatures.ShineCreeper;
import net.shinemod.creatures.ShinePig;
import net.shinemod.creatures.ShineSheep;
import net.shinemod.creatures.ShineSkeleton;
import net.shinemod.creatures.ShineSpider;
import net.shinemod.creatures.ShineZombie;

public class BiomeShine extends BiomeGenBase {

public BiomeShine(int par1) 
{
	super(par1);
	this.setBiomeName("Shine");
	this.fillerBlock = (byte) mod_tutorial.SDirt.blockID;
	this.topBlock = (byte) mod_tutorial.SGrass.blockID;
	this.maxHeight = 0.55f;
	this.minHeight = 0;
	this.theBiomeDecorator.treesPerChunk = 3;
	/**Adding My Monsters/Creatures**/
	this.spawnableCreatureList.add(new SpawnListEntry(ShineCow.class, 8, 4, 4));
        this.spawnableMonsterList.add(new SpawnListEntry(ShineSpider.class, 10, 4, 4));
        this.spawnableCreatureList.add(new SpawnListEntry(ShineSheep.class, 10, 4, 4));
        this.spawnableMonsterList.add(new SpawnListEntry(ShineCreeper.class, 10, 4, 4));
        this.spawnableCreatureList.add(new SpawnListEntry(ShinePig.class, 10, 4, 4));
        this.spawnableCreatureList.add(new SpawnListEntry(ShineChicken.class, 10, 4, 4));
        this.spawnableMonsterList.add(new SpawnListEntry(ShineZombie.class, 10, 4, 4));
        this.spawnableMonsterList.add(new SpawnListEntry(ShineSkeleton.class, 10, 4, 4));
	/**Despawning Other Monsters**/
        this.spawnableCreatureList.remove(new SpawnListEntry(EntitySheep.class, 12, 4, 4));
        this.spawnableCreatureList.remove(new SpawnListEntry(EntityPig.class, 10, 4, 4));
        this.spawnableCreatureList.remove(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
        this.spawnableCreatureList.remove(new SpawnListEntry(EntityCow.class, 8, 4, 4));
        this.spawnableMonsterList.remove(new SpawnListEntry(EntitySpider.class, 10, 4, 4));
        this.spawnableMonsterList.remove(new SpawnListEntry(EntityZombie.class, 10, 4, 4));
        this.spawnableMonsterList.remove(new SpawnListEntry(EntitySkeleton.class, 10, 4, 4));
        this.spawnableMonsterList.remove(new SpawnListEntry(EntitySlime.class, 10, 4, 4));
        this.spawnableMonsterList.remove(new SpawnListEntry(EntityEnderman.class, 1, 1, 4));
        this.spawnableWaterCreatureList.remove(new SpawnListEntry(EntitySquid.class, 10, 4, 4));
        this.spawnableCaveCreatureList.remove(new SpawnListEntry(EntityBat.class, 10, 8, );
        this.spawnableCreatureList.clear();
        this.spawnableMonsterList.clear();
}

public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
{
	return (WorldGenerator)(par1Random.nextInt(3) == 0 ? new WorldGenShineTrees() : new WorldGenShine2(false));
}

public void decorate(World world, Random rand, int chunkX, int chunkZ) 
 {
 	//BlackWhite ORE

 	 for (int i = 0; i < 10; i++) 
 	 {
 	 //16x16 area up to y = 64
 	 int randPosX = chunkX + rand.nextInt(16);
 	 int randPosY = rand.nextInt(64);
 	 int randPosZ = chunkZ + rand.nextInt(16);
 	 // 10 blocks per vein
 	 (new WorldGenMinable(mod_tutorial.EclipseBlock.blockID, 10)).generate(world, rand,
 	 randPosX, randPosY, randPosZ);
 	 }

 }
}

 

And no luck came from that. If anyone could please help me, theres no videos or tutorials on how to do this. I would appericate anyone willing to help. Thanks!

Posted

Pusedo Code:

    public void populate(IChunkProvider ichunkprovider, int i, int j)
    {
        BlockSand.fallInstantly = true;
        int k = i * 16;
        int l = j * 16;
        random.setSeed(worldObj.getSeed());
        long l1 = (random.nextLong() / 2L) * 2L + 1L;
        long l2 = (random.nextLong() / 2L) * 2L + 1L;
        random.setSeed((long)i * l1 + (long)j * l2 ^ worldObj.getSeed());
        double d = 0.25D;
        
        if(random.nextInt(32) == 0)
        {
            int i1 = k + random.nextInt(16);
            int j5 = random.nextInt(64) + 32;
            int j10 = l + random.nextInt(16);
            (new OreGenMinable(YOURMOD.ore.blockID, //amt in each vein)).generate(worldObj, random, i1, j5, j10);
        }

 

Create new class named OreGenMinable. Put this in:

package tut;

import java.util.Random;

import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class OreGenMinable extends WorldGenerator
{
private int minableBlockID;
private int numberOfBlocks;

public OreGenMinable(int i, int j)
{
	minableBlockID = i;
	numberOfBlocks = j;
}

public boolean generate(World world, Random random, int i, int j, int k)
{
	float f = random.nextFloat() * 3.151593F;
	double d = (float)(i +  + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
	double d1 = (float)(i +  - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
        double d2 = (float)(k +  + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d3 = (float)(k +  - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d4 = j + random.nextInt(3) + 2;
        double d5 = j + random.nextInt(3) + 2;
        for(int l = 0; l <= numberOfBlocks; l++)
        {
            double d6 = d + ((d1 - d) * (double)l) / (double)numberOfBlocks;
            double d7 = d4 + ((d5 - d4) * (double)l) / (double)numberOfBlocks;
            double d8 = d2 + ((d3 - d2) * (double)l) / (double)numberOfBlocks;
            double d9 = (random.nextDouble() * (double)numberOfBlocks) / 16D;
            double d10 = (double)(MathHelper.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            double d11 = (double)(MathHelper.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            int i1 = MathHelper.floor_double(d6 - d10 / 2D);
            int j1 = MathHelper.floor_double(d7 - d11 / 2D);
            int k1 = MathHelper.floor_double(d8 - d10 / 2D);
            int l1 = MathHelper.floor_double(d6 + d10 / 2D);
            int i2 = MathHelper.floor_double(d7 + d11 / 2D);
            int j2 = MathHelper.floor_double(d8 + d10 / 2D);
            for(int k2 = i1; k2 <= l1; k2++)
            {
                double d12 = (((double)k2 + 0.5D) - d6) / (d10 / 2D);
                if(d12 * d12 >= 1.0D)
                {
                    continue;
                }
                for(int l2 = j1; l2 <= i2; l2++)
                {
                    double d13 = (((double)l2 + 0.5D) - d7) / (d11 / 2D);
                    if(d12 * d12 + d13 * d13 >= 1.0D)
                    {
                        continue;
                    }
                    for(int i3 = k1; i3 <= j2; i3++)
                    {
                        double d14 = (((double)i3 + 0.5D) - d8) / (d10 / 2D);
                        if(d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlockId(k2, l2, i3) == YOURMOD.STONE.blockID && world.getBlockMetadata(k2, l2, i3) <= 1)
//Put your dimension's basic material (stone)
                        {
                            world.setBlock(k2, l2, i3, minableBlockID);
                        }
                    }

                }

            }

        }

        return true;
    }
}


 

Posted
Create new class named OreGenMinable. Put this in:

 

Why would you do that?

 

Just go to your chunkProvider class and put this in there (in the public void populate)

Example:

WorldGenMinable worldgenminable;
        int j2;

        for (int i = 0; i < 7; i++)
	{
		int randPosX = k + soulRNG.nextInt(16);
		int randPosY = soulRNG.nextInt(128);				//Rarerity 6 (1-15) 1 is very common 15 is extremely rare
		int randPosZ = l + soulRNG.nextInt(16);
		(new WorldGenMinable(mod_Ores.Amazoniteore.blockID, 7, mod_Ores.Slate.blockID)).generate(worldObj, soulRNG, randPosX, randPosY, randPosZ);
	}
	for (int i = 0; i < 9; i++)
	{
		int randPosX = k + soulRNG.nextInt(16);
		int randPosY = soulRNG.nextInt(128);				//Rarerity 4 (1-15) 1 is very common 15 is extremely rare
		int randPosZ = l + soulRNG.nextInt(16);
		(new WorldGenMinable(mod_Ores.Amethystore.blockID, 9, mod_Ores.Porphyry.blockID)).generate(worldObj, soulRNG, randPosX, randPosY, randPosZ);
	}
	for (int i = 0; i < 9; i++)
	{
		int randPosX = k + soulRNG.nextInt(16);
		int randPosY = soulRNG.nextInt(128);				//Rarerity 4 (1-15) 1 is very common 15 is extremely rare
		int randPosZ = l + soulRNG.nextInt(16);	
		(new WorldGenMinable(mod_Ores.Aquamarineore.blockID, 9, mod_Ores.Slate.blockID)).generate(worldObj, soulRNG, randPosX, randPosY, randPosZ);
	}

 

Thats how i did it and that works, just note that i have mod_Ores.Slate.blockID set as the block it needs to replace, for the overworld this is stone.

Posted

You are seriously mentally retarded.

No offense.

 

Learn java.

The vanilla WorldGenMinable only makes ores spawn when the dimension uses the vanilla: "Stone"

You need to create a new GenMinable if you want the ores to spawn in a custom: "Stone"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please read the FAQ and post logs as described there.
    • Upon starting the server I get; [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     Framework (framework) has failed to load correctly §7java.lang.NoClassDefFoundError: net/minecraft/client/gui/components/toasts/Toast ] I suspect there is a (possibly a few) client-only mods installed on my server. Any help would be appreciated! (Yes I know there are a lot of mods...) Here is the crash log:   https://paste.ee/p/pRz5mhMl#s=0
    • That's basically what the failure does, my apologies for failing to specify.  It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity.  From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user.  There should be few cases where that actually happens. Yes, that is my understanding of forceloading.  That's why on a successful summon, it removes the forceload.  Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful!  I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
    • I will have to do more research about 1.18 chunk loading. You were unclear about how your code manages with the entity load failure. If you simply used a loop, I suggest submitting a tick task to the next tick which does the same thing, checking if the entities are loaded and if so teleporting the right one else submitting another tick task etc. Also I think forceloading permanently force loads the chunk, and it only starts to unload when you make a subsequent call to mark the chunk as not forceloaded. I may be completely wrong, I dont know much about 1.18, most of my experience is 1.20. Good luck I hope you figure it out after all this time 😅
    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.