Jump to content

[1.7.10] [Resolved] Help with creating custom tree generation.


Awesome_Spider

Recommended Posts

I've hit yet ANOTHER snag in my mod. I need to know how generate a simple tree. I have attempted this a few times but to know avail. Minecraft has always crashed, stopped generating chucks, or corrupted worlds all the time I've tried. So I came here once again :). Thanks in advance.

 

Edit: Well it still isn't working. It crashes now. Here is the mod log.

 

[17:20:59] [main/INFO] [GradleStart]: No arguments specified, assuming client.
[17:21:00] [main/INFO] [GradleStart]: Extra: []
[17:21:00] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/Wyatt/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker]
[17:21:00] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[17:21:00] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[17:21:00] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker
[17:21:01] [main/INFO] [FML]: Forge Mod Loader version 7.10.85.1232 for Minecraft 1.7.10 loading
[17:21:01] [main/INFO] [FML]: Java is Java HotSpot(TM) Client VM, version 1.8.0_11, running on Windows 8.1:x86:6.3, installed at C:\Users\Wyatt\Documents\eclipse\jre
[17:21:01] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[17:21:01] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:01] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker
[17:21:01] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:01] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[17:21:01] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[17:21:05] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[17:21:13] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[17:21:13] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[17:21:13] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker
[17:21:15] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker
[17:21:15] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker
[17:21:15] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[17:21:20] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11]
at GradleStart.bounce(GradleStart.java:107) [start/:?]
at GradleStart.startClient(GradleStart.java:100) [start/:?]
at GradleStart.main(GradleStart.java:55) [start/:?]
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source) ~[?:1.8.0_11]
at java.lang.Runtime.loadLibrary0(Unknown Source) ~[?:1.8.0_11]
at java.lang.System.loadLibrary(Unknown Source) ~[?:1.8.0_11]
at org.lwjgl.Sys$1.run(Sys.java:73) ~[lwjgl-2.9.1.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_11]
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) ~[lwjgl-2.9.1.jar:?]
at org.lwjgl.Sys.loadLibrary(Sys.java:95) ~[lwjgl-2.9.1.jar:?]
at org.lwjgl.Sys.<clinit>(Sys.java:112) ~[lwjgl-2.9.1.jar:?]
at net.minecraft.client.Minecraft.getSystemTime(Minecraft.java:2807) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:79) ~[Main.class:?]
... 13 more
Exception in thread "main" [17:21:20] [main/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.ArrayIndexOutOfBoundsException: 0
[17:21:20] [main/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: 	at GradleStart.main(GradleStart.java:59)
Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

Here is the generation code:

 

package com.awsp8.wizardry.Gen;

import java.util.Random;

import com.awsp8.wizardry.Wizardry;

import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.util.ForgeDirection;

public class MaztrixTreeGen 
			extends WorldGenAbstractTree implements IWorldGenerator{

/** The minimum height of a generated tree. */
    private final int minTreeHeight;
    /** True if this tree should grow Vines. */
    private final boolean vinesGrow;
    /** The metadata value of the wood to use in tree generation. */
    private final int metaWood;
    /** The metadata value of the leaves to use in tree generation. */
    private final int metaLeaves;
    private static final String __OBFID = "CL_00000438";

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

    public MaztrixTreeGen(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)Blocks.sapling);
                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, Wizardry.maztrixLeaf, 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_, Wizardry.maztrixLog, 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);
}
}

 

Here is what I used to register the terrain generator:

 

GameRegistry.registerWorldGenerator(new MaztrixTreeGen(true, 4, 0, 0, false), 1);

 

Any further help would be great. :)

Link to comment
Share on other sites

Code is always more informative than a crash report alone, even if you remember what the exception was.

 

You said you're trying to generate a "simple" tree, but I assume you're trying to accomplish something beyond what the vanilla tree generation methods provide, as in, a different shape, or different blocks than vanilla leaves and logs?

 

Even if not, it might be worth a while to poke around in the vanilla methods, all in net.minecraft.world.gen.feature, to see how they're doing things. Spoiler: it's just huge mess of if statements and loops.

Link to comment
Share on other sites

Code is always more informative than a crash report alone, even if you remember what the exception was.

 

You said you're trying to generate a "simple" tree, but I assume you're trying to accomplish something beyond what the vanilla tree generation methods provide, as in, a different shape, or different blocks than vanilla leaves and logs?

 

Even if not, it might be worth a while to poke around in the vanilla methods, all in net.minecraft.world.gen.feature, to see how they're doing things. Spoiler: it's just huge mess of if statements and loops.

 

I'm trying to generate a tree with a custom leaf type and log type (already implemented). Oh, also I will look at the tree generation classes again, but which class is that generates oak trees? I can't find it :) There is just WorldGenAbstractTree and WorldGenBigTree that I can find.

 

Edit: Oh, and on doing more digging in net.minecraft.world.gen.feature, I also found WorldGenCanopyTree. That might beit, but I just need confirmation.

Link to comment
Share on other sites

The "minor" trees are handled by the WorldGenTrees class. This does the 1x1 trunk oak, birch, and jungle trees.

 

Did you mean you already had the custom leaf block and log block implemented, or that you had the generation method itself implemented?

 

I have the leaves and log implemented. Sorry for the confusion.

Link to comment
Share on other sites

At first you have to make a class that implements IWorldGenerator and register it. Let's call it Generate.java:

 

Generate.java

 

package your.package;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class Generate implements IWorldGenerator
{
    public void generate(Random random, int x, int z, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        switch (world.provider.dimensionId)
        {
        case -1:
            generateNether(world, random, x * 16, z * 16);
        case 0:
            generateSurface(world, random, x * 16, z * 16);
        case 1:
            generateEnd(world, random, x * 16, z * 16);
        }
    }

    private void generateEnd(World world, Random random, int x, int z)
    {

    }

    private void generateSurface(World world, Random random, int x, int z)
    {

    }

    private void generateNether(World world, Random random, int x, int z)
    {
    	
    }
}

 

 

 

Then create a var to register it:

Main mod class:

Generate generate = new Generate();

 

And register it in init():

GameRegistry.registerWorldGenerator(generate, 0);

 

And in Generate.java you can generate your trees

Write this in generateSurface method:

 

 

for(int i = 0; i < 15; i++) // 15 is rarity
{
    int randPosX=x + random.nextInt(16);
    int randPosY=random.nextInt(250); //Max Y coordinate
    int randPosZ=z + random.nextInt(16);
    (new MaztrixTreeGen(false)).generate(world, random, randPosX, randPosY, randPosZ);
}

 

 

 

I hope it helps.

Link to comment
Share on other sites

Is it just me or would your code for the tree Y position have some nasty sideeffects?

int randPosY=random.nextInt(250); //Max Y coordinate

 

afaik, random.nextInt would give a random height from 0 to 250 in this case, and the tree should be on the ground level, not randomly flying or appearing underground which would be the case here.

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

Is it just me or would your code for the tree Y position have some nasty sideeffects?

int randPosY=random.nextInt(250); //Max Y coordinate

 

afaik, random.nextInt would give a random height from 0 to 250 in this case, and the tree should be on the ground level, not randomly flying or appearing underground which would be the case here.

 

so what you're saying is this:

int randPosY= world.getHeightValue(randPosX, randPosZ);

 

instead of this:

 

int randPosY=random.nextInt(250); //Max Y coordinate

 

Edit: It still has this crash.

Link to comment
Share on other sites

so what you're saying is this:

int randPosY= world.getHeightValue(randPosX, randPosZ);

 

instead of this:

 

int randPosY=random.nextInt(250); //Max Y coordinate

 

Edit: It still has this crash.

 

Well, yea. That's what I'd do, however I do not have even the slightest knowledge how the world generation works in Minecraft but that's how I'd do it.

 

Another thing to note is that you might want to check the max-height there. Afaik the terrain in minecraft can sometimes reach about 240 blocks up (technically I think it may go all the way to 256 but it's not likely) but that means that if your tree is 11 blocks high and you create it at a height of 245 your tree will try to grow outside of the world. This is just a side-note and is doubtfully the cause of your crash but it's noteworthy.

 

Also, just to clarify, does your minecraft run without the generation code?

Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

This seems rather strange to me, though it could be a sideeffect of some other faulty code.

 

 

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

so what you're saying is this:

int randPosY= world.getHeightValue(randPosX, randPosZ);

 

instead of this:

 

int randPosY=random.nextInt(250); //Max Y coordinate

 

Edit: It still has this crash.

 

Well, yea. That's what I'd do, however I do not have even the slightest knowledge how the world generation works in Minecraft but that's how I'd do it.

 

Another thing to note is that you might want to check the max-height there. Afaik the terrain in minecraft can sometimes reach about 240 blocks up (technically I think it may go all the way to 256 but it's not likely) but that means that if your tree is 11 blocks high and you create it at a height of 245 your tree will try to grow outside of the world. This is just a side-note and is doubtfully the cause of your crash but it's noteworthy.

 

That's true.

 

Also, just to clarify, does your minecraft run without the generation code?

Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

This seems rather strange to me, though it could be a sideeffect of some other faulty code.

 

Well, it did run, but every time I add any form of generation code it doesn't run. However, now it's doing something funny where when I remove all the generation code it still doesn't run. I saw on Minecraft Forum that someone was having this same problem with some other code and it is caused be lack of LWJGL for some reason. I'm running

 gradlew.bat setupDecompWorkspace --refresh-dependencies 

again to see if that solves the problem.

 

Edit: Well, that fixed the crash, I added the generation code back in and it launches now. Yay! The bad news: World Corruption (Aqain!). I was flying through my test world looking for my custom tree, then the chucks stoped loading and the loaded chunks were unloading. I said to myself, "Uh oh." I clicked escape and exited out of the world. The forge took forever to shutdown the world, and once it did, it then took forever to quit the game. I have no idea what's going on.

Link to comment
Share on other sites

	@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);
}

 

Umm, this is placing every single tree at chunk 0,0

 

It should be

 

int x = chunkX*16 + random.nextInt(16);
int z = chunkZ*16 + random.nextInt(16);

Link to comment
Share on other sites

What does your world generator look like, Awesome_Spider? Not the tree bit, the one that implements IWorldGenerator.

 

It looks like this:

 

package com.awsp8.wizardry.Gen;

import java.util.Random;

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

public class Generate implements IWorldGenerator
{
    public void generate(Random random, int x, int z, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){
        switch (world.provider.dimensionId){
        case -1:
            generateNether(world, random, x * 16, z * 16);
            break;
        case 0:
            generateSurface(world, random, x * 16, z * 16);
            break;
        case 1:
            generateEnd(world, random, x * 16, z * 16);
            break;
        }
    }

    private void generateEnd(World world, Random random, int x, int z){
        
    }

    private void generateSurface(World world, Random random, int x, int z){
        for(int i = 0; i < 15; i++){ // 15 is rarity
            int randPosX= x + random.nextInt(16);
            int randPosZ= z + random.nextInt(16);
            int randPosY= world.getHeightValue(randPosX, randPosZ);
            (new MaztrixTreeGen(false, 4, 0, 0, false)).generate(world, random, randPosX, randPosY, randPosZ);
        }
    }

    private void generateNether(World world, Random random, int x, int z){
        
    }
}

Link to comment
Share on other sites

I'm going to be blunt here, Awesome_Spider, and I hope you don't find this discouraging. I see a lot of copy-paste going on with little thought given to what the methods you're using actually do or how they function.

 

For instance, I see you directly copy-pasted Kuu's world generation suggestion, which is itself lifted directly from the Forge Wiki's tutorial section. You even preserved the number of iterations in the for-loop and the comment label, erroneously referring to the value 15 as "rarity". If we look at your code however, what it does is call the tree generator 15 times per generateSurface call, which itself is called on every chunk. Is this actually what you want?

 

My advice to you at this point is to set aside a bit of time to go through the code you are using and try to determine how all the pieces fit together. If you must copy-paste, you should at least understand the bits you are using, otherwise, how will you understand what's going on when things don't work? Moreover, how will you know whether the suggestions you are taking are actually what you want?

 

I am certain that if you sit down and sift through your current code and figure out how it is working, the source of the issue you are having will become apparent. You got this far, so I know you can do it! Go forth and conquer!

Link to comment
Share on other sites

Is it just me or would your code for the tree Y position have some nasty sideeffects?

int randPosY=random.nextInt(250); //Max Y coordinate

 

afaik, random.nextInt would give a random height from 0 to 250 in this case, and the tree should be on the ground level, not randomly flying or appearing underground which would be the case here.

 

It won't generate in air because MaztrixTreeGen should check if the block is grass, but i think i've got long world generating because of this, thanks, i'll use

int randPosY= world.getHeightValue(randPosX, randPosZ);

  :D

Link to comment
Share on other sites

Awesome_Spider, I copied all the code from my working mod, so I can't understand what's the problem. Do you use big or small oak tree generation?

 

Hmm, try to remove IWorldGenerator implementation and remove this from MaztrixTreeGen:

@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);
}

Link to comment
Share on other sites

I'm going to be blunt here, Awesome_Spider, and I hope you don't find this discouraging. I see a lot of copy-paste going on with little thought given to what the methods you're using actually do or how they function.

 

For instance, I see you directly copy-pasted Kuu's world generation suggestion, which is itself lifted directly from the Forge Wiki's tutorial section. You even preserved the number of iterations in the for-loop and the comment label, erroneously referring to the value 15 as "rarity". If we look at your code however, what it does is call the tree generator 15 times per generateSurface call, which itself is called on every chunk. Is this actually what you want?

 

My advice to you at this point is to set aside a bit of time to go through the code you are using and try to determine how all the pieces fit together. If you must copy-paste, you should at least understand the bits you are using, otherwise, how will you understand what's going on when things don't work? Moreover, how will you know whether the suggestions you are taking are actually what you want?

 

I am certain that if you sit down and sift through your current code and figure out how it is working, the source of the issue you are having will become apparent. You got this far, so I know you can do it! Go forth and conquer!

 

Thanks for the suggestion. I will go through the code. Btw, I don't get discouraged easily.

 

Edit: Ok, I've gone through the generation code, figured out how it works, and figured out what the problem might be. My custom leaf block extends Block instead of BlockLeaves. A lot of the if statements check for if there is leaves in a given location. But my leaf block, MaztrixLeaf wouldn't count as a leaf, causing errors. So if I change it to BlockLeaves it should work. :)

 

Edit Again: It Worked! :D The color of the leaves is a little off but I can fix that.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
    • DAFTAR & LOGIN BIGO4D Bigo4D adalah situs togel online yang menjadi pilihan banyak pemain di Indonesia. Dengan berbagai keunggulan yang dimilikinya, Bigo4D mampu menjadi situs togel terbesar di pasaran saat ini. Dalam artikel ini, kami akan membahas secara lengkap tentang Bigo4d dan alasan-alasannya menjadi situs togel favorit banyak pemain.
  • Topics

×
×
  • Create New...

Important Information

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