public class NewWorldGenerator implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch (world.provider.dimensionId)
{
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
}
}
private void generateSurface(World world, Random random, int x, int z)
{
addOreSpawn(Main.oreRuby, world, random, x, z, 16, 16, 2 + random.nextInt(2), 7, 0, 32);
}
private void generateNether(World world, Random random, int x, int z)
{
}
private void generateEnd(World world, Random random, int x, int z)
{
}
private void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chanceToSpawn, int minY, int maxY)
{
for (int i = 10; i < chanceToSpawn; i++)
{
int posX = blockXPos + random.nextInt(maxX);
int posY = minY + random.nextInt(maxY - minY);
int posZ = blockZPos + random.nextInt(maxZ);
new WorldGenMinable(block, maxVeinSize).generate(world, random, posX, posY, posZ);
}
}
}
The 7 is the chance to spawn. I don't know the numbers related to Minecraft ore, but 10-12 is around the chance of coal to spawn. Diamonds would be around 3-5. This is just to give you an idea.
0 and 32 are the y-values at which it can spawn, so for this ore, Ruby Ore will spawn below 32 blocks.
The "2 + random.nextInt(2)" is the amount of ore in a vein. So this ore will spawn at least 2, with the chance of adding 2 more ores.
The Meaning of Life, the Universe, and Everything.
Join Date:
10/1/2012
Posts:
45
Minecraft:
QuickWhitt7
Xbox:
QuickWhitt7
PSN:
QuickWhitt7
Discord:
quickwhitt7#0007
PMC:
quickwhitt7
Member Details
I did every step you told me too, and I don't see any Minecraft folder inside the Package Explorer of Eclipse. I'm at a cliffhanger here, can you give more clear instructions?
I've got a creative tab working, but I cannot define anything into it. setCreativeTab(CreativeTabs.[tabID]); doesn't work fully, when I change it from a vanilla tab name it becomes reset as some sort of empty parameter and turns to plain text, and attempting to run causes a crash.
I also cannot get textures to work. Eclipse throws up a file not found error every single time, even though I have absolutely entered the correct path.
I've got a creative tab working, but I cannot define anything into it. setCreativeTab(CreativeTabs.[tabID]); doesn't work fully, when I change it from a vanilla tab name it becomes reset as some sort of empty parameter and turns to plain text, and attempting to run causes a crash.
I also cannot get textures to work. Eclipse throws up a file not found error every single time, even though I have absolutely entered the correct path.
Use 'setCreativeTab(YourCreativeTabClass.tabID);' for custom creative tabs. If you are trying to do a vanilla tab (e.g. Blocks), use 'setCreativeTab(CreativeTabs.tabID);'.
What's your texture path, texture code, and name of your texture?
Well giving the new tab its own class stopped the crash, but the tab doesn't have the block I set to it. The block has disappeared from the entire creative menu, in fact, and is no longer searchable. I am 100% confident that I have done something wrong about that.
The error in eclipse is [ unable to load tutorialmod:textures/blocks/tutorialBlock.png ] and the block texture path set to [ MODID+":"+"tutorialBlock" ]. The modid is tutorialmod. The path is Resources/assets/tutorialmod/textures/blocks, and the image is tutorialBlock.png. I've tried things like renaming copies of the image to tutorialBlock.png, so really as .png.png, setting the texture name in code as tutorialBlock.png, and writing in the path directly. Several other tutorials give the same code and none have worked.
Look through my code, and see about making it look fairly close to mine (Blocks, ModTabs, AscensionTab). It's much easier in the long run if your create different packages/class for better organization. If you get confused by my code, just let me know.
Look through my code, and see about making it look fairly close to mine (Blocks, ModTabs, AscensionTab). It's much easier in the long run if your create different packages/class for better organization. If you get confused by my code, just let me know.
Well, for the block itself, what does substring do in the texture naming line?
setBlockTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
In any case, using your code with replacement strings still results in an error.
I don't really get the classes for the creative tabs, what with needing an if/else to get the icons.
Substring basically ignores the first 5 characters of your item/block, as if you have an item, they would default to 'item.unlocalizedName', or in the blocks case, 'tile.unlocalizedName'. At least, that's what I believe it is there for ;).
As for the creative tabs, I used an if/else statement because it made it easier when adding multiple tabs, plus you can still do it with one.
I looks like you tried to import minecraft to your workspace, which definitely won't work. The left side panel should include only the imported forge src directory, so unless you renamed that folder to minecraft that's probably your error.
Okay, first I will point out I am no beginner. There are plenty of tutorials for making simple chunk generators (new dimensions, world types, etc.). I don't care about that.
I want to know how to take all the normal chunk generation stuff and hook it into forge, because the above screenshot was from a very old mod that was not compatible with anything but itself (and TMI). Could you make a short tutorial on adding already made WorldType's into forge? (for advanced users)
Please Can Somebody help me figure out how to set the harvestablilty on my ores. My code looks like this in my block initialization file but it drops the items no matter what
public static void InitializeBlock()
{
ambrOre = new ambrOre(Material.ground).setBlockName("ambrOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":amberore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
ambrOre.setHarvestLevel("pickaxe", 2);
amstOre = new amstOre(Material.ground).setBlockName("amstOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":amythestore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
amstOre.setHarvestLevel("pickaxe", 2);
sapOre = new sapOre(Material.ground).setBlockName("sapOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":sapphireore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
sapOre.setHarvestLevel("pickaxe", 2);
package com.craftxbox.generation;
import java.util.Random;
import com.craftxbox.Main.Main;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class NewWorldGenerator implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch (world.provider.dimensionId)
{
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
}
}
private void generateSurface(World world, Random random, int x, int z)
{
addOreSpawn(Main.oreRuby, world, random, x, z, 16, 16, 2 + random.nextInt(2), 7, 0, 32);
}
private void generateNether(World world, Random random, int x, int z)
{
}
private void generateEnd(World world, Random random, int x, int z)
{
}
private void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chanceToSpawn, int minY, int maxY)
{
for (int i = 10; i < chanceToSpawn; i++)
{
int posX = blockXPos + random.nextInt(maxX);
int posY = minY + random.nextInt(maxY - minY);
int posZ = blockZPos + random.nextInt(maxZ);
new WorldGenMinable(block, maxVeinSize).generate(world, random, posX, posY, posZ);
}
}
}
The 7 is the chance to spawn. I don't know the numbers related to Minecraft ore, but 10-12 is around the chance of coal to spawn. Diamonds would be around 3-5. This is just to give you an idea.
0 and 32 are the y-values at which it can spawn, so for this ore, Ruby Ore will spawn below 32 blocks.
The "2 + random.nextInt(2)" is the amount of ore in a vein. So this ore will spawn at least 2, with the chance of adding 2 more ores.
I'm telling you dude, you'd do awesome at it, and it would help alot of people out
I also cannot get textures to work. Eclipse throws up a file not found error every single time, even though I have absolutely entered the correct path.
Use 'setCreativeTab(YourCreativeTabClass.tabID);' for custom creative tabs. If you are trying to do a vanilla tab (e.g. Blocks), use 'setCreativeTab(CreativeTabs.tabID);'.
What's your texture path, texture code, and name of your texture?
The error in eclipse is [ unable to load tutorialmod:textures/blocks/tutorialBlock.png ] and the block texture path set to [ MODID+":"+"tutorialBlock" ]. The modid is tutorialmod. The path is Resources/assets/tutorialmod/textures/blocks, and the image is tutorialBlock.png. I've tried things like renaming copies of the image to tutorialBlock.png, so really as .png.png, setting the texture name in code as tutorialBlock.png, and writing in the path directly. Several other tutorials give the same code and none have worked.
block class and tab class
There's probably something I need to put inside the creative tab class, I haven't read a tutorial about setting up a new creative tab.
Well, for the block itself, what does substring do in the texture naming line?
setBlockTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
In any case, using your code with replacement strings still results in an error.
I don't really get the classes for the creative tabs, what with needing an if/else to get the icons.
As for the creative tabs, I used an if/else statement because it made it easier when adding multiple tabs, plus you can still do it with one.
I want to know how to take all the normal chunk generation stuff and hook it into forge, because the above screenshot was from a very old mod that was not compatible with anything but itself (and TMI). Could you make a short tutorial on adding already made WorldType's into forge? (for advanced users)
EDIT: I figured it out.
I don't cheat; I just conveniently write the rules.
Oops, did I steal your mod? Well, I'm lazy, so if I found the motivation to do so, you did something wrong as a developer.
Additional Buildcraft Objects: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2310397
I'm currently also working on Remain in Motion. http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2104611
I can't advertise the others....
My Patreon: https://www.patreon.com/DA3DSOUL
Diamonds for you m8 !
Please Can Somebody help me figure out how to set the harvestablilty on my ores. My code looks like this in my block initialization file but it drops the items no matter what
public static void InitializeBlock()
{
ambrOre = new ambrOre(Material.ground).setBlockName("ambrOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":amberore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
ambrOre.setHarvestLevel("pickaxe", 2);
amstOre = new amstOre(Material.ground).setBlockName("amstOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":amythestore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
amstOre.setHarvestLevel("pickaxe", 2);
sapOre = new sapOre(Material.ground).setBlockName("sapOre").setCreativeTab(MCreativeTabs.tabBlock).setBlockTextureName(ReferencedStrings.MODID + ":sapphireore").setHardness(3.0f).setStepSound(Block.soundTypeStone);
sapOre.setHarvestLevel("pickaxe", 2);
}
my block generator:
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
public class ambrOre extends Block
{
protected ambrOre(Material p_i45394_1_) {
super(p_i45394_1_);
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Mitems.amber;
}
}