Jump to content

Memory Issues on Ore Gen


wazupwiop

Recommended Posts

Hey Fellow Modders,

 

I am making a terraria mod, and to do this, I have to add in custom ore generation.  The ore gen that I am using seems to be causing this error: "Memory connection overburdened; after processing 2500 packets, we still have 325 to go!"

 

It did not do this until I added in ore generation into the game.  Is there a way to fix this?  I used this tutorial for my ore generation:

http://www.minecraftforum.net/topic/1485580-tutorialforge132forge-ore-generation-tutorial/

 

This is my first experience with Forge, and I am relatively new to Java, but I do understand a lot about programming (C# and web developer).  If anyone could give me a hint about where to look in my code, that would be greatly appreciated.

Link to comment
Share on other sites

seeing someone else's code isn't helpful in diagnosing a problem with your code

 

for all we know you misspelled your ore name or you are generating a null block or you are....9000000 different possible errors later.

 

we cant help unless you show us what your code is even if its exactly the same as the tutorial it could still have a slight error in it such as a typo

Link to comment
Share on other sites

Okay, here are all my classes that I am using for generation:

 

WorldGenJava

package terraria.generic;

 

import java.util.Random;

 

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.feature.WorldGenGlowStone1;

import net.minecraft.world.gen.feature.WorldGenMinable;

import cpw.mods.fml.common.IWorldGenerator;

 

public class WorldGen 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);

break;

case 0:

generateSurface(world, random, chunkX * 16, chunkZ * 16);

break;

case 1:

generateEnd(world, random, chunkX * 16, chunkZ * 16);

break;

}

 

}

 

private void generateSurface(World world, Random random, int chunkX, int chunkZ) {

for(int i=0; i<15; i++){

//i = size of vein

int xCoord = chunkX + random.nextInt(16);

int yCoord = random.nextInt(60); //Max Height

int zCoord = chunkZ + random.nextInt(16);

(new WorldGenMinable(terraria.generic.Generic.CopperOre.blockID, 12)).generate(world, random, xCoord, yCoord, zCoord);

}

for(int i=0; i<6; i++)

{

int xCoord = chunkX + random.nextInt(16);

int yCoord = random.nextInt(8 + 12); //Max Height

int zCoord = chunkZ + random.nextInt(16);

(new WorldGenMinable(terraria.generic.Generic.SilverOre.blockID, 8 )).generate(world, random, xCoord, yCoord, zCoord);

}

for(int i=0; i<3; i++)

{

int xCoord = chunkX + random.nextInt(16);

int yCoord = random.nextInt(8 + 12); //Max Height

int zCoord = chunkZ + random.nextInt(16);

(new WorldGenMinable(terraria.generic.Generic.Demonite.blockID, 8 )).generate(world, random, xCoord, yCoord, zCoord);

}

}

 

private void generateNether(World world, Random random, int chunkX, int chunkZ) {

 

for(int i=0; i<15; i++)

{

//i = number of veins per chunk

int xCoord = chunkX + random.nextInt(16);

int yCoord = random.nextInt(30); //Max Height

int zCoord = chunkZ + random.nextInt(16);

(new WorldGenNether(terraria.generic.Generic.Hellstone.blockID, 8 )).generate(world, random, xCoord, yCoord, zCoord);

}

 

}

 

private void generateEnd(World world, Random random, int chunkX, int chunkZ) {

 

}

 

 

}

 

 

WorldGenNether

 

package terraria.generic;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

 

public class WorldGenNether {

    /** The block ID of the ore to be placed using this generator. */

    private int minableBlockId;

    private int minableBlockMeta = 0;

 

    /** The number of blocks to generate. */

    private int numberOfBlocks;

 

    public WorldGenNether(int par1, int par2)

    {

        this.minableBlockId = par1;

        this.numberOfBlocks = par2;

    }

 

    public WorldGenNether(int id, int meta, int number)

    {

        this(id, number);

        minableBlockMeta = meta;

    }

 

    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)

    {

        float var6 = par2Random.nextFloat() * (float)Math.PI;

        double var7 = (double)((float)(par3 + 8) + MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);

        double var9 = (double)((float)(par3 + 8) - MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);

        double var11 = (double)((float)(par5 + 8) + MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);

        double var13 = (double)((float)(par5 + 8) - MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);

        double var15 = (double)(par4 + par2Random.nextInt(3) - 2);

        double var17 = (double)(par4 + par2Random.nextInt(3) - 2);

 

        for (int var19 = 0; var19 <= this.numberOfBlocks; ++var19)

        {

            double var20 = var7 + (var9 - var7) * (double)var19 / (double)this.numberOfBlocks;

            double var22 = var15 + (var17 - var15) * (double)var19 / (double)this.numberOfBlocks;

            double var24 = var11 + (var13 - var11) * (double)var19 / (double)this.numberOfBlocks;

            double var26 = par2Random.nextDouble() * (double)this.numberOfBlocks / 16.0D;

            double var28 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;

            double var30 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;

            int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);

            int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);

            int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);

            int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);

            int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);

            int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);

 

            for (int var38 = var32; var38 <= var35; ++var38)

            {

                double var39 = ((double)var38 + 0.5D - var20) / (var28 / 2.0D);

 

                if (var39 * var39 < 1.0D)

                {

                    for (int var41 = var33; var41 <= var36; ++var41)

                    {

                        double var42 = ((double)var41 + 0.5D - var22) / (var30 / 2.0D);

 

                        if (var39 * var39 + var42 * var42 < 1.0D)

                        {

                            for (int var44 = var34; var44 <= var37; ++var44)

                            {

                                double var45 = ((double)var44 + 0.5D - var24) / (var28 / 2.0D);

 

                                Block block = Block.blocksList[par1World.getBlockId(var38, var41, var44)];

                                if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (block != null && par1World.getBlockId(var38, var41, var44) == Block.netherrack.blockID))

                                {

                                    par1World.setBlockAndMetadata(var38, var41, var44, this.minableBlockId, minableBlockMeta);

                                }

                            }

                        }

                    }

                }

            }

        }

 

        return true;

    }

}

 

 

Generic

 

package terraria.generic;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

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

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = "TerrariaMod", name = "TerrariaMod", version = "0.0.1")

@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class Generic {

 

public final static Block CopperOre = new CopperOreBlock(500,0,Material.rock)

.setBlockName("Copper Ore").setCreativeTab(CreativeTabs.tabBlock);

public final static Block SilverOre =  new SilverOreBlock(501,1,Material.rock)

.setBlockName("Silver Ore").setCreativeTab(CreativeTabs.tabBlock);

public final static Block Demonite = new DemoniteBlock(502,2,Material.rock)

.setBlockName("Demonite").setCreativeTab(CreativeTabs.tabBlock).setLightValue(15.0f);

public final static Block Meteorite = new MeteoriteBlock(503,3,Material.rock)

.setBlockName("Meteorite").setCreativeTab(CreativeTabs.tabBlock).setLightValue(12.0f);

public final static Block Hellstone = new HellStoneBlock(504,4,Material.rock)

.setBlockName("Hell Stone").setCreativeTab(CreativeTabs.tabBlock).setLightValue(10.0f);

 

@Instance("Generic")

public static Generic instance;

 

@SidedProxy(clientSide = "terraria.generic.client.ClientProxy", serverSide = "terraria.generic.CommonProxy")

public static CommonProxy proxy;

 

@PreInit

public void preInit(FMLPreInitializationEvent event)

{

 

 

 

}

 

@Init

public void load(FMLInitializationEvent event)

{

GameRegistry.registerWorldGenerator(new WorldGen());

 

GameRegistry.registerBlock(CopperOre, "Copper Ore");

LanguageRegistry.addName(CopperOre, "Copper Ore");

 

GameRegistry.registerBlock(SilverOre, "Silver Ore");

LanguageRegistry.addName(SilverOre, "Silver Ore");

 

GameRegistry.registerBlock(Demonite, "Demonite");

LanguageRegistry.addName(Demonite, "Demonite");

 

GameRegistry.registerBlock(Meteorite, "Meteorite");

LanguageRegistry.addName(Meteorite, "Meteorite");

 

GameRegistry.registerBlock(Hellstone, "Hell Stone");

LanguageRegistry.addName(Hellstone, "Hell Stone");

 

proxy.registerRenders();

}

 

@PostInit

public void postInit(FMLPostInitializationEvent event)

{

 

 

 

}

 

}

 

 

That is my code.  If you guys could look at it and give me a clue as to where to look, that would be great.

Link to comment
Share on other sites

I have also noticed that there is a little bit of lag in the overworld as well.  There are several generating chunks, and this is in the console:

 

2013-03-11 13:58:23 [iNFO] [sTDOUT] Fetching addPacket for removed entity

2013-03-11 13:58:31 [iNFO] [sTDOUT] Memory connection overburdened; after processing 2500 packets, we still have 359 to go!

 

I did some testing and took I my generation code, and it helped lag a little bit, but there was still a lot of render lag.

 

It seems like if I just refresh the graphics settings, it fixes the chunk glitches.

 

Any clue what would cause this?

 

 

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.