Jump to content

[SOLVED][1.7.10]Custom Tree wont spawn from custom sapling


AOSPLolipop

Recommended Posts

Me again! :( :( :(:-[ :'(

 

So I created a new sapling, (SoulSapling) that is supposed to spawn a new tree type (SoulTree). The code doesnt have an error, it just doesnt do anything, like a decoration block, and i need it to grow this tree type but it wont!

 

The Code(tree gen)

 

package com.aosp.world;

import java.util.Random;

import com.aosp.Blocks.VBlocks;

import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.init.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.util.ForgeDirection;

public class SoulTreeGen extends WorldGenAbstractTree implements IWorldGenerator{

private final int minTreeHeight;
private final boolean vinesGrow;
private final int metaWood;
private final int metaLeaves;
private static final String __OBFID = "CL_00000438";

public SoulTreeGen(boolean p_i2027_1_)
{
	this(p_i2027_1_, 4, 0, 0, false);
}

public SoulTreeGen(boolean doBlockNotify, int treeHeight, int wood, int leaves, boolean vines)
{
        super(doBlockNotify);
        this.minTreeHeight = treeHeight;
        this.metaWood = wood;
        this.metaLeaves = leaves;
        this.vinesGrow = vines;
}
    public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_)
    {
        int l = p_76484_2_.nextInt(3) + this.minTreeHeight;
        boolean flag = true;

        if (p_76484_4_ >= 1 && p_76484_4_ + l + 1 <= 256)
        {
            byte b0;
            int k1;
            Block block;

            for (int i1 = p_76484_4_; i1 <= p_76484_4_ + 1 + l; ++i1)
            {
                b0 = 1;

                if (i1 == p_76484_4_)
                {
                    b0 = 0;
                }

                if (i1 >= p_76484_4_ + 1 + l - 2)
                {
                    b0 = 2;
                }

                for (int j1 = p_76484_3_ - b0; j1 <= p_76484_3_ + b0 && flag; ++j1)
                {
                    for (k1 = p_76484_5_ - b0; k1 <= p_76484_5_ + b0 && flag; ++k1)
                    {
                        if (i1 >= 0 && i1 < 256)
                        {
                            block = p_76484_1_.getBlock(j1, i1, k1);

                            if (!this.isReplaceable(p_76484_1_, j1, i1, k1))
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }

            if (!flag)
            {
                return false;
            }
            else
            {
                Block block2 = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ - 1, p_76484_5_);

                boolean isSoil = block2.canSustainPlant(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, ForgeDirection.UP, (BlockSapling)VBlocks.SoulSapling);
                if (isSoil && p_76484_4_ < 256 - l - 1)
                {
                    block2.onPlantGrow(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, p_76484_3_, p_76484_4_, p_76484_5_);
                    b0 = 3;
                    byte b1 = 0;
                    int l1;
                    int i2;
                    int j2;
                    int i3;

                    for (k1 = p_76484_4_ - b0 + l; k1 <= p_76484_4_ + l; ++k1)
                    {
                        i3 = k1 - (p_76484_4_ + l);
                        l1 = b1 + 1 - i3 / 2;

                        for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2)
                        {
                            j2 = i2 - p_76484_3_;

                            for (int k2 = p_76484_5_ - l1; k2 <= p_76484_5_ + l1; ++k2)
                            {
                                int l2 = k2 - p_76484_5_;

                                if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || p_76484_2_.nextInt(2) != 0 && i3 != 0)
                                {
                                    Block block1 = p_76484_1_.getBlock(i2, k1, k2);

                                    if (block1.isAir(p_76484_1_, i2, k1, k2) || block1.isLeaves(p_76484_1_, i2, k1, k2))
                                    {
                                        this.setBlockAndNotifyAdequately(p_76484_1_, i2, k1, k2, VBlocks.SoulTreeLeaves, this.metaLeaves);
                                    }
                                }
                            }
                        }
                    }

                    for (k1 = 0; k1 < l; ++k1)
                    {
                        block = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_);

                        if (block.isAir(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_) || block.isLeaves(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_))
                        {
                            this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_, VBlocks.SoulTree_Log, this.metaWood);

                            if (this.vinesGrow && k1 > 0)
                            {
                                if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_))
                                {
                                    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, ;
                                }

                                if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_))
                                {
                                    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, 2);
                                }

                                if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1))
                                {
                                    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1, Blocks.vine, 1);
                                }

                                if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1))
                                {
                                    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1, Blocks.vine, 4);
                                }
                            }
                        }
                    }

                    if (this.vinesGrow)
                    {
                        for (k1 = p_76484_4_ - 3 + l; k1 <= p_76484_4_ + l; ++k1)
                        {
                            i3 = k1 - (p_76484_4_ + l);
                            l1 = 2 - i3 / 2;

                            for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2)
                            {
                                for (j2 = p_76484_5_ - l1; j2 <= p_76484_5_ + l1; ++j2)
                                {
                                    if (p_76484_1_.getBlock(i2, k1, j2).isLeaves(p_76484_1_, i2, k1, j2))
                                    {
                                        if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 - 1, k1, j2).isAir(p_76484_1_, i2 - 1, k1, j2))
                                        {
                                            this.growVines(p_76484_1_, i2 - 1, k1, j2, ;
                                        }

                                        if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 + 1, k1, j2).isAir(p_76484_1_, i2 + 1, k1, j2))
                                        {
                                            this.growVines(p_76484_1_, i2 + 1, k1, j2, 2);
                                        }

                                        if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 - 1).isAir(p_76484_1_, i2, k1, j2 - 1))
                                        {
                                            this.growVines(p_76484_1_, i2, k1, j2 - 1, 1);
                                        }

                                        if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 + 1).isAir(p_76484_1_, i2, k1, j2 + 1))
                                        {
                                            this.growVines(p_76484_1_, i2, k1, j2 + 1, 4);
                                        }
                                    }
                                }
                            }
                        }

                        if (p_76484_2_.nextInt(5) == 0 && l > 5)
                        {
                            for (k1 = 0; k1 < 2; ++k1)
                            {
                                for (i3 = 0; i3 < 4; ++i3)
                                {
                                    if (p_76484_2_.nextInt(4 - k1) == 0)
                                    {
                                        l1 = p_76484_2_.nextInt(3);
                                        this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + Direction.offsetX[Direction.rotateOpposite[i3]], p_76484_4_ + l - 5 + k1, p_76484_5_ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3);
                                    }
                                }
                            }
                        }
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        else
        {
            return false;
        }
    }

    /**
     * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length
     */
    private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_)
    {
        this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
        int i1 = 4;

        while (true)
        {
            --p_76529_3_;

            if (!p_76529_1_.getBlock(p_76529_2_, p_76529_3_, p_76529_4_).isAir(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_) || i1 <= 0)
            {
                return;
            }

            this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
            --i1;
        }
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	int x = random.nextInt(16);
	int z = random.nextInt(16);

	this.generate(world, random, x, world.getHeightValue(x, z), z);
}
}

 

 

World Generator

 

package com.aosp.world;

import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;

public class WorldGeneration {
public static void mainRegistry(){
	initializeWorldGen();
}

public static void initializeWorldGen(){
	registerWorldGen(new CoreOre(), 1);
}

public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProbability ){
	GameRegistry.registerWorldGenerator(worldGenClass, weightedProbability);
	GameRegistry.registerWorldGenerator(new SoulTreeGen(true, 4, 0, 0, false), 1);
}
}

 

 

Sapling

 

package com.aosp.BlocksClass;

import java.util.Random;

import com.aosp.lib.RefStrings;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;

public class SoulSapling extends BlockBush implements IGrowable{

public SoulSapling(Material p_i45394_1_) {
	super(p_i45394_1_);

}

@Override
public boolean func_149851_a(World arg0, int arg1, int arg2, int arg3,
		boolean arg4) {
	return false;
}

@Override
public boolean func_149852_a(World arg0, Random arg1, int arg2, int arg3,
		int arg4) {
	return false;
}

@Override
public void func_149853_b(World arg0, Random arg1, int arg2, int arg3,
		int arg4) {

}


}

 

 

Please help! :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(

Sarcasm doesn't always means what you think it means!

Link to comment
Share on other sites

Putting "URGENT HELP" in the title will not get you an answer any quicker (if anything it will achieve the opposite). Your question is not any more urgent than anybody else's question. And neither will filling your post with tons of needless emoticons.

 

Now that's that out of the way: Your code is a copy-pasted mess. Please rename your variables to something normal ("p_76484_2_" tells neither me nor you what that variable means). If your answer to this is "I didn't write this code I don't understand it" then my answer will be: There is your problem. If you do not understand your own code you need to fix that first.

 

OK.

So i translated (renamed) the variables, and did a little research online, so i was missing some parts of the code. Now that i added those missing parts, still the same :(

 

Then after that I rewrote the code but THE SAME!

I really need help about this.

 

Sapling code:

 

package com.aosp.BlocksClass;

import java.util.List;
import java.util.Random;

import com.aosp.Blocks.VBlocks;
import com.aosp.lib.RefStrings;
import com.aosp.world.SoulTreeGen;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.entity.player.BonemealEvent;

public class SoulSapling extends BlockBush implements IGrowable{
    public static boolean bonemealingAllowed;
public SoulSapling(Material p_i45394_1_) {
	super();		
}

@Override
public boolean func_149851_a(World arg0, int arg1, int arg2, int arg3,
		boolean arg4) {
	return false;
}

@Override
public boolean func_149852_a(World arg0, Random arg1, int arg2, int arg3,
		int arg4) {
	return false;
}

@Override
public void func_149853_b(World arg0, Random arg1, int arg2, int arg3,
		int arg4) {
    {
        this.func_149878_d1(arg0, arg2, arg3, arg4, arg1);
    }

}
    public static final String[] field_149882_a = new String[] {"SoulTree"};
    private static final String __OBFID = "CL_00000305";

    protected SoulSapling()
    {
        float f = 0.4F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
    }

    /**
     * Ticks the block if it's been scheduled
     */
    public void updateTick(World world, int posX, int posZ, int posY, Random random)
    {
        if (!world.isRemote)
        {
            super.updateTick(world, posX, posZ, posY, random);

            if (world.getBlockLightValue(posX, posZ + 1, posY) >= 9 && random.nextInt(7) == 0)
            {
                this.func_149878_d1(world, posX, posZ, posY, random);
            }
        }
    }
// grow tree
    public void func_149878_d1(World world, int x, int y, int z, Random r) {
    if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(
    world, r, x, y, z))
    return;
    // metadata of the sapling
    int l = world.getBlockMetadata(x, y, z) & 7;
    Object object = r.nextInt(10) == 0 ? new WorldGenBigTree(true)
    : new WorldGenTrees(true);
    int i1 = 0;
    int j1 = 0;
    boolean flag = false;

    switch (l) {
    case 0:
    object = new SoulTreeGen(VBlocks.getLog(),
    VBlocks.getLeaf(), 0, 0, false);
    break;
    case 1:
    object = new SoulTreeGen(VBlocks.getLog(),
    VBlocks.getLeaf(), 1, 1, false);
    break;
    default:
    break;
    }

    Block block = Blocks.air;

    if (flag) {
    world.setBlock(x + i1, y, z + j1, block, 0, 4);
    world.setBlock(x + i1 + 1, y, z + j1, block, 0, 4);
    world.setBlock(x + i1, y, z + j1 + 1, block, 0, 4);
    world.setBlock(x + i1 + 1, y, z + j1 + 1, block, 0, 4);
    } else {
    world.setBlock(x, y, z, block, 0, 4);
    }

    if (!((WorldGenerator) object).generate(world, r, x + i1, y, z + j1)) {
    if (flag) {
    world.setBlock(x + i1, y, z + j1, this, l, 4);
    world.setBlock(x + i1 + 1, y, z + j1, this, l, 4);
    world.setBlock(x + i1, y, z + j1 + 1, this, l, 4);
    world.setBlock(x + i1 + 1, y, z + j1 + 1, this, l, 4);
    } else {
    world.setBlock(x, y, z, this, l, 4);
    }
    }
    }


    //Grow tree
    public void func_149878_d(World world, int posX, int posZ, int posY, Random random)
    {
        if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, posX, posZ, posY)) return;
        int l = world.getBlockMetadata(posX, posZ, posY) & 7;
        Object object = random.nextInt(10) == 0 ? new SoulTreeGen(true) : new SoulTreeGen(true);
        int i1 = 0;
        int j1 = 0;
        boolean flag = false;

        switch (l)
        {
            case 0:
            default:
                break;
            case 1:


                if (!flag)
                {
                    j1 = 0;
                    i1 = 0;
                    object = new SoulTreeGen(true);
                }

                break;
            case 2:
                object = new SoulTreeGen(true);
                break;
            case 3:
                label93:

                for (i1 = 0; i1 >= -1; --i1)
                {
                    for (j1 = 0; j1 >= -1; --j1)
                    {
                        if (this.func_149880_a(world, posX + i1, posZ, posY + j1, 3) && this.func_149880_a(world, posX + i1 + 1, posZ, posY + j1, 3) && this.func_149880_a(world, posX + i1, posZ, posY + j1 + 1, 3) && this.func_149880_a(world, posX + i1 + 1, posZ, posY + j1 + 1, 3))
                        {
                            object = new SoulTreeGen(true);
                            flag = true;
                            break label93;
                        }   
                    }
                    
                }

                if (!flag)
                {
                    return;
                }
        }

        Block block = Blocks.air;

        if (flag)
        {
            world.setBlock(posX + i1, posZ, posY + j1, block, 0, 4);
            world.setBlock(posX + i1 + 1, posZ, posY + j1, block, 0, 4);
            world.setBlock(posX + i1, posZ, posY + j1 + 1, block, 0, 4);
            world.setBlock(posX + i1 + 1, posZ, posY + j1 + 1, block, 0, 4);
        }
        else
        {
            world.setBlock(posX, posZ, posY, block, 0, 4);
        }

        if (!((WorldGenerator)object).generate(world, random, posX + i1, posZ, posY + j1))
        {
            if (flag)
            {
                world.setBlock(posX + i1, posZ, posY + j1, this, l, 4);
                world.setBlock(posX + i1 + 1, posZ, posY + j1, this, l, 4);
                world.setBlock(posX + i1, posZ, posY + j1 + 1, this, l, 4);
                world.setBlock(posX + i1 + 1, posZ, posY + j1 + 1, this, l, 4);
            }
            else
            {
                world.setBlock(posX, posZ, posY, this, l, 4);
            }
        }
    }

    public boolean func_149880_a(World world, int posX, int posZ, int posY, int random)
    {
        return world.getBlock(posX, posZ, posY) == this && (world.getBlockMetadata(posX, posZ, posY) & 7) == random;
    }

    /**
     * Determines the damage on the item the block drops. Used in cloth and wood.
     */
    public int damageDropped(int dmg)
    {
        return MathHelper.clamp_int(dmg & 7, 0, 5);
    }


}

 

 

TreeGen:

 

package com.aosp.world;

import java.util.Random;

import com.aosp.Blocks.VBlocks;
import com.aosp.BlocksClass.SoulSapling;

import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.init.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.util.ForgeDirection;

public class SoulTreeGen extends WorldGenAbstractTree implements IWorldGenerator{
    public static boolean bonemealingAllowed;
private final int minTreeHeight;
private final boolean vinesGrow;
private final int metaWood;
private final int metaLeaves;
private static final String __OBFID = "CL_00000438";

public SoulTreeGen(boolean SS)
{
	this(SS, 4, 0, 0, false);
}

public SoulTreeGen(boolean doBlockNotify, int treeHeight, int wood, int leaves, boolean vines)
{
        super(doBlockNotify);
        this.minTreeHeight = treeHeight;
        this.metaWood = wood;
        this.metaLeaves = leaves;
        this.vinesGrow = vines;
}
    public boolean generate(World world, Random random, int posX, int posZ, int posY)
    {
        int l =random.nextInt(3) + this.minTreeHeight;
        boolean flag = true;

        if (posZ >= 1 && posZ + l + 1 <= 256)
        {
            byte b0;
            int k1;
            Block block;

            for (int i1 = posZ; i1 <= posZ + 1 + l; ++i1)
            {
                b0 = 1;

                if (i1 == posZ)
                {
                    b0 = 0;
                }

                if (i1 >= posZ + 1 + l - 2)
                {
                    b0 = 2;
                }

                for (int j1 = posX - b0; j1 <= posX + b0 && flag; ++j1)
                {
                    for (k1 = posY - b0; k1 <= posY + b0 && flag; ++k1)
                    {
                        if (i1 >= 0 && i1 < 256)
                        {
                            block = world.getBlock(j1, i1, k1);

                            if (!this.isReplaceable(world, j1, i1, k1))
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }

            if (!flag)
            {
                return false;
            }
            else
            {
                Block block2 = world.getBlock(posX, posZ - 1, posY);

                boolean isSoil = block2.canSustainPlant(world, posX, posZ - 1, posY, 
                		ForgeDirection.UP, 
                		(SoulSapling)VBlocks.SoulSapling);
                if (isSoil && posZ < 256 - l - 1)
                {
                    block2.onPlantGrow(world, posX, posZ - 1, posY, posX, posZ, posY);
                    b0 = 3;
                    byte b1 = 0;
                    int l1;
                    int i2;
                    int j2;
                    int i3;

                    for (k1 = posZ - b0 + l; k1 <= posZ + l; ++k1)
                    {
                        i3 = k1 - (posZ + l);
                        l1 = b1 + 1 - i3 / 2;

                        for (i2 = posX - l1; i2 <= posX + l1; ++i2)
                        {
                            j2 = i2 - posX;

                            for (int k2 = posY - l1; k2 <= posY + l1; ++k2)
                            {
                                int l2 = k2 - posY;

                                if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || random.nextInt(2) != 0 && i3 != 0)
                                {
                                    Block block1 = world.getBlock(i2, k1, k2);

                                    if (block1.isAir(world, i2, k1, k2) || block1.isLeaves(world, i2, k1, k2))
                                    {
                                        this.setBlockAndNotifyAdequately(world, i2, k1, k2, VBlocks.SoulTreeLeaves, this.metaLeaves);
                                    }
                                }
                            }
                        }
                    }

                    for (k1 = 0; k1 < l; ++k1)
                    {
                        block = world.getBlock(posX, posZ + k1, posY);

                        if (block.isAir(world, posX, posZ + k1, posY) || block.isLeaves(world, posX, posZ + k1, posY))
                        {
                            this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY, VBlocks.SoulTree_Log, this.metaWood);

                            if (this.vinesGrow && k1 > 0)
                            {
                                if (random.nextInt(3) > 0 && world.isAirBlock(posX - 1, posZ + k1, posY))
                                {
                                    this.setBlockAndNotifyAdequately(world, posX - 1, posZ + k1, posY, Blocks.vine, ;
                                }

                                if (random.nextInt(3) > 0 && world.isAirBlock(posX + 1, posZ + k1, posY))
                                {
                                    this.setBlockAndNotifyAdequately(world, posX + 1, posZ + k1, posY, Blocks.vine, 2);
                                }

                                if (random.nextInt(3) > 0 && world.isAirBlock(posX, posZ + k1, posY - 1))
                                {
                                    this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY - 1, Blocks.vine, 1);
                                }

                                if (random.nextInt(3) > 0 && world.isAirBlock(posX, posZ + k1, posY + 1))
                                {
                                    this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY + 1, Blocks.vine, 4);
                                }
                            }
                        }
                    }

                    if (this.vinesGrow)
                    {
                        for (k1 = posZ - 3 + l; k1 <= posZ + l; ++k1)
                        {
                            i3 = k1 - (posZ + l);
                            l1 = 2 - i3 / 2;

                            for (i2 = posX - l1; i2 <= posX + l1; ++i2)
                            {
                                for (j2 = posY - l1; j2 <= posY + l1; ++j2)
                                {
                                    if (world.getBlock(i2, k1, j2).isLeaves(world, i2, k1, j2))
                                    {
                                        if (random.nextInt(4) == 0 && world.getBlock(i2 - 1, k1, j2).isAir(world, i2 - 1, k1, j2))
                                        {
                                            this.growVines(world, i2 - 1, k1, j2, ;
                                        }

                                        if (random.nextInt(4) == 0 && world.getBlock(i2 + 1, k1, j2).isAir(world, i2 + 1, k1, j2))
                                        {
                                            this.growVines(world, i2 + 1, k1, j2, 2);
                                        }

                                        if (random.nextInt(4) == 0 && world.getBlock(i2, k1, j2 - 1).isAir(world, i2, k1, j2 - 1))
                                        {
                                            this.growVines(world, i2, k1, j2 - 1, 1);
                                        }

                                        if (random.nextInt(4) == 0 && world.getBlock(i2, k1, j2 + 1).isAir(world, i2, k1, j2 + 1))
                                        {
                                            this.growVines(world, i2, k1, j2 + 1, 4);
                                        }
                                    }
                                }
                            }
                        }

                        if (random.nextInt(5) == 0 && l > 5)
                        {
                            for (k1 = 0; k1 < 2; ++k1)
                            {
                                for (i3 = 0; i3 < 4; ++i3)
                                {
                                    if (random.nextInt(4 - k1) == 0)
                                    {
                                        l1 = random.nextInt(3);
                                        this.setBlockAndNotifyAdequately(world, posX + Direction.offsetX[Direction.rotateOpposite[i3]], posZ + l - 5 + k1, posY + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3);
                                    }
                                }
                            }
                        }
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        else
        {
            return false;
        }
    }

    /**
     * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length
     */
    private void growVines(World world, int x, int starty, int z, int vine_length)
    {
        this.setBlockAndNotifyAdequately(world, x, starty, z, Blocks.vine, vine_length);
        int i1 = 4;

        while (true)
        {
            --starty;

            if (!world.getBlock(x, starty, z).isAir(world, x, starty, z) || i1 <= 0)
            {
                return;
            }

            this.setBlockAndNotifyAdequately(world, x, starty, z, Blocks.vine, vine_length);
            --i1;
        }
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	int x = random.nextInt(16);
	int z = random.nextInt(16);

	this.generate(world, random, x, world.getHeightValue(x, z), z);
}
}

 

Sarcasm doesn't always means what you think it means!

Link to comment
Share on other sites

The worst thing is that you are posting it here on the forums so all your formatting get's messed up (I seriously hope it doesn't look like that in your IDE...). Use pastebin or github.

 

OK so heres the github links, if more needed, ill upload

https://github.com/AOSPLolipop/world/blob/master/SoulTreeGen

https://github.com/AOSPLolipop/BlocksClass/blob/master/SoulSapling

 

Sarcasm doesn't always means what you think it means!

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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