Jump to content

[1.9.4] End Oregen


ThatGamerBlue

Recommended Posts

I'm struggling to do oregen, because mojang change everything every version nowadays ;p

 

I'm  trying to do it in the end, there's no errors in the log, but here's my code and maybe you can help me.

 

WorldGenAmethystOre.java:

package me.thatgamerblue.amethyst.worldgen;

import java.util.Random;

import me.thatgamerblue.amethyst.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
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.storage.WorldInfo;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldGenAmethystOre implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	switch (world.provider.getDimension()) {
	case -1:
		break;
	case 0:
		break;
	case 1:
		generateEnd(world, random, chunkX * 16, chunkZ * 16);
		break;
	default:
		break;

	}
}

private void generateEnd(World world, Random random, int i, int j){
	for (int k = 0; k < 6; k++){
		int chunkX = i + random.nextInt(16);
		int chunkY = random.nextInt(125);
		int chunkZ = j + random.nextInt(16);

		BlockPos bp = new BlockPos(chunkX, chunkY, chunkZ);

		new WorldGenMinable(ModBlocks.amethystOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.END_STONE)).generate(world, random, bp);
	}
}

}

 

AmethystCommonProxy.java:

package me.thatgamerblue.amethyst.proxy;

import me.thatgamerblue.amethyst.blocks.ModBlocks;
import me.thatgamerblue.amethyst.items.ModItems;
import me.thatgamerblue.amethyst.worldgen.WorldGenAmethystOre;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class AmethystCommonProxy {

public void preInit(){
	ModBlocks.init();
	ModItems.init();
}

public void init(){
	GameRegistry.registerWorldGenerator(new WorldGenAmethystOre(), 16);
}

public void postInit(){

}

}

 

Amethyst.java (main):

package me.thatgamerblue.amethyst;

import me.thatgamerblue.amethyst.proxy.AmethystCommonProxy;
import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Amethyst.MODID, version = Amethyst.VERSION, name = Amethyst.MODNAME)
public class Amethyst
{
    public static final String MODID = "Amethyst";
    public static final String VERSION = "1.0";
    public static final String MODNAME = "Amethyst";
    
    @SidedProxy(serverSide="me.thatgamerblue.amethyst.proxy.AmethystCommonProxy", clientSide="me.thatgamerblue.amethyst.proxy.AmethystClientProxy")
    public static AmethystCommonProxy proxy;
    
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        
    	proxy.init();
    	
        System.out.println("Loaded");
    }
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
    	
    	proxy.preInit();
    	
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event){
    	
    	proxy.postInit();
    	
    }
    
}

Link to comment
Share on other sites

For a start use << 4 when transforming chunk coords into block coords, not * 16.

Apart from that your code looks fine, it should work. Show your ClientProxy.

 

New world gen:

package me.thatgamerblue.amethyst.worldgen;

import java.util.Random;

import me.thatgamerblue.amethyst.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
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.storage.WorldInfo;
import net.minecraftforge.fml.common.IWorldGenerator;

public class WorldGenAmethystOre implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	switch (world.provider.getDimension()) {
	case -1:
		break;
	case 0:
		break;
	case 1:
		generateEnd(world, random, chunkX << 4, chunkZ << 4);
		break;
	default:
		break;

	}
}

private void generateEnd(World world, Random random, int i, int j){
	for (int k = 0; k < 6; k++){
		int chunkX = i + random.nextInt(16);
		int chunkY = random.nextInt(125);
		int chunkZ = j + random.nextInt(16);

		BlockPos bp = new BlockPos(chunkX, chunkY, chunkZ);

		new WorldGenMinable(ModBlocks.amethystOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.END_STONE)).generate(world, random, bp);
	}
}

}

 

Client proxy:

package me.thatgamerblue.amethyst.proxy;

import me.thatgamerblue.amethyst.blocks.ModBlocks;
import me.thatgamerblue.amethyst.items.ModItems;

public class AmethystClientProxy extends AmethystCommonProxy {

public void preInit(){

	super.preInit();
	ModBlocks.initModels();
	ModItems.initModels();

}

public void init(){

	super.init();

}

public void postInit(){

	super.postInit();

}

}

 

EDIT: Sorry for late reply, real life stuff happened :P

Link to comment
Share on other sites

Forge version is 12.17.0.1976, debugging to see if they're being called now.

 

EDIT: Changed generateEnd() function to this:

private void generateEnd(World world, Random random, int i, int j){
	System.out.println("generateEnd(world, random, i, j) called");
	for (int k = 0; k < 6; k++){
		int chunkX = i + random.nextInt(16);
		int chunkY = random.nextInt(125);
		int chunkZ = j + random.nextInt(16);

		BlockPos bp = new BlockPos(chunkX, chunkY, chunkZ);

		new WorldGenMinable(ModBlocks.amethystOre.getDefaultState(), 2, BlockMatcher.forBlock(Blocks.END_STONE)).generate(world, random, bp);
	}
}

 

It's definitely being called

Link to comment
Share on other sites

I have this, and it works for me:

public class CheeseGeneration implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
		IChunkProvider chunkProvider) {
	switch (world.provider.getDimension()) {
	case -1:
		generateNether(world, random, chunkX, chunkZ);
		break;
	case 0:
		generateOverworld(world, random, chunkX, chunkZ);
		break;
	case 1:
		generateEnd(world, random, chunkX, chunkZ);
		break;
	}
}

public void generateNether(World world, Random rand, int x, int z) {
	generateOre(CheeseBlocks.CHEESE_ORE_NETHER, world, rand, x, z, 3, 10, 35, 0, 256, Blocks.NETHERRACK);
}

public void generateOverworld(World world, Random rand, int x, int z) {
	generateOre(CheeseBlocks.CHEESE_ORE, world, rand, x, z, 3, 10, 47, 0, 256, Blocks.STONE);
}

public void generateEnd(World world, Random rand, int x, int z) {
	generateOre(CheeseBlocks.CHEESE_ORE_END, world, rand, x, z, 3, 10, 23, 0, 256, Blocks.END_STONE);
}

public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
	int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
	int heightRange = maxY - minY;
	WorldGenMinable gen = new WorldGenMinable(block.getDefaultState(), vienSize, BlockMatcher.forBlock(generateIn));
	for(int i = 0; i < chance; i++) {
		int xRand = chunkX * 16 + random.nextInt(16);
		int yRand = random.nextInt(heightRange) + minY;
		int zRand = chunkZ * 16 + random.nextInt(16);
		BlockPos orePos = new BlockPos(xRand, yRand, zRand);
		gen.generate(world, random, orePos);
	}
}

}

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.