Jump to content

Recommended Posts

Posted

Im having the weidest problem generated 2 different types of trees in my dimension (metadata).  I crash every time i make a new world for some reason. Now for some reason when i only generate 1 of the trees in works perfectly, but both, gives an error.

 

TreeGen

 

 

package com.manslaughter777.crystaldimension.world.gen;

import java.util.Random;

import com.manslaughter777.crystaldimension.Main;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenCrystalTrees;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenIlluminateTrees;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenOres;

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.feature.WorldGenTrees;
import cpw.mods.fml.common.IWorldGenerator;

public class TreeGenerator implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	switch (world.provider.dimensionId) {
	case -1:
		generateNether(world, random, chunkX * 16, chunkZ * 16);
	case 0:
		generateSurface(world, random, chunkX * 16, chunkZ * 16);
	case 1:
		generateEnd(world, random, chunkX * 16, chunkZ * 16);
	case 7:
		generateCrystal(world, random, chunkX * 16, chunkZ * 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) {

}

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

	BiomeGenBase biomeGenBase = world.getWorldChunkManager().getBiomeGenAt(x + 16, z + 16);

	if (biomeGenBase == Main.crystalBiome)

		this.addTreeSpawn(world, random, Main.log, Main.leaves, 0, 0, false, 5, 5, false, x, z, 16, 100, 16, 50);
	    this.addTreeSpawn(world, random, Main.log, Main.leaves, 1, 1, false, 6, 8, false, x, z, 16, 120, 16, 30);

	/*
	for (int i = 0; i < 50; i++) {
		int x1 = x + random.nextInt(16);
		int y1 = random.nextInt(100); //How High?
		int z1 = z + random.nextInt(16); 

		new WorldGenCrystalTrees(Main.log, Main.leaves, 0, 0, false, 5, 5, false).generate(world, random, x1, y1, z1);
	} */
}

private void addTreeSpawn(World world, Random random, Block log, Block leaves, int metaLog, int metaLeaves, boolean doBlockNotify, int minTreeHeight, int randomTreeHeight, boolean vinesGrow, int xPos, int zPos, int maxX, int maxY, int maxZ, int chanceToSpawn) {
	for (int i = 0; i < chanceToSpawn; i++) {
		int posX = xPos + random.nextInt(maxX); //16
		int posY = random.nextInt(maxY);
		int posZ = zPos + random.nextInt(maxZ); //16
		(new WorldGenCrystalTrees(log, leaves, metaLog, metaLeaves, doBlockNotify, minTreeHeight, randomTreeHeight, vinesGrow)).generate(world, random, posX, posY, posZ);
	}
}
}

 

 

 

WorldGenCrystalTrees

 

 

package com.manslaughter777.crystaldimension.world.gen.feature;

import java.util.Random;

import com.manslaughter777.crystaldimension.Main;

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.world.World;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.util.ForgeDirection;

public class WorldGenCrystalTrees extends WorldGenAbstractTree
{
    private final int minTreeHeight;
    private final int randomTreeHeight;

    private final boolean vinesGrow;
    
    private final Block wood;
    private final Block leaves;

    private final int metaWood;
    private final int metaLeaves;

    public WorldGenCrystalTrees(Block wood, Block leaves, int metaWood, int metaLeaves)
    {
        this(wood, leaves, metaWood, metaLeaves, false, 4, 3, false);
    }

    public WorldGenCrystalTrees(Block wood, Block leaves, int metaWood, int metaLeaves, boolean doBlockNotify, int minTreeHeight, int randomTreeHeight, boolean vinesGrow)
    {
        super(doBlockNotify);
        
        this.wood = wood;
        this.leaves = leaves;

        this.minTreeHeight = minTreeHeight;
        this.randomTreeHeight = randomTreeHeight;
        
        this.metaWood = metaWood;
        this.metaLeaves = metaLeaves;
        
        this.vinesGrow = vinesGrow;
    }

    public boolean generate(World world, Random random, int x, int y, int z)
    {
        int l = random.nextInt(3) + this.minTreeHeight;
        boolean flag = true;

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

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

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

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

                for (int j1 = x - b0; j1 <= x + b0 && flag; ++j1)
                {
                    for (k1 = z - b0; k1 <= z + b0 && flag; ++k1)
                    {
                        if (i1 >= 0 && i1 < 256)
                        {
                            block = world.getBlock(j1, i1, k1); //THIS IS WHERE THE ERROR CODE SAYS THERE IS SOMETHING WRONG

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

            if (!flag)
            {
                return false;
            }
            else
            {
                Block block2 = world.getBlock(x, y - 1, z);

                boolean isSoil = block2.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, (BlockSapling)Main.sapling);
                if (isSoil && y < 256 - l - 1)
                {
                    block2.onPlantGrow(world, x, y - 1, z, x, y, z);
                    b0 = 3;
                    byte b1 = 0;
                    int l1;
                    int i2;
                    int j2;
                    int i3;

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

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

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

                                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, Main.leaves, this.metaLeaves);
                                    }
                                }
                            }
                        }
                    }

                    for (k1 = 0; k1 < l; ++k1)
                    {
                        block = world.getBlock(x, y + k1, z);

                        if (block.isAir(world, x, y + k1, z) || block.isLeaves(world, x, y + k1, z))
                        {
                            this.setBlockAndNotifyAdequately(world, x, y + k1, z, Main.log, this.metaWood);

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

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

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

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

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

                            for (i2 = x - l1; i2 <= x + l1; ++i2)
                            {
                                for (j2 = z - l1; j2 <= z + 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, x + Direction.offsetX[Direction.rotateOpposite[i3]], y + l - 5 + k1, z + 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;
        }
    }
}

 

 

 

ERROR CODE (Seems to be line 81 of WorldGenCrystalTrees

--- Minecraft Crash Report ----

// Why did you do that?

 

Time: 9/11/14 6:53 PM

Description: Exception getting block type in world

 

java.lang.StackOverflowError: Exception getting block type in world

at java.security.AccessController.doPrivileged(Native Method)

at java.lang.ClassLoader.checkPackageAccess(Unknown Source)

at net.minecraft.world.World.getBlock(World.java:389)

at com.manslaughter777.crystaldimension.world.gen.feature.WorldGenCrystalTrees.generate(WorldGenCrystalTrees.java:81)

at com.manslaughter777.crystaldimension.world.gen.TreeGenerator.addTreeSpawn(TreeGenerator.java:70)

at com.manslaughter777.crystaldimension.world.gen.TreeGenerator.generateCrystal(TreeGenerator.java:52)

at com.manslaughter777.crystaldimension.world.gen.TreeGenerator.generate(TreeGenerator.java:29)

at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:106)

at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:314)

at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1134)

at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:208)

at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:149)

at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:119)

at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:221)

at net.minecraft.world.World.getChunkFromChunkCoords(World.java:479)

at net.minecraft.world.World.getBlock(World.java:384)

 

btw it repeats these lines about 100 times

 

Posted

Haven't looked into it, but from what it looks like, you're trying to get a block that hasn't generated yet. Minecraft then goes to generate the block, and in doing so, goes to call your class to generate. This results in an 'infinite loop'.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

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

    • When i try to join my friends server with mods it just says failed to log in: the authentication servers are currently not reachable. I've been having this issue for a while now and no method I've tried to fix it works. I've seen a lot of people fixing it by modifying the host.txt file and removing anything related to Mojang but when I open mine there's nothing related to Mojang there. I also tried flushing DNS cache, and changing my IPV6 to 8888, but nothing works.  It only happens when the mods are on too. When I join my friends server on vanilla it works, but not with mods. I can join multiplayer servers like hypixel. I can also play singleplayer with the mods and it works perfectly. The mods are up to date with the versions and the servers, but it just never gets past "Logging in" when i try to join their server. I use Curseforge to launch my mods, so that could maybe have something to do with it because it's technically a third party server, but it hasn't given me any trouble besides this one issue. I do not have MCLeaks and don't know what that is, but how can i search for it anyway to make sure? I have uninstalled minecraft launcher, updated my microsoft and my videocard drivers, reset my wifi and checked my parental settings (I am the owner on my computer), flushed my dns, modifying my host file to delete mojang but there's nothing with mojang on there, disabled my firewall, changed my IPV6 domain to 8888, restarted my router, and none of that works. I have researched this issue thoroughly and tried every solution I have came across and nothing is fixing the problem so i have come here as a last ditch effort. All i want to do is play mods with my friend. My friend has no issues with the server or mods and he has it through curseforge too. I would like further assistance in any way you think could help or even refer me to another forum that could help with this. Genuinely I cannot figure out why it doesn't work I would love any sort of further help.  
    • been getting this error and followed the old tick loop post however i cant figure out what file to delete Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.LevelAccessor.m_7654_()" because the return value of "net.minecraftforge.event.level.LevelEvent$Unload.getLevel()" is null     at com.lion.graveyard.platform.forge.HordeSpawner.onWorldUnload(HordeSpawner.java:41) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading}     at com.lion.graveyard.platform.forge.__HordeSpawner_onWorldUnload_Unload.invoke(.dynamic) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.mehvahdjukaar.moonlight.api.platform.forge.PlatHelperImpl.invokeLevelUnload(PlatHelperImpl.java:279) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.moonlight.api.platform.PlatHelper.invokeLevelUnload(PlatHelper.java) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.moonlight.core.misc.FakeLevelManager.invalidate(FakeLevelManager.java:29) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.utils.fake_level.BlockTestLevel.invalidate(BlockTestLevel.java:34) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.block.faucet.FaucetBehaviorsManager.onReloadWithLevel(FaucetBehaviorsManager.java:129) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.ServerEvents.onServerStart(ServerEvents.java:160) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.ServerEventsForge.onServerStart(ServerEventsForge.java:119) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.__ServerEventsForge_onServerStart_ServerStartedEvent.invoke(.dynamic) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(ServerLifecycleHooks.java:115) ~[forge-1.20.1-47.3.29-universal.jar%23212!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:638) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) ~[?:?] {}  
    • Online forums in general seem to be declining in popularity imo. There’s still value here for certain types of content, such as written tutorials and blog posts which would otherwise get lost in the chat history fairly quickly on Discord. Also for those that prefer the forums format ofc. But for faster support related topics, I agree that the Discord is probably your best bet at the moment. The speed of responses is also down to the ratio of volunteers - the player support forum still seems pretty active, but the coding ones much less so. Once you’re feeling more confident in your modding skills, be the change you want to see
    • try the same link, i swapped logs after sitting in the world for a few minutes then leaving. Lmk if it keeps happening then ill just send a video of the live log on modrinth
    • It is an issue with chimes
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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