Jump to content

[1.7.2] func_147465_d not working


ScrawnyBeast

Recommended Posts

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;

    }

}

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

 

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.

 

 

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

Stop creating new blocks!!! Just reference the block you already created in your main mod:

(new WorldGenBigNetherMushroom(Tutorial.cellulosBlock).generate(world,random,x,world.getTopSolidOrLiquidBlock(x, z),z);

Why on earth would you create a new block each time? That makes no sense, and nowhere in Wuppy's code do I see him do that.

Link to comment
Share on other sites

Look, OP. Doing it that way creates a huge chunk of memory in the dynamic heap (space in your RAM mamory) for every single 'new XYZ(...)' unless that class is trivial, which Block is not. About to time to fill one chunk of space with mushroom block, you have eaten up 16*16*(sizeof HugeMushRoomBlock) * height of blocks...

 

Yeah, a couple chunks and you are done! So, like everyone says, "Don't do that." Learn to code the minecraft way.

Link to comment
Share on other sites

It's not there because you cannot create blocks outside of preInit. Do not create a new block every time, like said many times above.

 

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This is calling a method: Tutorial.celluloseBlock()

This is referencing a static object: Tutorial.celluloseBlock

 

If you don't understand the difference between that, then please go here and learn more about Java.

 

I understand you are frustrated, but on the other hand, please understand that creating a Block is probably one of the most basic things you can do in a mod. Most 1.7 tutorials are about updating from 1.6 to 1.7, so if you don't understand how to create a basic block, I recommend you start off by modding a little for 1.6 first, just to get the hang of it, and then port your code over to 1.7 later on when you are more comfortable with not only Java, but Minecraft code in general.

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.