Posted November 2, 201311 yr Zombie Lantern name is overwriting all other lantern names. Maybe I'm missing something? ~*Blocks class*~ package lanterns.blocks; import lanterns.Reference; 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.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; public class Blocks { public static Block jackolantern; public static Block creeperlantern; public static Block zombielantern; public static void init(){ jackolantern = new BlockJackolantern(BlockIds.JACOLANTERN_ID, Material.pumpkin); GameRegistry.registerBlock(jackolantern, BlockIds.JACKOLANTERN_KEY); creeperlantern = new BlockCreeperLantern(BlockIds.CREEPER_ID, Material.pumpkin); GameRegistry.registerBlock(creeperlantern, BlockIds.CREEPER_KEY); zombielantern = new BlockZombieLantern(BlockIds.ZOMBIE_ID, Material.pumpkin); GameRegistry.registerBlock(zombielantern, BlockIds.ZOMBIE_KEY); } public static void addNames(){ LanguageRegistry.addName(jackolantern, BlockIds.JACKOLANTERN_NAME); LanguageRegistry.addName(creeperlantern, BlockIds.CREEPER_NAME); LanguageRegistry.addName(zombielantern, BlockIds.ZOMBIE_NAME); } public static void recipes(){ GameRegistry.addShapelessRecipe(new ItemStack(Blocks.jackolantern), new ItemStack(Block.pumpkinLantern), new ItemStack(Block.torchWood)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.creeperlantern), new ItemStack(Block.pumpkinLantern), new ItemStack(Item.gunpowder)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.zombielantern),new ItemStack(Block.pumpkinLantern), new ItemStack(Item.rottenFlesh)); } } ~*BlockIds*~ package lanterns.blocks; public class BlockIds { public static final String TEXTURE_LOCATION = "lanterns"; //jackolantern public static int JACOLANTERN_ID = 1000; public static final String JACKOLANTERN_UNLOCALIZED_NAME = "jackolantern"; public static final String JACKOLANTERN_KEY = "jackolantern"; public static final String JACKOLANTERN_NAME = "Jack-O-Lantern"; public static final String JACOLANTERNTOP = "jackolantern1"; public static final String JACKOLANTERNSIDE = "jackolantern2"; public static final String JACKOLANTERNFRONT = "jackolantern0"; //creeper lantern public static int CREEPER_ID = 1001; public static final String CREEPER_UNLOCALIZED_NAME = "creeperlantern"; public static final String CREEPER_KEY = "creeperlantern"; public static final String CREEPER_NAME = "Creeper Lantern"; public static final String CREEPERTOP = "creeper_top"; public static final String CREEPERSIDE = "creeper_side"; public static final String CREEPERFRONT = "creeper_front"; //ZOMBIE lantern public static int ZOMBIE_ID = 1002; public static final String ZOMBIE_UNLOCALIZED_NAME = "zombielantern"; public static final String ZOMBIE_KEY = "zombielantern"; public static final String ZOMBIE_NAME = "Zombie Lantern"; public static final String ZOMBIETOP = "zombie_top"; public static final String ZOMBIESIDE = "zombie_side"; public static final String ZOMBIEFRONT = "zombie_front"; } ~*Main Class*~ package lanterns; import lanterns.blocks.BlockJackolantern; import lanterns.blocks.Blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; 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.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = Reference.ID, name = Reference.NAME, version = Reference.VERSION) @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = Reference.CHANNEL) public class Lanterns { public static final String modid = "lanterns"; @EventHandler public void load(FMLInitializationEvent event){ Blocks.init(); Blocks.addNames(); Blocks.recipes(); } }
November 2, 201311 yr Did you set the unlocalized/ have the same unlocalized for every block? Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 2, 201311 yr Author Did you set the unlocalized/ have the same unlocalized for every block? I have separate unlocalized names in my Blockids class.
November 2, 201311 yr Can i see the Jackolantern, Creeperlantern and Zombielantern class? Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 2, 201311 yr Author Can i see the Jackolantern, Creeperlantern and Zombielantern class? Sure : Jackolantern package lanterns.blocks; import java.util.List; import lanterns.Lanterns; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockJackolantern extends BlockDirectional{ public BlockJackolantern(int id, Material material) { super(id, material.pumpkin); this.setCreativeTab(CreativeTabs.tabBlock); this.setLightValue(1F); } //icon junk @SideOnly(Side.CLIENT) private Icon topIcon; @SideOnly(Side.CLIENT) private Icon faceIcon; @SideOnly(Side.CLIENT) private Icon blockIcon; @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister register){ topIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.JACOLANTERNTOP); faceIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.JACKOLANTERNFRONT); blockIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.JACKOLANTERNSIDE); } @SideOnly(Side.CLIENT) @Override /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int side, int metadata) { if (side == 1) return this.topIcon; else if (side == 0) return this.topIcon; else if (metadata == 2 && side == 2) return this.faceIcon; else if (metadata == 3 && side == 5) return this.faceIcon; else if (metadata == 0 && side == 3) return this.faceIcon; else if (metadata == 1 && side == 4) return this.faceIcon; else return this.blockIcon; } public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int whichDirectionFacing = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(x, y, z, whichDirectionFacing, 2); } } Creeper lantern package lanterns.blocks; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockCreeperLantern extends BlockDirectional { public BlockCreeperLantern(int id, Material material){ super(id, material.pumpkin); this.setCreativeTab(CreativeTabs.tabBlock); this.setLightValue(1F); } //icon junk @SideOnly(Side.CLIENT) private Icon topIcon; @SideOnly(Side.CLIENT) private Icon faceIcon; @SideOnly(Side.CLIENT) private Icon blockIcon; @Override public void registerIcons(IconRegister register){ topIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.CREEPERTOP); faceIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.CREEPERFRONT); blockIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.CREEPERSIDE); } @SideOnly(Side.CLIENT) @Override public Icon getIcon(int side, int metadata){ if (side == 1) return this.topIcon; else if (side == 0) return this.topIcon; else if (metadata == 2 && side == 2) return this.faceIcon; else if (metadata == 3 && side == 5) return this.faceIcon; else if (metadata == 0 && side == 3) return this.faceIcon; else if (metadata == 1 && side == 4) return this.faceIcon; else return this.blockIcon; } public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int whichDirectionFacing = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(x, y, z, whichDirectionFacing, 2); } } Zombie Lantern package lanterns.blocks; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockZombieLantern extends BlockDirectional { public BlockZombieLantern (int id, Material material) { super(id, Material.pumpkin); this.setCreativeTab(CreativeTabs.tabBlock); this.setLightValue(1F); } //icon junk @SideOnly(Side.CLIENT) private Icon topIcon; @SideOnly(Side.CLIENT) private Icon faceIcon; @SideOnly(Side.CLIENT) private Icon blockIcon; @Override public void registerIcons(IconRegister register){ topIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.ZOMBIETOP); faceIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.ZOMBIEFRONT); blockIcon = register.registerIcon(BlockIds.TEXTURE_LOCATION + ":" + BlockIds.ZOMBIESIDE); } @SideOnly(Side.CLIENT) @Override public Icon getIcon(int side, int metadata){ if (side == 1) return this.topIcon; else if (side == 0) return this.topIcon; else if (metadata == 2 && side == 2) return this.faceIcon; else if (metadata == 3 && side == 5) return this.faceIcon; else if (metadata == 0 && side == 3) return this.faceIcon; else if (metadata == 1 && side == 4) return this.faceIcon; else return this.blockIcon; } public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int whichDirectionFacing = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(x, y, z, whichDirectionFacing, 2); } }
November 2, 201311 yr I seem to be having the same problem (if I'm understanding the OP correctly). I have 5 blocks. 2 of them are furnaces, so they each have a tile entity and each take up 2 ID's (one for idle, one for active). 2 others are custom crafting tables, one which has a 3x3 grid and another which has a 4x4 grid. The last is an ore which does have generation code. The ore and 1st crafting table show up with the exact same name that the 2nd crafting table has. The two furnaces are fine. Yes they all have different unlocalized names. EDIT: Nevermind, fixed it. The answer to the problem was that I had the unlocalized names in my Mod ID's class but didn't set them for some of the blocks. Just put "this.setUnlocalizedName(unlocalized name goes here)" in the constructor of each of your blocks and put the block's unlocalized name in the parentheses.
November 3, 201311 yr Author I seem to be having the same problem (if I'm understanding the OP correctly). I have 5 blocks. 2 of them are furnaces, so they each have a tile entity and each take up 2 ID's (one for idle, one for active). 2 others are custom crafting tables, one which has a 3x3 grid and another which has a 4x4 grid. The last is an ore which does have generation code. The ore and 1st crafting table show up with the exact same name that the 2nd crafting table has. The two furnaces are fine. Yes they all have different unlocalized names. EDIT: Nevermind, fixed it. The answer to the problem was that I had the unlocalized names in my Mod ID's class but didn't set them for some of the blocks. Just put "this.setUnlocalizedName(unlocalized name goes here)" in the constructor of each of your blocks and put the block's unlocalized name in the parentheses. Thank you that worked. I dont know why it worked but it did... If you know why let me know I'd love an explanation of that one.
November 3, 201311 yr Hi It worked because the LanguageRegistry uses the Block's unlocalized_name field to identify the Block. This is set by the this.setUnlocalizedName() in the Block's constructor. LanguageRegistry:: public void addNameForObject(Object objectToName, String lang, String name) { String objectName; if (objectToName instanceof Item) { objectName=((Item)objectToName).getUnlocalizedName(); } else if (objectToName instanceof Block) { objectName=((Block)objectToName).getUnlocalizedName(); } else if (objectToName instanceof ItemStack) { objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName); } else { throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName)); } objectName+=".name"; addStringLocalization(objectName, lang, name); i.e. objectName=((Block)objectToName).getUnlocalizedName(); // .... addStringLocalization(objectName, lang, name); So - if you don't set the unlocalizedname inside the Block, all three of your blocks have the same default unlocalizedname. So each time you add a new name eg LanguageRegistry.addName(jackolantern, BlockIds.JACKOLANTERN_NAME); it just overwrites the same spot in the LanguageRegistry. -TGG
November 3, 201311 yr Author so do I always set unlocalized name in the constructor regardless of block, item, tile entity, etc.?
November 3, 201311 yr so do I always set unlocalized name in the constructor regardless of block, item, tile entity, etc.? ...Yes, or it will have a default unlocalized name. If it has the default unlocalized name, then it will be identical to every other block with the default unlocalized name and that can't be uniquely localized! 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.