Posted May 9, 201312 yr Hello, I've created a mod and wanted to add my first block in it. But when I create this code: public final static Block AmethystBlock = new AmethystBlock(6543).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); It gives me errors that are weird: At my "public static CommonProxy Proxy;" it gives the error "Syntax errors on tokens, delete these tokens" And at my "public void load(FMLInitializationEvent event){" it gives 3 errors: - Syntax error on token "void", @ expected - Syntax error(s) on token(s), misplaced construct(s) - Syntax error, insert "enum Identifier" to complete EnumHeader Can someone help me please?
May 9, 201312 yr Hello, I've created a mod and wanted to add my first block in it. But when I create this code: public final static Block AmethystBlock = new AmethystBlock(6543).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); It gives me errors that are weird: At my "public static CommonProxy Proxy;" it gives the error "Syntax errors on tokens, delete these tokens" And at my "public void load(FMLInitializationEvent event){" it gives 3 errors: - Syntax error on token "void", @ expected - Syntax error(s) on token(s), misplaced construct(s) - Syntax error, insert "enum Identifier" to complete EnumHeader Can someone help me please? We can't until we see the full class... Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
May 9, 201312 yr Rather than doing it that way, which doesn't allow for a config file to change the block ID, do it the "correct" way. That and don't name your variable the same as your class name. It confuses things. public static Block amethystBlock; ... @PreInit public void preInit(FMLInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); int amethystID = config.getBlock("Amethyst", 6543).getInt(); amethystBlock = new AmethystBlock(amethystID).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); } Which might not solve your problem, as the error might be elsewhere. Also, block IDs cap at 4095. 6543 is an item ID. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 9, 201312 yr Author package mods.DennisMod.COMMON; import net.minecraft.block.Block; import net.minecraft.block.BlockOreStorage; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; 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; import net.minecraft.block.material.Material; @Mod(modid = "DennisMod",name = "Dennis' Tools", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class EmeraldMod { public final static EnumToolMaterial DENNIS = EnumHelper.addToolMaterial("DENNIS", 3, 2500, 10.0F, 6, 10); public final static EnumToolMaterial AMETHYST = EnumHelper.addToolMaterial("AMETHYST", 3, 5000, 25.0F, 15, 10); public final static Block AmethystBlock = new AmethystBlock(6543).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); public final static Item EmeraldSword = new ItemSword(6320, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldsword").setCreativeTab(CreativeTabs.tabCombat); public final static Item EmeraldPickaxe = new ItemPickaxe(6321, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldpickaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldAxe = new ItemAxe(6322, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldShovel = new ItemSpade(6323, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldshovel").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldHoe = new ItemHoe(6324, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldhoe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystSword = new ItemSword(6326, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystsword").setCreativeTab(CreativeTabs.tabCombat); public final static Item AmethystPickaxe = new ItemPickaxe(6327, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystpickaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystAxe = new ItemAxe(6328, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystShovel = new ItemSpade(6329, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystshovel").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystHoe = new ItemHoe(6330, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethysthoe").setCreativeTab(CreativeTabs.tabTools); public final static Item Amethyst = new Amethyst(6325).setUnlocalizedName("amethyst"); } @SidedProxy(clientSide = "mods.DennisMod.client.ClientProxy", serverSide = "mods.DennisMod.common.CommonProxy") public static CommonProxy Proxy; @Init public void load(FMLInitializationEvent event) { GameRegistry.registerBlock(AmethystBlock, "Amethyst.AmethystBlock"); ItemStack ema = new ItemStack(Item.emerald); ItemStack stick = new ItemStack(Item.stick); ItemStack quartz = new ItemStack(Item.netherQuartz); ItemStack ame = new ItemStack(Amethyst); GameRegistry.addRecipe(new ItemStack (EmeraldSword), "e", "e", "s", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldSword, "Emerald Sword"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldPickaxe), "eee", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldPickaxe, "Emerald Pickaxe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldAxe), "ee ", "es ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldAxe, "Emerald Axe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldShovel), " e ", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldShovel, "Emerald Shovel"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldHoe), "ee ", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldHoe, "Emerald Hoe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (Amethyst), "eqe", "qeq", "eqe", 'q', quartz, 'e', ema); LanguageRegistry.addName(Amethyst, "Amethyst"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystSword), "a", "a", "s", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystSword, "Amethyst Sword"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystPickaxe), "aaa", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystPickaxe, "Amethyst Pickaxe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystAxe), "aa ", "as ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystAxe, "Amethyst Axe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystShovel)," a ", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystShovel, "Amethyst Shovel"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystHoe), "aa ", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystHoe, "Amethyst Hoe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystBlock), "aaa", "aaa", "aaa", 'a', ame);} LanguageRegistry.addName(AmethystBlock, "Amethyst Block"); }} Full class
May 9, 201312 yr Author Rather than doing it that way, which doesn't allow for a config file to change the block ID, do it the "correct" way. That and don't name your variable the same as your class name. It confuses things. public static Block amethystBlock; ... @PreInit public void preInit(FMLInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); int amethystID = config.getBlock("Amethyst", 6543).getInt(); amethystBlock = new AmethystBlock(amethystID).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); } Which might not solve your problem, as the error might be elsewhere. Also, block IDs cap at 4095. 6543 is an item ID. If I copy that, I get an extra error with the ".getSuggestedConfigurationFile()" And there are 2 quick fixes, but I don't know if they help correctly: 1. Create method 'getSuggestedConfigurationFile()' in type 'FMLInitializationEvent' 2. Add cast to 'event'
May 9, 201312 yr package mods.DennisMod.COMMON; import net.minecraft.block.Block; import net.minecraft.block.BlockOreStorage; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; 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; import net.minecraft.block.material.Material; @Mod(modid = "DennisMod",name = "Dennis' Tools", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class EmeraldMod { public final static EnumToolMaterial DENNIS = EnumHelper.addToolMaterial("DENNIS", 3, 2500, 10.0F, 6, 10); public final static EnumToolMaterial AMETHYST = EnumHelper.addToolMaterial("AMETHYST", 3, 5000, 25.0F, 15, 10); public final static Block AmethystBlock = new AmethystBlock(6543).setHardness(5.0F).setResistance(10.0F).setUnlocalizedName("amethystblock").setCreativeTab(CreativeTabs.tabBlock); public final static Item EmeraldSword = new ItemSword(6320, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldsword").setCreativeTab(CreativeTabs.tabCombat); public final static Item EmeraldPickaxe = new ItemPickaxe(6321, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldpickaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldAxe = new ItemAxe(6322, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldShovel = new ItemSpade(6323, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldshovel").setCreativeTab(CreativeTabs.tabTools); public final static Item EmeraldHoe = new ItemHoe(6324, DENNIS).setMaxStackSize(1).setUnlocalizedName("emeraldhoe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystSword = new ItemSword(6326, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystsword").setCreativeTab(CreativeTabs.tabCombat); public final static Item AmethystPickaxe = new ItemPickaxe(6327, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystpickaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystAxe = new ItemAxe(6328, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystaxe").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystShovel = new ItemSpade(6329, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethystshovel").setCreativeTab(CreativeTabs.tabTools); public final static Item AmethystHoe = new ItemHoe(6330, AMETHYST).setMaxStackSize(1).setUnlocalizedName("amethysthoe").setCreativeTab(CreativeTabs.tabTools); public final static Item Amethyst = new Amethyst(6325).setUnlocalizedName("amethyst"); } @SidedProxy(clientSide = "mods.DennisMod.client.ClientProxy", serverSide = "mods.DennisMod.common.CommonProxy") public static CommonProxy Proxy; @Init public void load(FMLInitializationEvent event) { GameRegistry.registerBlock(AmethystBlock, "Amethyst.AmethystBlock"); ItemStack ema = new ItemStack(Item.emerald); ItemStack stick = new ItemStack(Item.stick); ItemStack quartz = new ItemStack(Item.netherQuartz); ItemStack ame = new ItemStack(Amethyst); GameRegistry.addRecipe(new ItemStack (EmeraldSword), "e", "e", "s", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldSword, "Emerald Sword"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldPickaxe), "eee", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldPickaxe, "Emerald Pickaxe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldAxe), "ee ", "es ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldAxe, "Emerald Axe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldShovel), " e ", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldShovel, "Emerald Shovel"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (EmeraldHoe), "ee ", " s ", " s ", 's', stick, 'e', ema); LanguageRegistry.addName(EmeraldHoe, "Emerald Hoe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (Amethyst), "eqe", "qeq", "eqe", 'q', quartz, 'e', ema); LanguageRegistry.addName(Amethyst, "Amethyst"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystSword), "a", "a", "s", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystSword, "Amethyst Sword"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystPickaxe), "aaa", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystPickaxe, "Amethyst Pickaxe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystAxe), "aa ", "as ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystAxe, "Amethyst Axe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystShovel)," a ", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystShovel, "Amethyst Shovel"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystHoe), "aa ", " s ", " s ", 'a', ame, 's', stick); LanguageRegistry.addName(AmethystHoe, "Amethyst Hoe"); Proxy.registerRendering(); GameRegistry.addRecipe(new ItemStack (AmethystBlock), "aaa", "aaa", "aaa", 'a', ame);} LanguageRegistry.addName(AmethystBlock, "Amethyst Block"); }} Full class public final static Item Amethyst = new Amethyst(6325).setUnlocalizedName("amethyst"); } Why is there a bracket? You close the class definition here... Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
May 9, 201312 yr Author public final static Item Amethyst = new Amethyst(6325).setUnlocalizedName("amethyst"); } Why is there a bracket? You close the class definition here... OMG that was it? Thanks, now it works again
May 9, 201312 yr If I copy that, I get an extra error with the ".getSuggestedConfigurationFile()" And there are 2 quick fixes, but I don't know if they help correctly: 1. Create method 'getSuggestedConfigurationFile()' in type 'FMLInitializationEvent' 2. Add cast to 'event' What version of Minecraft are you compiling for? Did you do the correct imports? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 9, 201312 yr Author If I copy that, I get an extra error with the ".getSuggestedConfigurationFile()" And there are 2 quick fixes, but I don't know if they help correctly: 1. Create method 'getSuggestedConfigurationFile()' in type 'FMLInitializationEvent' 2. Add cast to 'event' What version of Minecraft are you compiling for? Did you do the correct imports? 1.5.1 and yes, I imported everything that came with that line of code
May 9, 201312 yr If I copy that, I get an extra error with the ".getSuggestedConfigurationFile()" And there are 2 quick fixes, but I don't know if they help correctly: 1. Create method 'getSuggestedConfigurationFile()' in type 'FMLInitializationEvent' 2. Add cast to 'event' What version of Minecraft are you compiling for? Did you do the correct imports? 1.5.1 and yes, I imported everything that came with that line of code Well. I'm on 1.5.1 as well. So it should have worked. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.