Jump to content

[1.7.10]Generating pools of Oil with WorldGenLakes not working?[solved]


Recommended Posts

Posted

So I've made my own custom fluid crude oil and was able to spawn it via the ore generator. But what I really want is to spawn them as patches of oil. I'm registering the LakeHandler in my main file like this...

 

  Quote
GameRegistry.registerWorldGenerator(new MaterialEvolutionLakeGenerator(blockCrudeOil), 3);

 

..and then use this code trying to spawn the oil patches...

 

  Quote
package com.mofakin.materialevolution;

 

import java.util.Random;

 

import cpw.mods.fml.common.IWorldGenerator;

import net.minecraft.block.Block;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

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

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

 

public class MaterialEvolutionLakeGenerator extends WorldGenLakes implements IWorldGenerator {

 

public MaterialEvolutionLakeGenerator(Block p_i45455_1_) {

super(p_i45455_1_);

}

 

 

@Override

public boolean generate(World world, Random random, int x, int y, int z){

 

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

int firstBlockYCoord = random.nextInt(128);

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

 

new WorldGenLakes(MaterialEvolutionModBase.blockCrudeOil).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);

return true;

 

}

 

 

@Override

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

 

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

int firstBlockYCoord = random.nextInt(128);

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

 

new WorldGenLakes(MaterialEvolutionModBase.blockCrudeOil).generate(world, random, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);

 

}

 

}

 

...it's working perfectly inside the ore generator, despite not being an ore, but what's wrong with it in the lake handler?

Posted

I'm pretty sure you need to make the lake generator a different class. I've never worked with it before but, it could be conflicting.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I'm quoting @larsgerrits here...

  Quote
You don't need a new version of WorldGenLakes. You can just call new WorldGenLakes(YOUR_FLUID_BLOCK).generate(World,Random,Integer,Integer,Integer); and that will make it generate.

 

...the vanilla WorldGenLakes class is a World Generator class, and it implements methods the same way I do. I've found another thread using a method based on IChunkProvider, but I don't want to do Biomes or Dimensions, I only want to spawn my fluid in patches of oil. Which class type do you exactly advice me to use?

Posted

I feel dumb now...it's working. I should have utilized the fly function in creative mode earlier. You want to use the void method, not the boolean. Now I just need to find a frequence of quantity. The one used in ore generator doesn't semm to work.

  • 2 years later...
Posted

This is how to do what you are saying. Create a class that extends WorldGenLakes and implements IWorldGenerator. Then, register a copy of it specifying your oil block as the block type.

 

import java.util.Random;

import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenLakes;

public class OilLakeWorldGenerator extends WorldGenLakes implements IWorldGenerator{
    //    Constructors.
    public OilLakeWorldGenerator(Block fluidBlock) {
        super(fluidBlock);
    }
    
    //    Methods.
    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
        int x = (chunkX*16) + random.nextInt(16) + 8;
        int y = random.nextInt(256);
        int z = (chunkZ*16) + random.nextInt(16) + 8;
        super.generate(world, random, x, y, z);
    }
}

 

Change the y when you want it to spawn at only certain levels.

Posted
  On 5/14/2017 at 4:03 AM, Artemis said:

This is how to do what you are saying. Create a class that extends WorldGenLakes and implements IWorldGenerator. Then, register a copy of it specifying your oil block as the block type.

 

import java.util.Random;

import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenLakes;

public class OilLakeWorldGenerator extends WorldGenLakes implements IWorldGenerator{
    //    Constructors.
    public OilLakeWorldGenerator(Block fluidBlock) {
        super(fluidBlock);
    }
    
    //    Methods.
    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
        int x = (chunkX*16) + random.nextInt(16) + 8;
        int y = random.nextInt(256);
        int z = (chunkZ*16) + random.nextInt(16) + 8;
        super.generate(world, random, x, y, z);
    }
}

 

Change the y when you want it to spawn at only certain levels.

Expand  
  • This thread is over 2 years old.
  • 1.7.10 is no longer supported.
  • Your example will cause chunk-loading issues during worldgen.
    • What if the random.nextInt(16) is greater than 8? And you add 8 to that? Oh, we got n > 16, so now we're in the next chunk.

This thread should be locked by a moderator.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

  • Guest locked this topic
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.