Jump to content

ScrawnyBeast

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by ScrawnyBeast

  1. Not really. No one explained why making a new block wouldn't work(which would have been helpful for learning). They just stated that it wouldn't. But it didn't help either. Even after calling Tutorial.celluloseBlock(), which was initiated in the preInit() method, instead of making a new block I still just have empty spaces. None of my blocks get generated in the world. I can still place them from creative mode though.
  2. Finally an answer! So they have to be loaded in the preInit AND called from there in each other class. This answer would have saved a lot of confusion had it come earlier.
  3. Bad way to code (Because of performance issues always making a new block instance) aside. What causes the blocks not to be there at all? That is the question I started this post about, and it is still unanswered.
  4. Here's all the classes I think would matter. [code/] package myMinecraftMod.tutorial; import myMinecraftMod.tutorial.Blocks.Cellulos; import myMinecraftMod.tutorial.Items.CellulosItem; import myMinecraftMod.tutorial.Recipies.Crafting; import myMinecraftMod.tutorial.WorldGen.EventManager; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = Tutorial.MODID, version = Tutorial.VERSION) public class Tutorial { public static final String MODID = "tutorial"; public static final String VERSION = "1.0"; public static Item cellulosItem; public static Block cellulosBlock; public static Item cellulosplankItem; public static Block cellulosplankBlock; public EventManager eventManager; @EventHandler public void init(FMLInitializationEvent event) { } @EventHandler public void preInit(FMLPreInitializationEvent event) { //loads all new blocks/items cellulosBlock = new Cellulos(Material.wood).setBlockName("cellulosblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)); cellulosplankBlock = new Cellulos(Material.wood).setBlockName("cellulosplankblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)); GameRegistry.registerBlock(cellulosBlock,MODID +(cellulosBlock.getUnlocalizedName().substring(5))); GameRegistry.registerBlock(cellulosplankBlock,MODID +(cellulosplankBlock.getUnlocalizedName().substring(5))); cellulosplankItem = new CellulosItem().setUnlocalizedName("cellulosplankitem"); cellulosItem = new CellulosItem().setUnlocalizedName("cellulositem"); GameRegistry.registerItem(cellulosplankItem, "cellulosplankitem"); GameRegistry.registerItem(cellulosItem, "cellulositem"); myMinecraftMod.tutorial.Recipies.Crafting.loadRecipes(); eventManager=new EventManager(); GameRegistry.registerWorldGenerator(eventManager, 0); } @EventHandler public void postInit(FMLPostInitializationEvent event) { /** TODO Hack to get our textures for items and blocks to show, remove when the bug is * fixed in an update. If this is not done, then the player must manually refresh * the texture packs. */ } } [code/] package myMinecraftMod.tutorial.WorldGen; import java.util.Random; import myMinecraftMod.tutorial.Blocks.Cellulos; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenerator; import cpw.mods.fml.common.IWorldGenerator; public class EventManager implements IWorldGenerator{ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case -1: generateNether(world, random, chunkX * 16, chunkZ * 16); case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16); case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16); } } private void generateEnd(World world, Random random, int x, int z) { } private void generateSurface(World world, Random random, int chunk_X, int chunk_Z) { int x,z,y; int mushInChunk=random.nextInt(20); for(int j=0;j<mushInChunk;j++) { x=chunk_X+random.nextInt(16); z=chunk_Z+random.nextInt(16); Block block1,block2; for(int i=0;i<127;i++) { block1=world.getBlock(x,i,z); block2=world.getBlock(x,i+1,z); //if(!block1.isAir(world, x, i, z)&&block2.isAir(world, x, i+1, z)) //{ (new WorldGenBigNetherMushroom(new Cellulos(Material.wood).setBlockName("cellulosblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)))).generate(world,random,x,world.getTopSolidOrLiquidBlock(x, z),z); //} } } } private void generateNether(World world, Random random, int chunk_X, int chunk_Z) { int x,z,y; int mushInChunk=random.nextInt(5); for(int j=0;j<mushInChunk;j++) { x=chunk_X+random.nextInt(16); z=chunk_Z+random.nextInt(16); Block block1,block2; for(int i=0;i<127;i++) { block1=world.getBlock(x,i,z); block2=world.getBlock(x,i+1,z); if(!block1.isAir(world, x, i, z)&&block2.isAir(world, x, i+1, z)) { (new WorldGenBigNetherMushroom(new Cellulos(Material.wood).setBlockName("cellulosblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)))).generate(world,random,x,i,z); } } } } } [code] [code/] package myMinecraftMod.tutorial.WorldGen; import java.util.Random; import myMinecraftMod.tutorial.Blocks.Cellulos; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenBigNetherMushroom extends WorldGenerator { private int mushroomType = -1; private static final String __OBFID = "CL_00000415"; private static Block mushBlock; public WorldGenBigNetherMushroom(Block block) { super(false); mushBlock=block; } public WorldGenBigNetherMushroom(Block block,int par1) { super(true); this.mushroomType = par1; mushBlock=block; } @Override public boolean generate(World world, Random random, int x, int y, int z) { //mushBlock=new Cellulos(); //mushBlock=new Cellulos(Material.wood).setBlockName("cellulosblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)); int stalkHeight=random.nextInt(3)+10; for(int i=1;i<0+stalkHeight;i++) { world.setBlock(x,i,z,mushBlock,1,2); } return true; } } [code] also here is my crafting code, which doesn't seem to load [code/] package myMinecraftMod.tutorial.Recipies; import myMinecraftMod.tutorial.Tutorial; import myMinecraftMod.tutorial.Blocks.Cellulos; import myMinecraftMod.tutorial.Blocks.CellulosPlank; import net.minecraft.enchantment.Enchantment; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import cpw.mods.fml.common.registry.GameRegistry; public class Crafting { public static void loadRecipes() { System.out.println("loading recipies for cellulos"); GameRegistry.addRecipe(new ItemStack(new CellulosPlank(),4), new Object[]{ "X", 'X', new Cellulos()}); } } [code]
  5. Yeah, no. Wuppy is not using dynamic blocks, he is assigning the blocks to static fields in his mod class, and notice he is registering each of them. You need to study his code better. Right. He registers his blocks in his main mod file. Same as I did. I gave the wrong link anyway. His main mod file http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-updating-1-6-to-1-7-part-2-more-modfile/ registers the blocks. Then it registers a world generator. The world generator uses the EventManager class he defines. Here are the world generator and event manager http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-updating-1-6-to-1-7-part-6-generation-finishing-it-up/ In his event manager he calls the world generator. The world generator uses a new block as a prameter. Mine has no parameters. I generated a block and initialize it in the world generator. I don't see what difference that would make. But it appears that is the only difference.
  6. Seems to be the same format Wuppy used. http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-updating-1-6-to-1-7-part-2-more-modfile/
  7. after updating to the latest version of forge, and fixing all the method names, this is what my code to place the block looks like. world.setBlock(...) is what I am using to place. package myMinecraftMod.tutorial.WorldGen; import java.util.Random; import myMinecraftMod.tutorial.Blocks.Cellulos; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenBigNetherMushroom extends WorldGenerator { private int mushroomType = -1; private static final String __OBFID = "CL_00000415"; private Block mushBlock; public WorldGenBigNetherMushroom() { super(false); } public WorldGenBigNetherMushroom(int par1) { super(true); this.mushroomType = par1; } @Override public boolean generate(World world, Random random, int x, int y, int z) { //mushBlock=new Cellulos(); mushBlock=new Cellulos(Material.wood).setBlockName("cellulosblock").setHardness(2.0F).setStepSound(new Block.SoundType("wood", 1.0F, 1.0F)); int stalkHeight=random.nextInt(3)+10; for(int i=1;i<0+stalkHeight;i++) { world.setBlock(x,i,z,mushBlock,1,2); } return true; } }
  8. Got all the method names straightened out, the mod loads again, but still doesn't place my block, just air.
  9. So I updated to the recommended version. Apparently some methods and constants had their names changed. I'm not sure where to begin correcting that. Let alone see if my code works as expected.
  10. I was following Wuppy29's tutorial, he had been using the version I listed above. I figured it should work if he was using it for his tutorials? I can upgrade and check it out when I get home.
  11. I'm using forge 1.7.2-10.12.0.997. set block isn't a valid method name.
  12. I've been trying to generate blocks in my minecraft world using func_147465_d but all it does is put an air block at the spot, not the new kind of block I was generating. Note: I have registered my blocks and they do appear in the creative tab and can be placed from inventory. Thanks
  13. When I try to register and run a class implementing IWorldGenerator minecraft crashes when loading any new chuncks. Here is how I handle the Generator code in my main mod file public static EventManager eventManager; ... @EventHandler public void preInit(FMLPreInitializationEvent event) { ... GameRegistry.registerWorldGenerator(eventManager, 0); } Here is the EventManager class I made implementing IWorldGenerator public class EventManager implements IWorldGenerator{ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case -1: generateNether(world, random, chunkX * 16, chunkZ * 16); case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16); case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16); } } private void generateEnd(World world, Random random, int x, int z) { } private void generateSurface(World world, Random random, int x, int z) { } private void generateNether(World world, Random random, int chunk_X, int chunk_Z) { } } The stack trace starts with this.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.