Jump to content

Recommended Posts

Posted

So I ported my 1.7 ore generation to a 1.11.2 workspace, but I can't seem to figure out how to properly impliment the WorldGenMineable variable, can someone tell me what I'm doing wrong here?

 

package jedijoe.mods.worldgen;

import java.util.Random;

import jedijoe.mods.init.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.fml.common.IWorldGenerator;

public class Ore implements IWorldGenerator {

	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
			IChunkProvider chunkProvider) {
		switch(world.provider.getDimensionType()) { case
		OVERWORLD:
			generateOverWorld(random, chunkX * 16, chunkZ * 16, world);
			break;
		case THE_END:
			generateEnd(random, chunkX * 16, chunkZ * 16, world);
			break;
		case NETHER:
			generateNether(random, chunkX * 16, chunkZ * 16, world);
			break;

			
		
			
			
		}
		
	}

	private void generateNether(Random random, int i, int j, World world) {
		// TODO Auto-generated method stub
		
	}

	private void generateEnd(Random random, int chunkX, int chunkZ, World world) {
		addOre(ModBlocks.EAtomicO, Blocks.END_STONE, random, world, chunkX, chunkZ, 5, 12, 2, 4, 4);
		
	}

	private void generateOverWorld(Random random, int i, int j, World world) {
		// TODO Auto-generated method stub
		
	}

	private void addOre(Block block, Block blockspawn, Random random, World world, int posX, int posZ, int minY, int maxY, int minVein, int maxVein, int spawnChance) {
		for(int i = 0; i < spawnChance; i++) {
			int defaultChunkSize = 16;
			int veinSize = minVein + random.nextInt(maxVein - minVein);
			int heightRange = maxY - minY;
			int xPos= posX + random.nextInt(defaultChunkSize);
			int yPos = minY + random.nextInt(maxY - minY);
			int zPos= posZ + random.nextInt(defaultChunkSize);
			WorldGenMinable gen = new WorldGenMinable(block, veinSize, generateIn);
			
		}
	}
}

 

Posted (edited)

The WorldGenMineable line here is popping a syntax error at generateIn saying that it can not be resolved to a variable, removing it causes bigger errors, following the path of errors and trying to resolve them via the suggested methods by eclipse just causes more errors. I tried removing the line entirely, but of course that just prevents ores from spawning entirely.

 

			WorldGenMinable gen = new WorldGenMinable(block, veinSize, generateIn);

 

 

Edited by jedijoe
grammar fix
Posted

Well, you never declare generateIn anywhere...

 

You do however have a variable called blockspawn, of which you need to make a Predicate<IBlockState> and pass that instead of generateIn. You can use BlockMatcher.forBlock(Block) to create a Predicate<IBlocKState>.

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/

Posted

Alright, I got it to stop spitting errors at me, but now I just can't get it to generate the ores I am telling it to, and I am quite sure it's probably some giant mistake I am not seeing here

package jedijoe.mods.init;

import java.util.Random;

import com.google.common.base.Predicate;

import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

public class Worldgen implements IWorldGenerator {
	
	private WorldGenerator ATOMICORE;
	
	public Worldgen() {
		
	}

	@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
			IChunkProvider chunkProvider) {
		switch (world.provider.getDimension())
	{
		case 0:
		addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, chunkX, chunkZ, 16, 16, 50, 30, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
		break;
	
		default:
			break;
		
		
	}


	}

	private void genSurface(World world, Random random, int chunkX, int chunkZ){
		 addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, chunkX, chunkZ, 16, 16, 50, 20, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
		}

	private void addOreSpawn(IBlockState defaultState, World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ,
			int maxVeinSize, int chance, int minY, int maxY, Predicate<IBlockState> Stone) {
		int diffMinMaxY = maxY - minY;
		for (int x = 0; x < chance; x++) {
		  int posX = blockXpos + random.nextInt(maxX);
		  int posY = minY + random.nextInt(diffMinMaxY);
		  int posZ = blockZpos + random.nextInt(maxZ);
		   (new WorldGenMinable(defaultState, maxVeinSize, Stone)).generate(world, random, new BlockPos(posX, posY, posZ));
		}

		
	}
	
}

 

Posted

I adjusted it to swap out the chunk variables for the block variables, and matched the syntax, however these changes did not fix the issue where no ore is generating

package jedijoe.mods.init;

import java.util.Random;

import com.google.common.base.Predicate;

import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

public class Worldgen implements IWorldGenerator {
	
	private WorldGenerator ATOMICORE;
	
	public Worldgen() {
		
	}

	@Override
	public void generate(Random random, int blockXpos, int blockZpos, World world, IChunkGenerator chunkGenerator,
			IChunkProvider chunkProvider) {
		switch (world.provider.getDimension())
	{
		case 0:
		addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, blockXpos, blockZpos, 16, 16, 50, 30, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
		break;
	
		default:
			break;
		
		
	}


	}

	private void genSurface(World world, Random random, int blockXpos, int blockZpos){
		 addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, blockXpos, blockZpos, 16, 16, 50, 20, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
		}

	private void addOreSpawn(IBlockState defaultState, World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ,
			int maxVeinSize, int chance, int minY, int maxY, Predicate<IBlockState> Stone) {
		int diffMinMaxY = maxY - minY;
		for (int x = 0; x < chance; x++) {

			
	          int posX = blockXpos + random.nextInt(maxX);
	          int posY = minY + random.nextInt(diffMinMaxY);
	          int posZ = blockZpos + random.nextInt(maxZ);
		   (new WorldGenMinable(defaultState, maxVeinSize, Stone)).generate(world, random, new BlockPos(posX, posY, posZ));
		}

		
	}
	
}

 

 

Posted

Simply changing the name won't change the value. This is basic Java.

 

You should convert the chunk coordinates to block coordinates by using chunkX << 4. The same for chunkZ.

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/

Posted

I'm pretty sure this is closer to what you meant. I know I still managed to mess it up.

public class Worldgen implements IWorldGenerator {
   
    private WorldGenerator ATOMICORE;
   
    public Worldgen() {
       
    }
 
    @Override
    public void generate(Random random, int blockXPos, int blockZPos, World world, IChunkGenerator chunkGenerator,
            IChunkProvider chunkProvider) {
        switch (world.provider.getDimension())
    {
        case 0:
        addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, blockXPos, blockZPos, 16, 16, 50, 30, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
        break;
   
        default:
            break;
       
       
    }
 
 
    }
 
    private void genSurface(World world, Random random, int chunkX, int chunkZ){
         addOreSpawn(ModBlocks.AtomicO.getDefaultState(), world, random, chunkX, chunkZ, 16, 16, 50, 20, 10, 100, BlockMatcher.forBlock(Blocks.STONE));
        }
 
    private void addOreSpawn(IBlockState defaultState, World world, Random random, int chunkX, int chunkZ, int maxX, int maxZ,
            int maxVeinSize, int chance, int minY, int maxY, Predicate<IBlockState> Stone) {
    	int defaultchunksize = 16; 
        int diffMinMaxY = maxY - minY;
        for (int x = 0; x < chance; x++) {
        int blockXpos = chunkX << 4;
        int blockZpos = chunkZ << 4;
          int posX = blockXpos + random.nextInt(maxX);
          int posY = minY + random.nextInt(diffMinMaxY);
          int posZ = blockZpos + random.nextInt(maxZ);
           (new WorldGenMinable(defaultState, maxVeinSize, Stone)).generate(world, random, new BlockPos(posX, posY, posZ));
        }
 
       
    }
   
}

 

Posted

Step through your generate method (and  into the methods it calls) using the debugger to see what you are actually doing. Examine local variables to see which block (positions) are being changed to what.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.