Jump to content

[1.8.9] What is the 1.8.x equivalent of IChunkGenerator from 1.9/1.10?


boredherobrine13

Recommended Posts

Hi, as stated. I am wondering if there is a simple equivalent to IChunkGenerator for 1.8. I am doing a backport of some code for my mod's users. Mainly because 1.8 is still semi-popular for modpacks. Here is my code, problem line in bold:

 

package com.bored.morefuelsmod;

 

import java.util.Random;

 

import com.bored.morefuelsmod.block.ModBlocks;

 

import net.minecraft.util.BlockPos;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.chunk.IChunkGenerator;

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

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

import net.minecraftforge.fml.common.IWorldGenerator;

 

public class ModWorldGen implements IWorldGenerator{

 

private WorldGenerator bituminousCoalOre;

 

public ModWorldGen(){

  this.bituminousCoalOre = new WorldGenMinable(ModBlocks.bituminousCoalOre.getDefaultState(), 4);

  }

 

private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {

        if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)

            throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");

 

        int heightDiff = maxHeight - minHeight + 1;

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

            int x = chunk_X * 16 + rand.nextInt(16);

            int y = minHeight + rand.nextInt(heightDiff);

            int z = chunk_Z * 16 + rand.nextInt(16);

            generator.generate(world, rand, new BlockPos(x, y, z));

        }

    }

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,

  IChunkProvider chunkProvider) {

  switch (world.provider.getDimensionId()){

  case 0://Over_World

  //this.runGenerator(generator, world, random, chunkX, chunkZ, chancesToSpawn, minHeight, maxHeight);//

  this.runGenerator(this.bituminousCoalOre, world, random, chunkX, chunkZ, 10, 0, 60);

    break;

  case -1://Nether

 

  break;

 

  case 1://End

 

  break;

  }

}

 

@Override

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

IChunkProvider chunkProvider) {

// TODO Auto-generated method stub

 

}

}

 

Link to comment
Share on other sites

Hi, as stated. I am wondering if there is a simple equivalent to IChunkGenerator for 1.8. I am doing a backport of some code for my mod's users. Mainly because 1.8 is still semi-popular for modpacks. Here is my code, problem line in bold:

 

package com.bored.morefuelsmod;

 

import java.util.Random;

 

import com.bored.morefuelsmod.block.ModBlocks;

 

import net.minecraft.util.BlockPos;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.chunk.IChunkGenerator;

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

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

import net.minecraftforge.fml.common.IWorldGenerator;

 

public class ModWorldGen implements IWorldGenerator{

 

private WorldGenerator bituminousCoalOre;

 

public ModWorldGen(){

  this.bituminousCoalOre = new WorldGenMinable(ModBlocks.bituminousCoalOre.getDefaultState(), 4);

  }

 

private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {

        if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)

            throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");

 

        int heightDiff = maxHeight - minHeight + 1;

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

            int x = chunk_X * 16 + rand.nextInt(16);

            int y = minHeight + rand.nextInt(heightDiff);

            int z = chunk_Z * 16 + rand.nextInt(16);

            generator.generate(world, rand, new BlockPos(x, y, z));

        }

    }

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,

  IChunkProvider chunkProvider) {

  switch (world.provider.getDimensionId()){

  case 0://Over_World

  //this.runGenerator(generator, world, random, chunkX, chunkZ, chancesToSpawn, minHeight, maxHeight);//

  this.runGenerator(this.bituminousCoalOre, world, random, chunkX, chunkZ, 10, 0, 60);

    break;

  case -1://Nether

 

  break;

 

  case 1://End

 

  break;

  }

}

 

@Override

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

IChunkProvider chunkProvider) {

// TODO Auto-generated method stub

 

}

}

If you implement IWorldGenerator it will show you what the method should be assuming you are using an IDE like eclipse.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.