Jump to content

[1.7.10] Minable Generator Crashes the game.


BlazeGameR

Recommended Posts

Hi! I'm creating mod, I think first ores will be added. The ores themself work fine, but when I enable generator Minecraft crashes on world load. Log says:

 

java.lang.NullPointerException: Exception in server tick loop

at net.minecraft.world.chunk.storage.ExtendedBlockStorage.func_150818_a(ExtendedBlockStorage.java:86)

at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:653)

at net.minecraft.world.World.setBlock(World.java:519)

at net.minecraft.world.gen.feature.WorldGenMinable.generate(WorldGenMinable.java:79)

at cf.blazegamer.industrialflow.IFGenerator.generateOverworld(IFGenerator.java:82)

at cf.blazegamer.industrialflow.IFGenerator.generate(IFGenerator.java:26)

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

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

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

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.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:305)

at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:79)

at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

The IFGenerator code (shortened):

 

public IFGenerator(Block block, boolean inNether, boolean inWorld, boolean inEnd, int heightMin, int heightMax, int BlocksPerVein, int VeinsPerChunk) {

this.block = block;

this.nether = inNether;

this.end = inEnd;

this.overworld = inWorld;

this.minY = heightMin;

this.maxY = heightMax;

this.blocksPerVein = BlocksPerVein;

this.veinsPerChunk = VeinsPerChunk;

}

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch(world.provider.dimensionId) {

case -1: if (this.nether == true) generateNether(world, random, chunkX * 16, chunkZ * 16);

case 0: if (this.overworld == true) generateOverworld(world, random, chunkX * 16, chunkZ * 16);

case 1: if (this.end == true) generateEnd(world, random, chunkX * 16, chunkZ * 16);

}

}

private void generateOverworld(World world, Random random, int X, int Z) {

        for (int i = 0; i < this.veinsPerChunk; i++) {

        int x = X + random.nextInt(16);

int Y = this.minY + random.nextInt(this.maxY - this.minY);

        int z = Z + random.nextInt(16);

(new WorldGenMinable(this.block, this.blocksPerVein)).generate(world, random, X, Y, Z);

        }

}

}

 

Please tell me what do I do incorrect!

And sorry for bad English, it isn't my native language

Link to comment
Share on other sites

Thank you for describing my problem! I fixed that crash but now...

World is filled with Tungsten. Nearly 30 veins of T. per chunk float in air. And yes, I pass correct values to constructor.

The screenshot of that glitch: Jnug6U9.png

Also, seems no IF ores, no caves and no lava generate below air level...

Link to comment
Share on other sites

Updated only generate function because don't know what causes gen glitches. The function:

 

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch(world.provider.dimensionId) {

case -1: if (this.nether == true) generateNether(world, random, chunkX * 16, chunkZ * 16);break;

case 0: if (this.overworld == true) generateOverworld(world, random, chunkX * 16, chunkZ * 16);break;

case 1: if (this.end == true) generateEnd(world, random, chunkX * 16, chunkZ * 16);break;

}

}

 

Link to comment
Share on other sites

The IFGenerator:

 

(package, imports)

 

public class IFGenerator implements IWorldGenerator {

public static Block block;

public static boolean nether;

public static boolean end;

public static boolean overworld;

public static int minY;

public static int maxY;

public static int blocksPerVein;

public static int veinsPerChunk;

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch(world.provider.dimensionId) {

case -1: if (this.nether == true) generateNether(world, random, chunkX * 16, chunkZ * 16);break;

case 0: if (this.overworld == true) generateOverworld(world, random, chunkX * 16, chunkZ * 16);break;

case 1: if (this.end == true) generateEnd(world, random, chunkX * 16, chunkZ * 16);break;

}

}

 

public IFGenerator(Block block, boolean inNether, boolean inWorld, boolean inEnd, int heightMin, int heightMax, int BlocksPerVein, int VeinsPerChunk) {

this.block = block;

this.nether = inNether;

this.end = inEnd;

this.overworld = inWorld;

this.minY = heightMin;

this.maxY = heightMax;

this.blocksPerVein = BlocksPerVein;

this.veinsPerChunk = VeinsPerChunk;

}

 

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

for (int i = 0; i < this.veinsPerChunk; i++) {

int X = x + random.nextInt(16);

int Y = this.minY + random.nextInt(this.maxY - this.minY);

int Z = z + random.nextInt(16);

(new WorldGenMinable(this.block, 1, this.blocksPerVein, Blocks.end_stone)).generate(world, random, X, Y, Z);

}

}

 

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

for (int i = 0; i < this.veinsPerChunk; i++) {

int X = x + random.nextInt(16);

int Y = this.minY + random.nextInt(this.maxY - this.minY);

int Z = z + random.nextInt(16);

(new WorldGenMinable(this.block, 1, this.blocksPerVein, Blocks.netherrack)).generate(world, random, X, Y, Z);

}

}

 

private void generateOverworld(World world, Random random, int X, int Z) {

assert maxY > minY : "Max Y is lower than Min Y!";

        assert minY > 0 : "Min Y is too low!";

        assert maxY < 256 && maxY > 0 : "Incorrect Max Y!";

        for (int i = 0; i < this.veinsPerChunk; i++) {

        int x = X + random.nextInt(16);

int Y = this.minY + random.nextInt(this.maxY - this.minY);

        int z = Z + random.nextInt(16);

(new WorldGenMinable(this.block, this.blocksPerVein, Blocks.stone)).generate(world, random, X, Y, Z);

        }

}

}

 

 

The Main class (i shortened it, deleted not related to generation items):

 

(imports)

 

@Mod(modid = "industrialflow", version = "0.1", name = "IndustrialFlow")

public class IF_Base {

public static Block oreCopper, oreTin, oreLead, oreIron, oreZinc, oreCobalt, oreNickel, oreTopaz, oreDiamond, oreCadmium;

public static Block oreSilver, oreGold, orePlatinum, oreGermanium, oreGallium, oreTungsten, oreUranium, oreTitanium;

public static Block oreRenium, orePalladium, oreRuthenium, oreRadium, oreThorium, oreFlint;

(ingots and tools)

 

public static IFGenerator copperGen, tinGen, zincGen, leadGen, uraniumGen;

public static IFGenerator titaniumGen, radiumGen, thoriumGen, cobaltGen, nickelGen;

public static IFGenerator tungstenGen, topazGen, galliumGen, germaniumGen, platinumGen;

public static IFGenerator silverGen, palladiumGen, rutheniumGen, cadmiumGen, reniumGen;

public static AirGenerator flintGen;

@EventHandler

public void preLoad(FMLPreInitializationEvent event)

{

(not related to gen and ores items like ingots)

 

// Ores

oreFlint = new IFOre("industrialflow:oreFlint", tabIF, 5.6F, "", 0, this.nuggetFlint, Material.ground);

 

oreZinc = new IFOre("industrialflow:oreZinc", tabIF, 1.3F, "pickaxe", 1);

oreCopper = new IFOre("industrialflow:oreCopper", tabIF, 2.2F, "pickaxe", 1);

oreTin = new IFOre("industrialflow:oreTin", tabIF, 2.6F, "pickaxe", 1);

oreIron = new IFOre("industrialflow:oreIron", tabIF, 2.9F, "pickaxe", 1);

oreLead = new IFOre("industrialflow:oreLead", tabIF, 3.1F, "pickaxe", 1);

 

oreSilver = new IFOre("industrialflow:oreSilver", tabIF, 3.8F, "pickaxe", 2);

oreGold = new IFOre("industrialflow:oreGold", tabIF, 4.2F, "pickaxe", 2);

oreCobalt = new IFOre("industrialflow:oreCobalt", tabIF, 4.4F, "pickaxe", 2);

oreNickel = new IFOre("industrialflow:oreNickel", tabIF, 4.4F, "pickaxe", 2);

oreCadmium = new IFOre("industrialflow:oreCadmium", tabIF, 4.7F, "pickaxe", 2);

oreTopaz = new IFOre("industrialflow:oreTopaz", tabIF, 5.3F, "pickaxe", 2, this.gemTopaz);

oreDiamond = new IFOre("industrialflow:oreDiamond", tabIF, 5.6F, "pickaxe", 2, this.gemDiamond);

oreGallium = new IFOre("industrialflow:oreGallium", tabIF, 5.6F, "pickaxe", 2, this.dustGallium, 4);

oreGermanium = new IFOre("industrialflow:oreGermanium", tabIF, 5.8F, "pickaxe", 2, this.dustGermanium, 6);

 

oreUranium = new IFOre("industrialflow:oreUranium", tabIF, 6F, "pickaxe", 3);

oreTungsten = new IFOre("industrialflow:oreTungsten", tabIF, 8.5F, "pickaxe", 3);

 

orePlatinum = new IFOre("industrialflow:orePlatinum", tabIF, 10.3F, "pickaxe", 4);

oreTitanium = new IFOre("industrialflow:oreTitanium", tabIF, 12.5F, "pickaxe", 4);

 

orePalladium = new IFOre("industrialflow:orePalladium", tabIF, 15F, "pickaxe", 5);

oreRenium = new IFOre("industrialflow:oreRenium", tabIF, 16F, "pickaxe", 5);

oreRuthenium = new IFOre("industrialflow:oreRuthenium", tabIF, 20F, "pickaxe", 5);

oreRadium = new IFOre("industrialflow:oreRadium", tabIF, 22F, "pickaxe", 5);

oreThorium = new IFOre("industrialflow:oreThorium", tabIF, 24F, "pickaxe", 5);

 

GameRegistry.registerBlock(oreFlint, "industrialflowOreFlint");

GameRegistry.registerBlock(oreCopper, "industrialflowOreCopper");

GameRegistry.registerBlock(oreTin, "industrialflowOreTin");

GameRegistry.registerBlock(oreIron, "industrialflowOreIron");

GameRegistry.registerBlock(oreLead, "industrialflowOreLead");

GameRegistry.registerBlock(oreUranium, "industrialflowOreUranium");

GameRegistry.registerBlock(oreTitanium, "industrialflowOreTitanium");

GameRegistry.registerBlock(oreCobalt, "industrialflowOreCobalt");

GameRegistry.registerBlock(oreNickel, "industrialflowOreNickel");

GameRegistry.registerBlock(oreTopaz, "industrialflowOreTopaz");

GameRegistry.registerBlock(oreDiamond, "industrialflowOreDiamond");

GameRegistry.registerBlock(oreCadmium, "industrialflowOreCadmium");

GameRegistry.registerBlock(oreSilver, "industrialflowOreSilver");

GameRegistry.registerBlock(oreGold, "industrialflowOreGold");

GameRegistry.registerBlock(oreZinc, "industrialflowOreZinc");

GameRegistry.registerBlock(orePlatinum, "industrialflowOrePlatinum");

GameRegistry.registerBlock(oreGermanium, "industrialflowOreGermanium");

GameRegistry.registerBlock(oreGallium, "industrialflowOreGallium");

GameRegistry.registerBlock(oreTungsten, "industrialflowOreTungsten");

GameRegistry.registerBlock(oreRenium, "industrialflowOreRenium");

GameRegistry.registerBlock(orePalladium, "industrialflowOrePalladium");

GameRegistry.registerBlock(oreRuthenium, "industrialflowOreRuthenium");

GameRegistry.registerBlock(oreRadium, "industrialflowOreRadium");

GameRegistry.registerBlock(oreThorium, "industrialflowOreThorium");

(not related to ores and gen items like crafting)

 

cadmiumGen = new IFGenerator(oreCadmium, true, false, false, 1, 64, 6, 6);

reniumGen = new IFGenerator(oreRenium, true, false, false, 1, 36, 4, 3);

thoriumGen = new IFGenerator(oreThorium, false, false, true, 1, 52, 4, 4);

radiumGen = new IFGenerator(oreRadium, false, false, true, 1, 70, 4, 5);

 

zincGen = new IFGenerator(oreZinc, false, true, false, 1, 80, 6, 6);

copperGen = new IFGenerator(oreCopper, false, true, false, 1, 70, 6, 12);

tinGen = new IFGenerator(oreTin, false, true, false, 1, 70, 6, 10);

leadGen = new IFGenerator(oreLead, false, true, false, 1, 55, 5, 8);

cobaltGen = new IFGenerator(oreCobalt, false, true, false, 1, 45, 7, 4);

topazGen = new IFGenerator(oreTopaz, false, true, false, 1, 40, 7, 4);

nickelGen = new IFGenerator(oreNickel, false, true, false, 1, 45, 9, 3);

galliumGen = new IFGenerator(oreGallium, false, true, false, 1, 40, 9, 4);

germaniumGen = new IFGenerator(oreGermanium, false, true, false, 1, 40, 9, 4);

rutheniumGen = new IFGenerator(oreRuthenium, false, true, false, 1, 20, 4, 2);

palladiumGen = new IFGenerator(orePalladium, false, true, false, 1, 20, 4, 2);

uraniumGen = new IFGenerator(oreUranium, false, true, false, 1, 40, 2, 22);

titaniumGen = new IFGenerator(oreTitanium, false, true, false, 1, 30, 3, 8);

platinumGen = new IFGenerator(orePlatinum, false, true, false, 1, 40, 3, 3);

silverGen = new IFGenerator(oreSilver, false, true, false, 1, 55, 5, 5);

tungstenGen = new IFGenerator(oreTungsten, false, true, false, 1, 35, 5, 4);

 

flintGen = new AirGenerator(oreTungsten, 9, 9, 200, 1);

 

GameRegistry.registerWorldGenerator(flintGen, 0);

GameRegistry.registerWorldGenerator(reniumGen, 1);

GameRegistry.registerWorldGenerator(thoriumGen, 2);

GameRegistry.registerWorldGenerator(radiumGen, 3);

GameRegistry.registerWorldGenerator(copperGen, 4);

GameRegistry.registerWorldGenerator(tinGen, 5);

GameRegistry.registerWorldGenerator(cadmiumGen, 6);

GameRegistry.registerWorldGenerator(leadGen, 7);

GameRegistry.registerWorldGenerator(tungstenGen, 8);

GameRegistry.registerWorldGenerator(rutheniumGen, 9);

GameRegistry.registerWorldGenerator(palladiumGen, 10);

GameRegistry.registerWorldGenerator(silverGen, 11);

GameRegistry.registerWorldGenerator(zincGen, 12);

GameRegistry.registerWorldGenerator(galliumGen, 13);

GameRegistry.registerWorldGenerator(uraniumGen, 14);

GameRegistry.registerWorldGenerator(germaniumGen, 15);

GameRegistry.registerWorldGenerator(cobaltGen, 16);

GameRegistry.registerWorldGenerator(nickelGen, 17);

GameRegistry.registerWorldGenerator(topazGen, 18);

GameRegistry.registerWorldGenerator(platinumGen, 19);

GameRegistry.registerWorldGenerator(titaniumGen, 20);

}

}

 

 

P.S.  8) = 8 )

Link to comment
Share on other sites

I see a lot of things wrong with the way you coded your mod:

 

- You only need 1

IWorldGenerator 

to generate all your ores.

-

if (this.nether == true)

  Why do people do this? This works exactly the same as

if(this.nether)

, since the

nether

variable is of type boolean.

- As diesieben07 said, why are the fields in your generator class static? Do you even know what static means? This explains a lot of your problems (only tungsten generating, but everywhere).

- In allof your asserts, you used the wrong logical operators: < instead of >, and vice versa. The first asserts is basically: if maxY is greater than minY, say "maxY is lower than minY".

- You are generating with the wrong X and Z variables in the overworld. This is what you get when you have horrible names for variables.

 

Overall, I'm beginning to question your Java knowledge. If you don't know Java, and you are trying to learn it via Minecraft modding, I strongly advice against it. Learning Java and modding seperately will take way less time.

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

1) About static fields. They don't change anything, the error was in the AirGenerator class that generated Flint ore.

2) Asserts: view here http://stackoverflow.com/questions/3018683/what-does-the-assert-keyword-do

this statement

 

assert cond;

is equivalent to

 

if (!cond)

    throw new AssertionError();

it's from SOF. So maybe you don't remember java fully?

3) About

if (this.nether == true)
I use this to minimize errors. I know
if(this.nether)
is shorter, but that sometimes causes errors.

4) About 1 IWorldGenerator. I don't understand why multiple IWGens are required, solo IWG works too.

5) Horrible names for variables are really horrible, thank you very much for finding real fault!  :)

Link to comment
Share on other sites

1) About static fields. They don't change anything

Yes, they do.

Oh, that was my fault. I disabled static before I disabled flint ore...  :o Right then nothing changed.

About this.nether and this.nether==true - they are equal... But because of they are equal why can't I use 2nd variant? Because it's longer than 1st?  ???

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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