Compatibility of "GTOres" and "Astrominer" from "Galacticraft 3". Need help with NBT

The real problem there is, I cant explain super basic programming stuff well, like you dont have any prerequisites to understand what i am saying…

Example of that, I would have just told you to “make it into what you need it to be” because it is that basic to do, if you know programming.

You are already at the stage where all arcane bullshit from Minecraft has been taken care of and you can write the Code the way you want it to be.

1 Like

You are completely right!
My main problem is the lack of basic programming knowledge. I don’t have enough example to solve my task.
I have code:

Summary
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister reg) {
        this.blockIcons = new IIcon[9];
        this.blockIcons[0] = reg.registerIcon(TEXTURE_PREFIX + "CertusQuartz");
        this.blockIcons[1] = reg.registerIcon(TEXTURE_PREFIX + "Cooperite");
        this.blockIcons[2] = reg.registerIcon(TEXTURE_PREFIX + "Dolamide");
        this.blockIcons[3] = reg.registerIcon(TEXTURE_PREFIX + "Iridium");
        this.blockIcons[4] = reg.registerIcon(TEXTURE_PREFIX + "Naquadah");
        this.blockIcons[5] = reg.registerIcon(TEXTURE_PREFIX + "Pyrite");
        this.blockIcons[6] = reg.registerIcon(TEXTURE_PREFIX + "Scheelite");
        this.blockIcons[7] = reg.registerIcon(TEXTURE_PREFIX + "Sperrylite");
        this.blockIcons[8] = reg.registerIcon(TEXTURE_PREFIX + "Trinium");
        this.blockIcon = this.blockIcons[0];
    }

    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
    {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
        ret.add(OP.dust.mat(MT.STONES.SpaceRock, 1));
        ret.add(OP.crushed.mat(MATERIAL, 1));

        return ret;
    }

I can’t build the chain correctly (this is an example circuit):

    smallore1[metadata] = GT6_Material[material]
    MATERIAL = smallore1[metadata]
            ...
            ret.add(OP.crushed.mat(MATERIAl, 1));
            ...

I deeply apologize for the stupid questions and the inconvenience caused.
I hope after some time I will figure out how to do it.

2 Likes

It is not abut the inconvenience, its simply because I dont know how to exactly explain it to you that you can just create an Array like the following and then use metadata as the index.

public static final OreDictMaterial[] MY_ORE_MATERIALS = {MT.CertusQuartz, MT.OREMATS.Cooperite, MT.OREMATS.Dolamide, MT.Ir, MT.Nq, MT.Pyrite, MT.OREMATS.Scheelite, MT.OREMATS.Sperrylite, MT.Ke, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL};

public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    ret.add(OP.dust.mat(MT.STONES.SpaceRock, 1));
    ret.add(OP.crushed.mat(MY_ORE_MATERIALS[metadata], 1));
    return ret;
}

And yes the MT.NULL is necessary but for Arcane Minecraft Bullshit reasons I did not want to mention.

2 Likes

Ooo double whammy, learning both programming and the horrors of MC coding (which is not well designed at all), plus the GT api on top is definitely hard… You are doing it quite well and learning quickly though! Don’t be discouraged, it is a lot, but definitely doable. :slight_smile:

That code you showed I think is great, if @Lucelarius has questions about any part of it don’t hesitate to ask at all! :slight_smile:

2 Likes

Thank you!
It was exactly what we needed!

I also tried to use your code “getDrops” and after a little adjustment I got the desired result:

Here's what happened
    public static final OreDictMaterial[] aMaterial = {MT.CertusQuartz, MT.OREMATS.Cooperite, MT.Dolamide, MT.Ir, MT.Nq, MT.Pyrite, MT.OREMATS.Scheelite, MT.OREMATS.Sperrylite, MT.Ke, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL, MT.NULL};

    public ArrayList<ItemStack> getDrops(World World, int aX, int aY, int aZ, int aMetaData, int aFortune) {
        ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
        OreDictMaterial mSecondaryDrop = MT.STONES.SpaceRock;
        if (aMaterial[aMetaData] != null) aMaterial[aMetaData] = aMaterial[aMetaData].mTargetCrushing.mMaterial;

        if (aMaterial[aMetaData] != null) {
            Random tRandom = new Random(aX ^ aY ^ aZ);
            for (int i = 0; i < 16; i++) tRandom.nextInt(10000);
            if (aMaterial[aMetaData] == MT.STONES.Gneiss || aMaterial[aMetaData] == MT.PetrifiedWood) {
                ItemStack tStack = OP.rockGt.mat(aMaterial[aMetaData], 1);
                for (int i = 0, j = Math.max(1, aMaterial[aMetaData].mOreMultiplier*aMaterial[aMetaData].mOreProcessingMultiplier+(aFortune>0?(tRandom.nextInt((1+aFortune)*aMaterial[aMetaData].mOreMultiplier*aMaterial[aMetaData].mOreProcessingMultiplier)):0)/2+tRandom.nextInt(2)); i < j; i++) {
                    rList.add(ST.update(ST.copy(tStack)));
                }
            } else {
                ItemStack tStack = OP.gemLegendary.mat(aMaterial[aMetaData], 1);
                if (tStack != null && tRandom.nextInt(10000) <= aFortune) {
                    rList.add(ST.update(tStack));
                } else {
                    ArrayList<ItemStack> tSelector = new ArrayList<ItemStack>();
                    tStack = OP.gemExquisite.mat(aMaterial[aMetaData], OP.gem.mat(aMaterial[aMetaData], 4), 1);
                    if (tStack != null) for (int i = 0, j = 1; i < j; i++) tSelector.add(tStack);
                    tStack = OP.gemFlawless.mat(aMaterial[aMetaData], OP.gem.mat(aMaterial[aMetaData], 2), 1);
                    if (tStack != null) for (int i = 0, j = 2; i < j; i++) tSelector.add(tStack);
                    tStack = OP.gem.mat(aMaterial[aMetaData], 1);
                    if (tStack != null) for (int i = 0, j = 12; i < j; i++) tSelector.add(tStack);

                    tStack = OP.gemFlawed.mat(aMaterial[aMetaData], 2);
                    if (tStack != null){for (int i = 0, j = 5; i < j; i++) tSelector.add(tStack);
                        tStack = OP.crushed.mat(aMaterial[aMetaData], 1);
                        if (tStack != null) for (int i = 0, j = 10; i < j; i++) tSelector.add(tStack);
                    } else {
                        tStack = OP.crushed.mat(aMaterial[aMetaData], 1);
                        if (tStack != null) for (int i = 0, j = 15; i < j; i++) tSelector.add(tStack);
                    }

                    tStack = OP.gemChipped.mat(aMaterial[aMetaData], 4);
                    if (tStack != null){for (int i = 0, j = 5; i < j; i++) tSelector.add(tStack);
                        tStack = OP.crushed.mat(aMaterial[aMetaData], OP.dust.mat(aMaterial[aMetaData], 1), 1);
                        if (tStack != null) for (int i = 0, j = 10; i < j; i++) tSelector.add(tStack);
                    } else {
                        tStack = OP.crushed.mat(aMaterial[aMetaData], 1);
                        if (tStack != null) for (int i = 0, j = 15; i < j; i++) tSelector.add(tStack);
                    }

                    if (tSelector.size() > 0) {
                        for (int i = 0, j = Math.max(1, aMaterial[aMetaData].mOreMultiplier*aMaterial[aMetaData].mOreProcessingMultiplier+(aFortune>0?(tRandom.nextInt((1+aFortune)*aMaterial[aMetaData].mOreMultiplier*aMaterial[aMetaData].mOreProcessingMultiplier)):0)/2); i < j; i++) {
                            rList.add(ST.update(ST.copy(tSelector.get(tRandom.nextInt(tSelector.size())))));
                        }
                    }
                }
            }
            if (tRandom.nextInt(3+aFortune)>1) rList.add(ST.update(OP.dust.mat(mSecondaryDrop.mTargetCrushing.mMaterial, 1)));
        }
        return rList;
    }

I don’t know if it’s right or not, but it works :slightly_smiling_face:

1 Like

I need help again…
I’m trying to implement generation of veins in asteroids like in GT instead of the standard generation of one ore in one asteroid.
I’m having difficulty building arrays and methods

This is the original ore generation code:

Original

ChunkProviderAsteroids

public class ChunkProviderAsteroids extends ChunkProviderGenerate
{
    private final SpecialAsteroidBlockHandler coreHandler;

    public ChunkProviderAsteroids(World par1World, long par2, boolean par4)
    {
        //

        this.coreHandler = new SpecialAsteroidBlockHandler();
        //Diamond ore - has no config to disable
        this.coreHandler.addBlock(new SpecialAsteroidBlock(Blocks.diamond_ore, (byte) 0, 1, .1));
    }
}

SpecialAsteroidBlockHandler

public class SpecialAsteroidBlockHandler
{

    ArrayList<SpecialAsteroidBlock> asteroidBlocks;

    public SpecialAsteroidBlockHandler(SpecialAsteroidBlock... asteroidBlocks)
    {
        this.asteroidBlocks = new ArrayList<SpecialAsteroidBlock>();
        for (SpecialAsteroidBlock asteroidBlock : this.asteroidBlocks)
        {
            for (int i = 0; i < asteroidBlock.probability; i++)
            {
                this.asteroidBlocks.add(asteroidBlock);
            }
        }
    }

    public SpecialAsteroidBlockHandler()
    {
        this.asteroidBlocks = new ArrayList<SpecialAsteroidBlock>();
    }

    public void addBlock(SpecialAsteroidBlock asteroidBlock)
    {
        for (int i = 0; i < asteroidBlock.probability; i++)
        {
            this.asteroidBlocks.add(asteroidBlock);
        }
    }

    public SpecialAsteroidBlock getBlock(Random rand, int size)
    {
        int s = this.asteroidBlocks.size();
        if (s < 10)
        	return this.asteroidBlocks.get(rand.nextInt(s));
        
        Double r = rand.nextDouble();
        int index = (int) (s * Math.pow(r, (size + 5) * 0.05D));
    	return this.asteroidBlocks.get(index);
    }

}

SpecialAsteroidBlock

public class SpecialAsteroidBlock
{

    public Block block;
    public byte meta;
    public int probability;
    public double thickness; //Arbitrary scale from 0 to 1;
    public int index;
    public static ArrayList<SpecialAsteroidBlock> register = new ArrayList();

    public SpecialAsteroidBlock(Block block, byte meta, int probability, double thickness)
    {
        this.block = block;
        this.meta = meta;
        this.probability = probability;
        this.thickness = thickness;
        this.index = register.size();
        register.add(this);
    }
}

I’m thinking of doing something like this:

Embedding option
this.eOreLayerHandler = new GCAOE_OresLayerHandler();
this.eOreLayerHandler.addLayerName(new GCAOE_OresLayerName("lQuartz", 1, .2)); //"lQuartz" - Name of ore vein

More like this

public class GCAOE_OresLayerList {
    public void list() {
        new GCAOE_OresLayerName("lQuartz", EBlock.ore2[7], EBlock.ore2[1], EBlock.ore1[0], EBlock.ore1[0]);
        new GCAOE_OresLayerName("lGold", EBlock.ore1[5], EBlock.ore2[2], EBlock.ore2[0], EBlock.ore2[6]);
        new GCAOE_OresLayerName("lPlatinum", EBlock.ore1[1], EBlock.ore2[8], EBlock.ore1[7], EBlock.ore1[3]);
        new GCAOE_OresLayerName("lTungstate", EBlock.ore1[6], EBlock.ore2[10], EBlock.ore2[11], EBlock.ore2[9]);
        new GCAOE_OresLayerName("lNaquadah", EBlock.ore1[4], EBlock.ore1[4], EBlock.ore1[4], EBlock.ore1[4]);
        new GCAOE_OresLayerName("lTrinium", EBlock.ore1[8], EBlock.ore1[8], EBlock.ore1[8], EBlock.ore1[8]);
        new GCAOE_OresLayerName("lDolamide", EBlock.ore2[5], EBlock.ore2[4], EBlock.ore2[3], EBlock.ore1[2]);
    }
}

This is still a draft version for visual perception.

2 Likes

Oh no, I have no Idea what you are trying to do, when reading your Code…

So uhh, what is this supposed to do? And in which Dimension is it supposed to do that? I feel like you are trying to copy what other people do without knowing what any of this Stuff does…

2 Likes

This is the part of the code that is responsible for generating asteroids in Galacticraft.

this.coreHandler.addBlock(new SpecialAsteroidBlock(Blocks.diamond_ore, (byte) 0, probability: 1, thickness: .2));

coreHandler - responsible for the generation of asteroid cores
Blocks.diamond_ore - block to be used in generation
(byte) 0 - this block’s metadata
probability: 1 - generation chance
thickness: .2 - the density or size of the core relative to the size of the asteroid

I can just substitute my blocks there and everything will work.
I’m trying to substitute in the existing generation instead of one block of ore, the generation of a vein from 4 different blocks as in GT6

UPD:
I don’t know yet if this will work.
I can’t write code for ore layers like in GT6: OreTop, OreBottom, OreBetween, OreSpread.
I’m trying to create something similar to yours:

WorldgenOresLarge
@SafeVarargs
	public WorldgenOresLarge(String aName, boolean aDefault, boolean aIndicatorRocks, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, OreDictMaterial aTop, OreDictMaterial aBottom, OreDictMaterial aBetween, OreDictMaterial aSpread, List<WorldgenObject>... aLists) {
		super(aName, aDefault, aLists);
		mMinY               = (short)Math.max(0,        getConfigFile().get(mCategory, "MinHeight"        , aMinY));
		mMaxY               = (short)Math.max(mMinY+5,  getConfigFile().get(mCategory, "MaxHeight"        , aMaxY));
		mWeight             =        Math.max(1,        getConfigFile().get(mCategory, "RandomWeight"     , aWeight));
		mDensity            = (short)Math.max(1,        getConfigFile().get(mCategory, "Density"          , aDensity));
		mDistance           =        Math.max(0,        getConfigFile().get(mCategory, "DistanceFromSpawn", 0));
		mSize               = (short)Math.max(1,        getConfigFile().get(mCategory, "Size"             , aSize));
		mIndicatorRocks     =                           getConfigFile().get(mCategory, "IndicatorRocks"   , aIndicatorRocks);
		mTop                =                           getConfigFile().get(mCategory, "OreTop"           , aTop);
		mBottom             =                           getConfigFile().get(mCategory, "OreBottom"        , aBottom);
		mBetween            =                           getConfigFile().get(mCategory, "OreBetween"       , aBetween);
		mSpread             =                           getConfigFile().get(mCategory, "OreSpread"        , aSpread);
2 Likes

A word of advice, copying my GT5 Style Worldgen is too advanced for someone who does not know programming, so I would recommend trying to do your own thing and understanding how Worldgen works first.

GT5 Style ore Generation has so much special Code in it, its nearly impossible to understand what the fuck it is doing, let alone rewrite it to work with non-GT Ore Blocks.

2 Likes

I agree. Your code is very complex for me, but so far this is the only example of what I want to get.
I understand that copying the GT5 code is useless, and it’s not necessary either. I am trying in a simpler way to repeat the very logic of generating a vein from several layers of ore.
I don’t understand how to properly work with blocks using metadata and arrays. This is exactly what my problem is.
This requires a little more knowledge than a basic programming course provides. I can’t even find similar examples with explanations.

2 Likes

I think I’ll leave the single ore generation and just adjust the generation chances.
I just want to play my build…
But in general, minecraft became interesting to me only when they showed me such a mod as GregTech (then it was GregTech 4) :slightly_smiling_face:

3 Likes