JimiIT92 Posted January 29, 2014 Share Posted January 29, 2014 Hi everybody! I have a simple question for you I'm trying to update my mod to 1.7.2 but i can't even add a simple block! D: I'm trying to add a new ore but it seems that the code doesn't work, in fact in game there isn't my block. This is my main mod file package MineWorld; import MineWorld.blocks.BlockOreMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.util.RegistryNamespaced; 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.GameData; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = main.MODID, version = main.VERSION) public class main { public static final String MODID = "mineworld"; public static final String VERSION = "0.3"; //Blocks public static Block oreRuby; @EventHandler public void preInit(FMLPreInitializationEvent event) { oreRuby = (new BlockOreMod(1000).func_149711_c(3.0F).func_149711_c(5.0F).func_149672_a(Block.field_149769_e).func_149663_c("oreRuby").func_149658_d(MODID + ":" + "oreRuby")); } @EventHandler public void init(FMLInitializationEvent event) { GameRegistry.registerBlock(oreRuby, "oreRuby"); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } and this is the BlockOreMod file package MineWorld.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockOreMod extends Block { public BlockOreMod(int par1) { super(Material.field_151576_e); this.func_149647_a(CreativeTabs.tabBlock); } /** * Returns the ID of the items to drop on destruction. */ public Item func_149650_a(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.func_150898_a(this); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { /*return this.blockID == mod_ores.main.oreRuby.blockID ? 1 + par1Random.nextInt(3) : (this.blockID == mod_ores.main.oreSapphire.blockID ? 1 + par1Random.nextInt(3) : (this.blockID == mod_ores.main.orePyrite.blockID ? 4 + par1Random.nextInt(5) : 1));*/ return 1; } /** * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive). */ public int func_149679_a(int p_149679_1_, Random p_149679_2_) { if (p_149679_1_ > 0 && Item.func_150898_a(this) != this.func_149650_a(0, p_149679_2_, p_149679_1_)) { int j = p_149679_2_.nextInt(p_149679_1_ + 2) - 1; if (j < 0) { j = 0; } return this.func_149745_a(p_149679_2_) * (j + 1); } else { return this.func_149745_a(p_149679_2_); } } /** * Drops the block items with a specified chance of dropping the specified items */ private Random rand = new Random(); @Override public int getExpDrop(IBlockAccess p_149690_1_, int p_149690_5_, int p_149690_7_) { if (this.func_149650_a(p_149690_5_, rand, p_149690_7_) != Item.func_150898_a(this)) { int j1 = 0; if (this == MineWorld.main.oreRuby) { j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7); } return j1; } return 0; } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ public int damageDropped(int par1) { return 0; } } Thanks for who will help me Quote Don't blame me if i always ask for your help. I just want to learn to be better Link to comment Share on other sites More sharing options...
GotoLink Posted January 29, 2014 Share Posted January 29, 2014 Dude, register the block in FMLPreInit stage. This is standard since 1.5 at least. Quote Link to comment Share on other sites More sharing options...
JimiIT92 Posted January 29, 2014 Author Share Posted January 29, 2014 I know, but i've tried to make it in the init function because it doesn't work in pre init method, i've already a 1.6.4 version of the mod, i know where all things go but it seems that is wrong in 1.7 EDIT: I've changed it again right now and it worked O_O and so yes, i'm a stupid (doh!). Aniway, why the id of this block is 165 and not 1000 like i specify? Quote Don't blame me if i always ask for your help. I just want to learn to be better Link to comment Share on other sites More sharing options...
JimiIT92 Posted January 29, 2014 Author Share Posted January 29, 2014 So there is not the problem to make the mistake to give same id to different blocks? The game itself assigns an automatic id to the blocks? Edit: cool, the Ore Ruby has already a translated name in the game O_O I'm italian, i didn't added a translation method yet, but i see the ore name in italian, not tile.oreRuby.name but "Rubino Grezzo", "Ruby Ore" in english. Lol. Also it seems like i've supposed, the game itself give an unique id to the blocks, wich is really cool. Thanks for help me, i'll close this post Quote Don't blame me if i always ask for your help. I just want to learn to be better Link to comment Share on other sites More sharing options...
Recommended Posts
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.