[Help] Generated Ores Other Mods in My Planet/Moon.

BlesseNtumble

Member
Content developer
Galaxy Space
Space Ambient
Nov 1, 2014
314
70
28
26
α Centauri Bb
Hello radfast.
I'm trying to do in my addon generation ores from other mods.
In "Init" main fashion I register:
Code:
MinecraftForge.EVENT_BUS.register(new OreGenOtherModsGS());
Then took a class and rewritten for WorldProviderPhobos:

Code:
package blessentumble.core.configs;

import micdoodle8.mods.galacticraft.api.event.wgen.GCCoreEventPopulate;
import micdoodle8.mods.galacticraft.api.vector.BlockTuple;
import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider;
import micdoodle8.mods.galacticraft.core.GalacticraftCore;
import micdoodle8.mods.galacticraft.core.dimension.WorldProviderOrbit;
import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore;
import micdoodle8.mods.galacticraft.core.util.GCLog;
import micdoodle8.mods.galacticraft.core.world.gen.WorldGenMinableMeta;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.gen.feature.WorldGenerator;

import java.util.ArrayList;
import java.util.Random;

import blessentumble.core.blocks.BlocksAddon;
import blessentumble.moons.deimos.dimension.WorldProviderDeimos;
import blessentumble.moons.enceladus.dimension.WorldProviderEnceladus;
import blessentumble.moons.europa.dimension.WorldProviderEuropa;
import blessentumble.moons.io.dimension.WorldProviderIo;
import blessentumble.moons.phobos.dimension.WorldProviderPhobos;
import blessentumble.planets.mercury.dimension.WorldProviderMercury;
import blessentumble.planets.venus.dimension.WorldProviderVenus;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class OreGenOtherModsGS
{
private World worldObj;
private Random randomGenerator;

private int chunkX;
private int chunkZ;

private WorldGenerator oreGen;
public static ArrayList<OreGenData> data = new ArrayList<OreGenData>();

static
{
for (final String str : PlanetsConfig.oregenIDs)
{
try
{
int slash = str.indexOf('/');
String s;
int rarity = 0; //0 = common 1 = uncommon 2 = rare
int depth = 0; //0 = even 1 = deep 2 = shallow
int size = 1; //0 = single 1 = standard 2 = large
boolean extraRandom = false;
int dim = 0;

if (slash >= 0)
{
s = str.substring(0, slash).trim();
String params = str.substring(slash).toUpperCase();
if (params.contains("UNCOMMON")) rarity = 1;
else if (params.contains("RARE")) rarity = 2;

if (params.contains("DEEP")) depth = 1;
else if (params.contains("SHALLOW")) depth = 2;

if (params.contains("SINGLE")) size = 0;
else if (params.contains("LARGE")) size = 2;

if (params.contains("XTRARANDOM")) extraRandom = true;

if (params.contains("ONLYMOON")) dim = 1;
else if (params.contains("ONLYMARS")) dim = 2;

}
else s = str;

BlockTuple bt = ConfigManagerCore.stringToBlock(s, "Other mod ore generate IDs", true);
if (bt == null) continue;

int meta = bt.meta;
if (meta == -1) meta = 0;

OreGenOtherModsGS.addOre(bt.block, meta, rarity, depth, size, extraRandom, dim);
}
catch (final Exception e)
{
GCLog.severe("[config] External Sealable IDs: error parsing '" + str + "'. Must be in the form Blockname or BlockName:metadata followed by / parameters ");
}
}
}

public static void addOre(Block block, int meta, int rarity, int depth, int clumpSize, boolean extraRandom, int dim)
{
int clusters = 12;
int size = 4;
int min = 0;
int max = 64;

switch(depth)
{
case 0:
//Evenly distributed
size = 6;
clusters = 20;
max = 80;
if (rarity == 1)
{
clusters = 9;
size = 4;
}
else if (rarity == 2)
{
clusters = 6;
size = 3;
max = 96;
}
break;
case 1:
//Deep
size = 5;
clusters = 12;
max = 32;
if (rarity == 1)
{
clusters = 6;
size = 4;
max = 20;
}
else if (rarity == 2)
{
clusters = 2;
size = 3;
max = 16;
}
break;
case 2:
//Shallow
size = 6;
clusters = 15;
min = 32;
max = 80;
if (rarity == 1)
{
clusters = 8;
size = 4;
min = 32;
max = 72;
}
else if (rarity == 2)
{
clusters = 3;
size = 3;
min = 40;
max = 64;
}
}

if (clumpSize == 0)
{
size = 1;
clusters = (3 * clusters) / 2;
}
else if (clumpSize == 2)
{
size *= 4;
clusters /= 2;
}

if (extraRandom)
{
if (depth == 1)
{
min = -max * 3;
}
else
max *= 4;
}

OreGenData ore = new OreGenData(block, meta, clusters, size, min, max, dim);
OreGenOtherModsGS.data.add(ore);
}

@SubscribeEvent
public void onPlanetDecorated(GCCoreEventPopulate.Post event)
{
this.worldObj = event.worldObj;
this.randomGenerator = event.rand;
this.chunkX = event.chunkX;
this.chunkZ = event.chunkZ;

int dimDetected = 0;

WorldProvider prov = worldObj.provider;
if (!(prov instanceof IGalacticraftWorldProvider) || (prov instanceof WorldProviderOrbit))
return;

Block stoneBlock = null;
int stoneMeta = 0;

if (GalacticraftCore.isPlanetsLoaded && prov instanceof WorldProviderPhobos)
{
stoneBlock = BlocksAddon.BlockRock;
stoneMeta = 0;
dimDetected = 1;
}


if (stoneBlock == null) return;

for (OreGenData ore : OreGenOtherModsGS.data)
{
if (ore.dimRestrict == 0 || ore.dimRestrict == dimDetected)
{
this.oreGen = new WorldGenMinableMeta(ore.oreBlock, ore.sizeCluster, ore.oreMeta, true, stoneBlock, stoneMeta);
this.genStandardOre1(ore.numClusters, this.oreGen, ore.minHeight, ore.maxHeight);
}
}
}

void genStandardOre1(int amountPerChunk, WorldGenerator worldGenerator, int minY, int maxY)
{
for (int var5 = 0; var5 < amountPerChunk; ++var5)
{
final int var6 = this.chunkX + this.randomGenerator.nextInt(16);
final int var7 = this.randomGenerator.nextInt(maxY - minY) + minY;
if (var7 < 0) continue;
final int var8 = this.chunkZ + this.randomGenerator.nextInt(16);
worldGenerator.generate(this.worldObj, this.randomGenerator, var6, var7, var8);
}
}

public static class OreGenData
{
public Block oreBlock = BlocksAddon.BlockStone;
public int oreMeta = 0;
public int sizeCluster = 4;
public int numClusters = 8;
public int minHeight = 0;
public int maxHeight = 128;
public int dimRestrict = 0;

public OreGenData(Block block, int meta, int num, int cluster, int min, int max, int dim)
{
this.oreBlock = block;
this.oreMeta = meta;
this.sizeCluster = cluster;
this.numClusters = num;
this.minHeight = min;
this.maxHeight = max;
this.dimRestrict = dim;
}

public OreGenData(Block block, int meta, int num, int cluster)
{
this.oreBlock = block;
this.oreMeta = meta;
this.sizeCluster = cluster;
this.numClusters = num;
this.minHeight = 0;
this.maxHeight = 128;
}

public OreGenData(Block block, int meta, int num)
{
this.oreBlock = block;
this.oreMeta = meta;
this.sizeCluster = 4;
this.numClusters = num;
this.minHeight = 0;
this.maxHeight = 128;
}
}
}

Made such a config file:
Code:
general {
# Enter IDs of other mods' ores here for Galacticraft to generate them on GS planets. Format is BlockName or BlockName:metadata."
<
586:1
>
}
But the trouble is that no generation. Where is my mistake?
 

radfast

Member
Staff member
Apr 27, 2014
1,118
339
83
Hello.

I don't know. Some possible ideas for you to try:

1. Is your mod's worldgen for Phobos using galacticraft.api.prefab.world.gen.BiomeDecoratorSpace - specifically, the call to decorate() which fires the GCCoreEventPopulate.Pre and GCCoreEventPopulate.Post?

2. In OreGenOtherModsGS have you set up the stone you want to replace correctly? It works by searching for a type of stone given by block ID + metadata, and only replacing that one type of stone with ores. (This stops oregen damaging structures.) In vanilla Minecraft it's Plain Stone. On the Moon it's Moon Rock. On Mars it's Mars Stone. You get the idea...

3. Other than that, you should add log lines to your code and have it log when it reaches certain points then you can maybe see what is going on here.
 

BlesseNtumble

Member
Content developer
Galaxy Space
Space Ambient
Nov 1, 2014
314
70
28
26
α Centauri Bb
1) public class BiomeDecoratorPhobos extends BiomeDecoratorSpace

Code:
@Override
protected BiomeDecoratorSpace getBiomeGenerator() {
return new BiomeDecoratorPhobos();

}
2) I registered block: public static PhobosBlockStone BlockStone;
In ChunkProviderPhobos:

Code:
@Override
protected BlockMetaPair getStoneBlock() {

return new BlockMetaPair(BlocksAddon.BlockStone, (byte) 0);

}
 

radfast

Member
Staff member
Apr 27, 2014
1,118
339
83
I can't help you more without your whole code, and I don't really have time for that, very sorry.

Please try logging at the different stages in the code for this (sometimes I just log "1", "2", "3" etc) and you can easily see which part of your code has been reached and which has not been reached.

Galacticraft Mars is supposed to be implemented using the exact same API which is available for addons, so my general answer is look and see how Mars does it. There is only a very small amout of special code in Galacticraft .core or .api to implement Mars, and that's mainly for the TileEntityLaunchController and similar.
 

Share this page