Jump to content

Recommended Posts

Posted

Hello, I'm new to this forum and to forge. I'm trying to port my mod onto forge whilst updating to 1.3.2. It's also the first time I've run the game from eclipse.

 

Names:

I'm trying to add names to my blocks and items, but when testing from eclipse the items and blocks have no names. I'm using the ModLoader.addName(obj, string); method. Is this a problem with testing in eclipse, 1.3.2 or is there a different way to do it with Forge?

 

Generation

I'm also trying to generate ores with my mod, and I'm using what I assume is ModLoaders generateSurface(). Is there a different way to do this in Forge again? or am I just a bad player because after two hours of looking I couldn't find anything.

 

Code:

Here is the code which contains both of these errors

package info.mineverse.Willow;

import java.util.Random;
import net.minecraft.src.Block;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumArmorMaterial;
import net.minecraft.src.EnumToolMaterial;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.ItemSword;
import net.minecraft.src.Material;
import net.minecraft.src.ModLoader;
import net.minecraft.src.World;
import net.minecraft.src.WorldGenMinable;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = "Willow", name="Willow", version="0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, versionBounds = "0.1")
public class WillowBase
{

//gem ores
public static Block oreAmethyst;
public static Block oreRuby;
public static Block oreAmber;
public static Block oreOnyx;
public static Block oreJade;
public static Block oreIolite;
public static Block oreSapphire;
public static Block oreTopaz;

//gem blocks
public static Block blockAmethyst;
public static Block blockRuby;
public static Block blockAmber;
public static Block blockOnyx;
public static Block blockJade;
public static Block blockIolite;
public static Block blockSapphire;
public static Block blockTopaz;

//gems
public static Item gemAmethyst;
public static Item gemRuby;
public static Item gemAmber;
public static Item gemOnyx;
public static Item gemJade;
public static Item gemIolite;
public static Item gemSapphire;
public static Item gemTopaz;

//enums
// - tools
static EnumToolMaterial enumAmethystTool = EnumHelper.addToolMaterial("Amethyst", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumRubyTool = EnumHelper.addToolMaterial("Ruby", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumAmberTool = EnumHelper.addToolMaterial("Amber", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumOnyxTool = EnumHelper.addToolMaterial("Onyx", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumJadeTool = EnumHelper.addToolMaterial("Jade", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumIoliteTool = EnumHelper.addToolMaterial("Iolite", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumSapphireTool = EnumHelper.addToolMaterial("Sapphire", 3, 1561, 8, 3, 10);
static EnumToolMaterial enumTopazTool = EnumHelper.addToolMaterial("Topaz", 3, 1561, 8, 3, 10);

// - armour
static EnumArmorMaterial enumAmethystArmour = EnumHelper.addArmorMaterial("Amethyst", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumRubyArmour = EnumHelper.addArmorMaterial("Ruby", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumAmberArmour = EnumHelper.addArmorMaterial("Amber", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumOnyxArmour = EnumHelper.addArmorMaterial("Onyx", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumJadeArmour = EnumHelper.addArmorMaterial("Jade", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumIoliteArmour = EnumHelper.addArmorMaterial("Iolite", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumSapphireArmour = EnumHelper.addArmorMaterial("Sapphire", 33, new int[]{3, 8, 6, 3}, 10);
static EnumArmorMaterial enumTopazArmour = EnumHelper.addArmorMaterial("Topaz", 33, new int[]{3, 8, 6, 3}, 10);

//gem tools
// - Amethyst
public static Item swordAmethyst;
public static Item pickaxeAmethyst;
public static Item spadeAmethyst;
public static Item axeAmethyst;
public static Item hoeAmethyst;

// - Ruby
public static Item swordRuby;
public static Item pickaxeRuby;
public static Item spadeRuby;
public static Item axeRuby;
public static Item hoeRuby;

// - Amber
public static Item swordAmber;
public static Item pickaxeAmber;
public static Item spadeAmber;
public static Item axeAmber;
public static Item hoeAmber;

// - Onyx
public static Item swordOnyx;
public static Item pickaxeOnyx;
public static Item spadeOnyx;
public static Item axeOnyx;
public static Item hoeOnyx;

// - Jade
public static Item swordJade;
public static Item pickaxeJade;
public static Item spadeJade;
public static Item axeJade;
public static Item hoeJade;

// - Iolite
public static Item swordIolite;
public static Item pickaxeIolite;
public static Item spadeIolite;
public static Item axeIolite;
public static Item hoeIolite;

// - Sapphire
public static Item swordSapphire;
public static Item pickaxeSapphire;
public static Item spadeSapphire;
public static Item axeSapphire;
public static Item hoeSapphire;

// - Topaz
public static Item swordTopaz;
public static Item pickaxeTopaz;
public static Item spadeTopaz;
public static Item axeTopaz;
public static Item hoeTopaz;

//gem armour
// - Amethyst
public static Item helmetAmethyst;
public static Item chestplateAmethyst;
public static Item leggingsAmethyst;
public static Item bootsAmethyst;

// - Ruby
public static Item helmetRuby;
public static Item chestplateRuby;
public static Item leggingsRuby;
public static Item bootsRuby;

// - Amber
public static Item helmetAmber;
public static Item chestplateAmber;
public static Item leggingsAmber;
public static Item bootsAmber;

// - Onyx
public static Item helmetOnyx;
public static Item chestplateOnyx;
public static Item leggingsOnyx;
public static Item bootsOnyx;

// - Jade
public static Item helmetJade;
public static Item chestplateJade;
public static Item leggingsJade;
public static Item bootsJade;

// - Iolite
public static Item helmetIolite;
public static Item chestplateIolite;
public static Item leggingsIolite;
public static Item bootsIolite;

// - Sapphire
public static Item helmetSapphire;
public static Item chestplateSapphire;
public static Item leggingsSapphire;
public static Item bootsSapphire;

// - Topaz
public static Item helmetTopaz;
public static Item chestplateTopaz;
public static Item leggingsTopaz;
public static Item bootsTopaz;

@Init
public void loadWillow(FMLInitializationEvent event)
{
	//textures
	MinecraftForgeClient.preloadTexture("/Willow/Base/BlockGems.png");
	MinecraftForgeClient.preloadTexture("/Willow/Base/ItemGems.png");

	//gem ores
	GameRegistry.registerBlock(oreAmethyst);
	GameRegistry.registerBlock(oreRuby);
	GameRegistry.registerBlock(oreAmber);
	GameRegistry.registerBlock(oreOnyx);
	GameRegistry.registerBlock(oreJade);
	GameRegistry.registerBlock(oreIolite);
	GameRegistry.registerBlock(oreSapphire);
	GameRegistry.registerBlock(oreTopaz);
	ModLoader.addName(oreAmethyst, "Amethyst Ore");
	ModLoader.addName(oreRuby, "Ruby Ore");
	ModLoader.addName(oreAmber, "Amber Ore");
	ModLoader.addName(oreOnyx, "Onyx Ore");
	ModLoader.addName(oreJade, "Jade Ore");
	ModLoader.addName(oreIolite, "Iolite Ore");
	ModLoader.addName(oreSapphire, "Sapphire Ore");
	ModLoader.addName(oreTopaz, "Topaz Ore");
	MinecraftForge.setBlockHarvestLevel(oreAmethyst, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreRuby, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreAmber, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreOnyx, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreJade, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreIolite, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreSapphire, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(oreTopaz, "pickaxe", 2);

	//gem blocks
	GameRegistry.registerBlock(blockAmethyst);
	GameRegistry.registerBlock(blockRuby);
	GameRegistry.registerBlock(blockAmber);
	GameRegistry.registerBlock(blockOnyx);
	GameRegistry.registerBlock(blockJade);
	GameRegistry.registerBlock(blockIolite);
	GameRegistry.registerBlock(blockSapphire);
	GameRegistry.registerBlock(blockTopaz);
	ModLoader.addName(blockAmethyst, "Amethyst Block");
	ModLoader.addName(blockRuby, "Ruby Block");
	ModLoader.addName(blockAmber, "Amber Block");
	ModLoader.addName(blockOnyx, "Onyx Block");
	ModLoader.addName(blockJade, "Jade Block");
	ModLoader.addName(blockIolite, "Iolite Block");
	ModLoader.addName(blockSapphire, "Sapphire Block");
	ModLoader.addName(blockTopaz, "Topaz Block");
	MinecraftForge.setBlockHarvestLevel(blockAmethyst, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockRuby, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockAmber, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockOnyx, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockJade, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockIolite, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockSapphire, "pickaxe", 2);
	MinecraftForge.setBlockHarvestLevel(blockTopaz, "pickaxe", 2);

	//gems
	ModLoader.addName(gemAmethyst, "Amethyst");
	ModLoader.addName(gemRuby, "Ruby");
	ModLoader.addName(gemAmber, "Amber");
	ModLoader.addName(gemOnyx, "Onyx");
	ModLoader.addName(gemJade, "Jade");
	ModLoader.addName(gemIolite, "Iolite");
	ModLoader.addName(gemSapphire, "Sapphire");
	ModLoader.addName(gemTopaz, "Topaz");

	//gem tools
	// - Amethyst
	ModLoader.addName(swordAmethyst, "Amethyst Sword");
	ModLoader.addName(pickaxeAmethyst, "Amethyst Pickaxe");
	ModLoader.addName(spadeAmethyst, "Amethyst Spade");
	ModLoader.addName(axeAmethyst, "Amethyst Axe");
	ModLoader.addName(hoeAmethyst, "Amethyst Hoe");

	// - Ruby
	ModLoader.addName(swordRuby, "Ruby Sword");
	ModLoader.addName(pickaxeRuby, "Ruby Pickaxe");
	ModLoader.addName(spadeRuby, "Ruby Spade");
	ModLoader.addName(axeRuby, "Ruby Axe");
	ModLoader.addName(hoeRuby, "Ruby Hoe");

	// - Amber
	ModLoader.addName(swordAmber, "Amber Sword");
	ModLoader.addName(pickaxeAmber, "Amber Pickaxe");
	ModLoader.addName(spadeAmber, "Amber Spade");
	ModLoader.addName(axeAmber, "Amber Axe");
	ModLoader.addName(hoeAmber, "Amber Hoe");

	// - Onyx
	ModLoader.addName(swordOnyx, "Onyx Sword");
	ModLoader.addName(pickaxeOnyx, "Onyx Pickaxe");
	ModLoader.addName(spadeOnyx, "Onyx Spade");
	ModLoader.addName(axeOnyx, "Onyx Axe");
	ModLoader.addName(hoeOnyx, "Onyx Hoe");

	// - Jade
	ModLoader.addName(swordJade, "Jade Sword");
	ModLoader.addName(pickaxeJade, "Jade Pickaxe");
	ModLoader.addName(spadeJade, "Jade Spade");
	ModLoader.addName(axeJade, "Jade Axe");
	ModLoader.addName(hoeJade, "Jade Hoe");

	// - Iolite
	ModLoader.addName(swordIolite, "Iolite Sword");
	ModLoader.addName(pickaxeIolite, "Iolite Pickaxe");
	ModLoader.addName(spadeIolite, "Iolite Spade");
	ModLoader.addName(axeIolite, "Iolite Axe");
	ModLoader.addName(hoeIolite, "Iolite Hoe");

	// - Sapphire
	ModLoader.addName(swordSapphire, "Sapphire Sword");
	ModLoader.addName(pickaxeSapphire, "Sapphire Pickaxe");
	ModLoader.addName(spadeSapphire, "Sapphire Spade");
	ModLoader.addName(axeSapphire, "Sapphire Axe");
	ModLoader.addName(hoeSapphire, "Sapphire Hoe");

	// - Topaz
	ModLoader.addName(swordTopaz, "Topaz Sword");
	ModLoader.addName(pickaxeTopaz, "Topaz Pickaxe");
	ModLoader.addName(spadeTopaz, "Topaz Spade");
	ModLoader.addName(axeTopaz, "Topaz Axe");
	ModLoader.addName(hoeTopaz, "Topaz Hoe");

	//Crafting Recipes
	// - Gems2Gemblock
	// - - Amethyst
	GameRegistry.addRecipe(new ItemStack(blockAmethyst, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemAmethyst
        });

	// - - Ruby
	GameRegistry.addRecipe(new ItemStack(blockRuby, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemRuby
        });

	// - - Amber
	GameRegistry.addRecipe(new ItemStack(blockAmber, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemAmber
        });

	// - - Onyx
	GameRegistry.addRecipe(new ItemStack(blockOnyx, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemOnyx
        });

	// - - Jade
	GameRegistry.addRecipe(new ItemStack(blockJade, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemJade
        });

	// - - Iolite
	GameRegistry.addRecipe(new ItemStack(blockIolite, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemIolite
        });

	// - - Sapphire
	GameRegistry.addRecipe(new ItemStack(blockSapphire, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemSapphire
        });

	// - - Topaz
	GameRegistry.addRecipe(new ItemStack(blockTopaz, 1), new Object[]
                {
            "###", "###", "###", Character.valueOf('#'), gemTopaz
        });

	// - blockblock2Gems
	// - - Amethyst
	GameRegistry.addRecipe(new ItemStack(gemAmethyst, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockAmethyst
        });

	// - - Ruby
	GameRegistry.addRecipe(new ItemStack(gemRuby, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockRuby
        });

	// - - Amber
	GameRegistry.addRecipe(new ItemStack(gemAmber, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockAmber
        });

	// - - Onyx
	GameRegistry.addRecipe(new ItemStack(gemOnyx, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockOnyx
        });

	// - - Jade
	GameRegistry.addRecipe(new ItemStack(gemJade, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockJade
        });

	// - - Iolite
	GameRegistry.addRecipe(new ItemStack(gemIolite, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockIolite
        });

	// - - Sapphire
	GameRegistry.addRecipe(new ItemStack(gemSapphire, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockSapphire
        });

	// - - Topaz
	GameRegistry.addRecipe(new ItemStack(gemTopaz, 9), new Object[]
                {
            "#", Character.valueOf('#'), blockTopaz
        });
}

    public void generateSurface(World world, Random random, int i, int j)
    {
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreAmethyst.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreRuby.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreAmber.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreOnyx.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreJade.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreIolite.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreSapphire.blockID, 3)).generate(world, random, l1, i3, j4);
        }
        for (int k = 0; k < 1; k++)
        {
            int l1 = i + random.nextInt(16);
            int i3 = random.nextInt(16);
            int j4 = j + random.nextInt(16);
            (new WorldGenMinable(oreTopaz.blockID, 3)).generate(world, random, l1, i3, j4);
        }
    }

static
{
	//gem ores
	oreAmethyst = (new WillowBlockOre(225, 0)).setBlockName("AmethystOre");
	oreRuby = (new WillowBlockOre(226, 1)).setBlockName("RubyOre");
	oreAmber = (new WillowBlockOre(227, 2)).setBlockName("AmberOre");
	oreOnyx = (new WillowBlockOre(228, 3)).setBlockName("OnyxOre");
	oreJade = (new WillowBlockOre(229, 4)).setBlockName("JadeOre");
	oreIolite = (new WillowBlockOre(230, 5)).setBlockName("IoliteOre");
	oreSapphire = (new WillowBlockOre(231, 6)).setBlockName("SapphireOre");
	oreTopaz = (new WillowBlockOre(232, 7)).setBlockName("TopazOre");

	//gem blocks
	blockAmethyst = (new WillowBlockStorage(233, ).setBlockName("AmethystBlock");
	blockRuby = (new WillowBlockStorage(234, 9)).setBlockName("RubyBlock");
	blockAmber = (new WillowBlockStorage(235, 10)).setBlockName("AmberBlock");
	blockOnyx = (new WillowBlockStorage(236, 11)).setBlockName("OnyxBlock");
	blockJade = (new WillowBlockStorage(237, 12)).setBlockName("JadeBlock");
	blockIolite = (new WillowBlockStorage(238, 13)).setBlockName("IoliteBlock");
	blockSapphire = (new WillowBlockStorage(239, 14)).setBlockName("SapphireBlock");
	blockTopaz = (new WillowBlockStorage(240, 15)).setBlockName("TopazBlock");

	//gems
	gemAmethyst = (new WillowItemGem(1000, 144)).setItemName("Amethyst");
	gemRuby = (new WillowItemGem(1001, 145)).setItemName("Ruby");
	gemAmber = (new WillowItemGem(1002, 146)).setItemName("Amber");
	gemOnyx = (new WillowItemGem(1003, 147)).setItemName("Onyx");
	gemJade = (new WillowItemGem(1004, 148)).setItemName("Jade");
	gemIolite = (new WillowItemGem(1005, 149)).setItemName("Iolite");
	gemSapphire = (new WillowItemGem(1006, 150)).setItemName("Sapphire");
	gemTopaz = (new WillowItemGem(1007, 151)).setItemName("Topaz");

	//gem tools
	// - Amethyst
	swordAmethyst = (new WillowItemSword(1008, 64, enumAmethystTool)).setItemName("AmethystSword");
	pickaxeAmethyst = (new WillowItemPickaxe(1009, 96, enumAmethystTool)).setItemName("AmethystPickaxe");
	spadeAmethyst = (new WillowItemSpade(1010, 80, enumAmethystTool)).setItemName("AmethystPickaxe");
	axeAmethyst = (new WillowItemAxe(1011, 112, enumAmethystTool)).setItemName("AmethystAxe");
	hoeAmethyst = (new WillowItemHoe(1012, 128, enumAmethystTool)).setItemName("AmethystHoe");

	// - Ruby
	swordRuby = (new WillowItemSword(1013, 65, enumRubyTool)).setItemName("RubySword");
	pickaxeRuby = (new WillowItemPickaxe(1014, 97, enumRubyTool)).setItemName("RubyPickaxe");
	spadeRuby = (new WillowItemSpade(1015, 81, enumRubyTool)).setItemName("RubyPickaxe");
	axeRuby = (new WillowItemAxe(1016, 113, enumRubyTool)).setItemName("RubyAxe");
	hoeRuby = (new WillowItemHoe(1017, 129, enumRubyTool)).setItemName("RubyHoe");

	// - Amber
	swordAmber = (new WillowItemSword(1018, 66, enumAmberTool)).setItemName("AmberSword");
	pickaxeAmber = (new WillowItemPickaxe(1019, 98, enumAmberTool)).setItemName("AmberPickaxe");
	spadeAmber = (new WillowItemSpade(1020, 82, enumAmberTool)).setItemName("AmberPickaxe");
	axeAmber = (new WillowItemAxe(1021, 114, enumAmberTool)).setItemName("AmberAxe");
	hoeAmber = (new WillowItemHoe(1022, 130, enumAmberTool)).setItemName("AmberHoe");

	// - Onyx
	swordOnyx = (new WillowItemSword(1023, 67, enumOnyxTool)).setItemName("OnyxSword");
	pickaxeOnyx = (new WillowItemPickaxe(1024, 99, enumOnyxTool)).setItemName("OnyxPickaxe");
	spadeOnyx = (new WillowItemSpade(1025, 83, enumOnyxTool)).setItemName("OnyxPickaxe");
	axeOnyx = (new WillowItemAxe(1026, 115, enumOnyxTool)).setItemName("OnyxAxe");
	hoeOnyx = (new WillowItemHoe(1027, 131, enumOnyxTool)).setItemName("OnyxHoe");

	// - Jade
	swordJade = (new WillowItemSword(1028, 68, enumJadeTool)).setItemName("JadeSword");
	pickaxeJade = (new WillowItemPickaxe(1029, 100, enumJadeTool)).setItemName("JadePickaxe");
	spadeJade = (new WillowItemSpade(1030, 84, enumJadeTool)).setItemName("JadePickaxe");
	axeJade = (new WillowItemAxe(1031, 116, enumJadeTool)).setItemName("JadeAxe");
	hoeJade = (new WillowItemHoe(1032, 132, enumJadeTool)).setItemName("JadeHoe");

	// - Iolite
	swordIolite = (new WillowItemSword(1033, 69, enumIoliteTool)).setItemName("IoliteSword");
	pickaxeIolite = (new WillowItemPickaxe(1034, 101, enumIoliteTool)).setItemName("IolitePickaxe");
	spadeIolite = (new WillowItemSpade(1035, 85, enumIoliteTool)).setItemName("IolitePickaxe");
	axeIolite = (new WillowItemAxe(1036, 117, enumIoliteTool)).setItemName("IoliteAxe");
	hoeIolite = (new WillowItemHoe(1037, 133, enumIoliteTool)).setItemName("IoliteHoe");

	// - Sapphire
	swordSapphire = (new WillowItemSword(1038, 70, enumSapphireTool)).setItemName("SapphireSword");
	pickaxeSapphire = (new WillowItemPickaxe(1039, 102, enumSapphireTool)).setItemName("SapphirePickaxe");
	spadeSapphire = (new WillowItemSpade(1040, 86, enumSapphireTool)).setItemName("SapphirePickaxe");
	axeSapphire = (new WillowItemAxe(1041, 118, enumSapphireTool)).setItemName("SapphireAxe");
	hoeSapphire = (new WillowItemHoe(1042, 134, enumSapphireTool)).setItemName("SapphireHoe");

	// - Topaz
	swordTopaz = (new WillowItemSword(1043, 71, enumTopazTool)).setItemName("TopazSword");
	pickaxeTopaz = (new WillowItemPickaxe(1044, 103, enumTopazTool)).setItemName("TopazPickaxe");
	spadeTopaz = (new WillowItemSpade(1045, 87, enumTopazTool)).setItemName("TopazPickaxe");
	axeTopaz = (new WillowItemAxe(1046, 119, enumTopazTool)).setItemName("TopazAxe");
	hoeTopaz = (new WillowItemHoe(1047, 135, enumTopazTool)).setItemName("TopazHoe");

	//gem armour
	// - Amethyst
	helmetAmethyst = (new WillowItemArmor(1048, 0, enumAmethystArmour, 6, 0)).setItemName("AmethystHelmet");
	chestplateAmethyst = (new WillowItemArmor(1049, 16, enumAmethystArmour, 6, 1)).setItemName("AmethystChestplate");
	leggingsAmethyst = (new WillowItemArmor(1050, 32, enumAmethystArmour, 6, 2)).setItemName("AmethystLeggings");
	bootsAmethyst = (new WillowItemArmor(1051, 48, enumAmethystArmour, 6, 3)).setItemName("AmethystBoots");

	// - Ruby
	helmetRuby = (new WillowItemArmor(1052, 1, enumRubyArmour, 7, 0)).setItemName("RubyHelmet");
	chestplateRuby = (new WillowItemArmor(1053, 17, enumRubyArmour, 7, 1)).setItemName("RubyChestplate");
	leggingsRuby = (new WillowItemArmor(1054, 33, enumRubyArmour, 7, 2)).setItemName("RubyLeggings");
	bootsRuby = (new WillowItemArmor(1055, 49, enumRubyArmour, 7, 3)).setItemName("RubyBoots");

	// - Amber
	helmetAmber = (new WillowItemArmor(1056, 2, enumAmberArmour, 8, 0)).setItemName("AmberHelmet");
	chestplateAmber = (new WillowItemArmor(1057, 18, enumAmberArmour, 8, 1)).setItemName("AmberChestplate");
	leggingsAmber = (new WillowItemArmor(1058, 34, enumAmberArmour, 8, 2)).setItemName("AmberLeggings");
	bootsAmber = (new WillowItemArmor(1059, 50, enumAmberArmour, 8, 3)).setItemName("AmberBoots");

	// - Onyx
	helmetOnyx = (new WillowItemArmor(1060, 3, enumOnyxArmour, 9, 0)).setItemName("OnyxHelmet");
	chestplateOnyx = (new WillowItemArmor(1061, 19, enumOnyxArmour, 9, 1)).setItemName("OnyxChestplate");
	leggingsOnyx = (new WillowItemArmor(1062, 35, enumOnyxArmour, 9, 2)).setItemName("OnyxLeggings");
	bootsOnyx = (new WillowItemArmor(1063, 51, enumOnyxArmour, 9, 3)).setItemName("OnyxBoots");

	// - Jade
	helmetJade = (new WillowItemArmor(1064, 4, enumJadeArmour, 10, 0)).setItemName("JadeHelmet");
	chestplateJade = (new WillowItemArmor(1065, 20, enumJadeArmour, 10, 1)).setItemName("JadeChestplate");
	leggingsJade = (new WillowItemArmor(1066, 36, enumJadeArmour, 10, 2)).setItemName("JadeLeggings");
	bootsJade = (new WillowItemArmor(1067, 52, enumJadeArmour, 10, 3)).setItemName("JadeBoots");

	// - Iolite
	helmetIolite = (new WillowItemArmor(1068, 5, enumIoliteArmour, 11, 0)).setItemName("IoliteHelmet");
	chestplateIolite = (new WillowItemArmor(1069, 21, enumIoliteArmour, 11, 1)).setItemName("IoliteChestplate");
	leggingsIolite = (new WillowItemArmor(1070, 37, enumIoliteArmour, 11, 2)).setItemName("IoliteLeggings");
	bootsIolite = (new WillowItemArmor(1071, 53, enumIoliteArmour, 11, 3)).setItemName("IoliteBoots");

	// - Sapphire
	helmetSapphire = (new WillowItemArmor(1072, 6, enumSapphireArmour, 12, 0)).setItemName("SapphireHelmet");
	chestplateSapphire = (new WillowItemArmor(1073, 22, enumSapphireArmour, 12, 1)).setItemName("SapphireChestplate");
	leggingsSapphire = (new WillowItemArmor(1074, 38, enumSapphireArmour, 12, 2)).setItemName("SapphireLeggings");
	bootsSapphire = (new WillowItemArmor(1075, 54, enumSapphireArmour, 12, 3)).setItemName("SapphireBoots");

	// - Topaz
	helmetTopaz = (new WillowItemArmor(1076, 7, enumTopazArmour, 13, 0)).setItemName("TopazHelmet");
	chestplateTopaz = (new WillowItemArmor(1077, 23, enumTopazArmour, 13, 1)).setItemName("TopazChestplate");
	leggingsTopaz = (new WillowItemArmor(1078, 39, enumTopazArmour, 13, 2)).setItemName("TopazLeggings");
	bootsTopaz = (new WillowItemArmor(1079, 55, enumTopazArmour, 13, 3)).setItemName("TopazBoots");
}
}

Posted

I believe .setBlockName requires the first letter to be lower case, but I could be wrong.

oreAmethyst = (new WillowBlockOre(225, 0)).setBlockName("amethystOre");

 

NOTE: The following code enables you to remove ModLoader.addName but functions exactly the same

If you want to remove ModLoader.addName your new code would look like:

LanguageRegistry.instance().addNameForObject(oreAmethyst, "en_US", "Amethyst Ore");

 

Or you can make your own addName and just remove "ModLoader."

private void addName(Object objectToName, String inGameName)
{
    LanguageRegistry.instance().addNameForObject(objectToName, "en_US", inGameName);
}

 

 

As for generation,

I'll give the code to put it in its own class file, personally I find this to be less cluttered when you are generating many things.

If you wish to have it in your main class file minimal changes are needed.

 

First you'll need this line (after your textures but before registering your ores looks like a good spot)

GameRegistry.registerWorldGenerator(new WorldGenerator());

 

Next a new class file WorldGenerator.class

public class WorldGenerator implements IWorldGenerator
{
    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        switch (world.provider.worldType)
        {
            case -1:
                generateNether(world, random, chunkX*16, chunkZ*16); //Forge provides true chunk coordinates, while ModLoader provides block coordinates and calls them chunkX & chunkZ
                break;
            case 0:
                generateSurface(world, random, chunkX*16, chunkZ*16); //To make these values the same as ModLoader they need to be multiplied by 16
                break;
        }
    }

    public void generateSurface(World world, Random random, int blockX, int blockZ)
    {
        // TODO Your code here
    }

    public void generateNether(World world, Random random, int blockX, int blockZ)
    {
        // TODO Your code here
    }
}

Posted

wow em i do not work with forge at the moment. but there are a lot of tutorials for the basement. i use them to check my code. check it out. www.minecraftforum.net/topic/929151-moddingmodloaderforge-api-jotamotas-tutorials/ this is a tut about metadata items and blocks with and without forge. Thir is for textures. i hope it help.

Crazy Brain...

Posted

I believe .setBlockName requires the first letter to be lower case, but I could be wrong.

oreAmethyst = (new WillowBlockOre(225, 0)).setBlockName("amethystOre");

 

NOTE: The following code enables you to remove ModLoader.addName but functions exactly the same

If you want to remove ModLoader.addName your new code would look like:

LanguageRegistry.instance().addNameForObject(oreAmethyst, "en_US", "Amethyst Ore");

 

Or you can make your own addName and just remove "ModLoader."

private void addName(Object objectToName, String inGameName)
{
    LanguageRegistry.instance().addNameForObject(objectToName, "en_US", inGameName);
}

 

 

As for generation,

I'll give the code to put it in its own class file, personally I find this to be less cluttered when you are generating many things.

If you wish to have it in your main class file minimal changes are needed.

 

First you'll need this line (after your textures but before registering your ores looks like a good spot)

GameRegistry.registerWorldGenerator(new WorldGenerator());

 

Next a new class file WorldGenerator.class

public class WorldGenerator implements IWorldGenerator
{
    @Override
    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
    {
        switch (world.provider.worldType)
        {
            case -1:
                generateNether(world, random, chunkX*16, chunkZ*16); //Forge provides true chunk coordinates, while ModLoader provides block coordinates and calls them chunkX & chunkZ
                break;
            case 0:
                generateSurface(world, random, chunkX*16, chunkZ*16); //To make these values the same as ModLoader they need to be multiplied by 16
                break;
        }
    }

    public void generateSurface(World world, Random random, int blockX, int blockZ)
    {
        // TODO Your code here
    }

    public void generateNether(World world, Random random, int blockX, int blockZ)
    {
        // TODO Your code here
    }
}

 

With the naming, will it only apply for English(US), as I use English(UK) that was my only concern with that

Posted

ModLoader.addName also sets it to "en_US"

 

This is untested but might work for you

private void addName(Object objectToName, String inGameName)
{
    LanguageRegistry.instance().addNameForObject(objectToName, "en_US", inGameName);
    LanguageRegistry.instance().addNameForObject(objectToName, "en_UK", inGameName);
}

Posted

All of the names work with ModLoader.addName(object, string) as of the new Forge update

 

EDIT:

The armour names have not worked (I have also put .setItem/BlockName to camelCase for all blocks/items)

 

EDIT:

Neither do they render when worn.

 

EDIT:

Armour code:

 

package info.mineverse.willow.common;

import net.minecraft.src.EnumArmorMaterial;
import net.minecraft.src.ItemArmor;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;

public class WillowItemArmor extends ItemArmor implements IArmorTextureProvider
{
public WillowItemArmor(int par1, int par2, EnumArmorMaterial par3EnumArmorMaterial, int par4, int par5)
{
	super(par1, par3EnumArmorMaterial, par4, par5);
	setIconIndex(par2);
}

@Override
public String getTextureFile()
{
	return "/Willow/Base/ItemGems.png";
}

@Override
public String getArmorTextureFile(ItemStack itemstack)
{
	//Amethyst
	if(itemstack.itemID == WillowBase.helmetAmethyst.shiftedIndex || itemstack.itemID == WillowBase.chestplateAmethyst.shiftedIndex || itemstack.itemID == WillowBase.bootsAmethyst.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Amethyst_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsAmethyst.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Amethyst_2.png";
        }
        
	//Ruby
	if(itemstack.itemID == WillowBase.helmetRuby.shiftedIndex || itemstack.itemID == WillowBase.chestplateRuby.shiftedIndex || itemstack.itemID == WillowBase.bootsRuby.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Ruby_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsRuby.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Ruby_2.png";
        }
        
	//Amber
	if(itemstack.itemID == WillowBase.helmetAmber.shiftedIndex || itemstack.itemID == WillowBase.chestplateAmber.shiftedIndex || itemstack.itemID == WillowBase.bootsAmber.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Amber_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsAmber.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Amber_2.png";
        }
        
	//Onyx
	if(itemstack.itemID == WillowBase.helmetOnyx.shiftedIndex || itemstack.itemID == WillowBase.chestplateOnyx.shiftedIndex || itemstack.itemID == WillowBase.bootsOnyx.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Onyx_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsOnyx.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Onyx_2.png";
        }
        
	//Jade
	if(itemstack.itemID == WillowBase.helmetJade.shiftedIndex || itemstack.itemID == WillowBase.chestplateJade.shiftedIndex || itemstack.itemID == WillowBase.bootsJade.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Jade_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsJade.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Jade_2.png";
        }
        
	//Iolite
	if(itemstack.itemID == WillowBase.helmetIolite.shiftedIndex || itemstack.itemID == WillowBase.chestplateIolite.shiftedIndex || itemstack.itemID == WillowBase.bootsIolite.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Iolite_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsIolite.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Iolite_2.png";
        }
        
	//Sapphire
	if(itemstack.itemID == WillowBase.helmetSapphire.shiftedIndex || itemstack.itemID == WillowBase.chestplateSapphire.shiftedIndex || itemstack.itemID == WillowBase.bootsSapphire.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Sapphire_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsSapphire.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Sapphire_2.png";
        }
        
	//Topaz
	if(itemstack.itemID == WillowBase.helmetTopaz.shiftedIndex || itemstack.itemID == WillowBase.chestplateTopaz.shiftedIndex || itemstack.itemID == WillowBase.bootsTopaz.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Topaz_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsTopaz.shiftedIndex)
        {
        	return "/Willow/Base/Armor/Topaz_2.png";
        }
        
        else
        {
        	return null;
        }
}
}

 

 

EDIT:

The ore generation works now, thanks!

 

EDIT:

Noticed the armour was never assigned a name, derp

Posted

I've only added a single Amulet and it was in the armor directory and didn't use IArmorTextureProvider, so I won't be of much use but;

 

Have you tried throwing some system.out 's in to see if the textures are ever being returned, rather then returning null each time?

 

 

Posted

I think only one other way but i do not know if that work. make your own armor folder. and put ther your textures. if that do not work than i have no idea. i need help to.

Crazy Brain...

Posted

I've not layed it out as so;

 

	@Override
public String getArmorTextureFile(ItemStack itemstack)
{
	//Amethyst
	if(itemstack.itemID == WillowBase.helmetAmethyst.shiftedIndex || itemstack.itemID == WillowBase.chestplateAmethyst.shiftedIndex || itemstack.itemID == WillowBase.bootsAmethyst.shiftedIndex)
        {
        	return "amethyst_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsAmethyst.shiftedIndex)
        {
        	return "amethyst_2.png";
        }
        
	//Ruby
	if(itemstack.itemID == WillowBase.helmetRuby.shiftedIndex || itemstack.itemID == WillowBase.chestplateRuby.shiftedIndex || itemstack.itemID == WillowBase.bootsRuby.shiftedIndex)
        {
        	return "ruby_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsRuby.shiftedIndex)
        {
        	return "ruby_2.png";
        }
        
	//Amber
	if(itemstack.itemID == WillowBase.helmetAmber.shiftedIndex || itemstack.itemID == WillowBase.chestplateAmber.shiftedIndex || itemstack.itemID == WillowBase.bootsAmber.shiftedIndex)
        {
        	return "amber_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsAmber.shiftedIndex)
        {
        	return "amber_2.png";
        }
        
	//Onyx
	if(itemstack.itemID == WillowBase.helmetOnyx.shiftedIndex || itemstack.itemID == WillowBase.chestplateOnyx.shiftedIndex || itemstack.itemID == WillowBase.bootsOnyx.shiftedIndex)
        {
        	return "onyx_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsOnyx.shiftedIndex)
        {
        	return "onyx_2.png";
        }
        
	//Jade
	if(itemstack.itemID == WillowBase.helmetJade.shiftedIndex || itemstack.itemID == WillowBase.chestplateJade.shiftedIndex || itemstack.itemID == WillowBase.bootsJade.shiftedIndex)
        {
        	return "jade_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsJade.shiftedIndex)
        {
        	return "jade_2.png";
        }
        
	//Iolite
	if(itemstack.itemID == WillowBase.helmetIolite.shiftedIndex || itemstack.itemID == WillowBase.chestplateIolite.shiftedIndex || itemstack.itemID == WillowBase.bootsIolite.shiftedIndex)
        {
        	return "iolite_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsIolite.shiftedIndex)
        {
        	return "iolite_2.png";
        }
        
	//Sapphire
	if(itemstack.itemID == WillowBase.helmetSapphire.shiftedIndex || itemstack.itemID == WillowBase.chestplateSapphire.shiftedIndex || itemstack.itemID == WillowBase.bootsSapphire.shiftedIndex)
        {
        	return "sapphire_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsSapphire.shiftedIndex)
        {
        	return "sapphire_2.png";
        }
        
	//Topaz
	if(itemstack.itemID == WillowBase.helmetTopaz.shiftedIndex || itemstack.itemID == WillowBase.chestplateTopaz.shiftedIndex || itemstack.itemID == WillowBase.bootsTopaz.shiftedIndex)
        {
        	return "topaz_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsTopaz.shiftedIndex)
        {
        	return "topaz_2.png";
        }
        
        else
        {
        	return null;
        }
}

 

 

with the armour images in the /armor folder. However, this still does not work for me.

Posted

preloaded the textures:

		MinecraftForgeClient.preloadTexture("/Willow/Base/Armor/amethyst_1.png");
	MinecraftForgeClient.preloadTexture("/Willow/Base/Armor/amethyst_2.png");

In the armor file:

	@Override
public String getArmorTextureFile(ItemStack itemstack)
{
	//Amethyst
	if(itemstack.itemID == WillowBase.helmetAmethyst.shiftedIndex || itemstack.itemID == WillowBase.chestplateAmethyst.shiftedIndex || itemstack.itemID == WillowBase.bootsAmethyst.shiftedIndex)
        {
        	return "/Willow/Base/Armor/amethyst_1.png";
        }
        if(itemstack.itemID == WillowBase.leggingsAmethyst.shiftedIndex)
        {
        	return "/Willow/Base/Armor/amethyst_2.png";
        }
}

 

The problem I was having is that the armour wasn't registered as a render, so I had to register it;

helmetAmethyst = (new WillowItemArmor(1048, 0, enumAmethystArmour, ModLoader.addArmor("Amethyst"), 0)).setItemName("amethystHelmet");

Posted

Cool. (i mean that you solve it). thanks to release a little of your code you help me a lot with your enum tools material. i had no clue how to make it in a mod.

Crazy Brain...

Posted

When defining your blocks, you also need to make the enum as so;

static EnumToolMaterial enumAmethystTool = EnumHelper.addToolMaterial("Amethyst", 3, 1561, 8, 3, 10);

 

and then it's included in the tool as so;

swordAmethyst = (new WillowItemSword(1008, 64, enumAmethystTool)).setItemName("amethystSword");

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.