Awesome_Spider Posted March 31, 2015 Share Posted March 31, 2015 I made some blocks, most of which will be used to generate a structure. I added them to the lang file, added textures for them, and added them to my Creative Tab. I then ran it to build the structure (I like laying out generated structures before adding the code) and opened up the Creative Tab. No textures: The blocks not working are BlockThatch, BlockSmoothSandstone, BlockTurnedPlanksBirch, BlockTurnedPlanksOak, and BlockGranite. But I clearly have the files in there: Here is the code: Main class: @Mod(modid = SignificantAdvancements.MODID, version = SignificantAdvancements.VERSION, name = SignificantAdvancements.NAME) public class SignificantAdvancements { public static final String MODID = "significantadvancements"; public static final String NAME = "Significant Advancements"; public static final String VERSION = "0.0.1"; @SidedProxy(clientSide = "awesomespider.significantAdvancements.ClientProxy", serverSide = "awesomespider.significantAdvancements.CommonProxy") public static CommonProxy proxy; public static File configFile; public static Configuration config; //The Dismantler's State as Specified by the Config (on or off) public static boolean dismantlerState; public static File dataFolder; public static MaterialsCreativeTab materialsTab; public static Block blockGranite; public static Block blockSmoothSandstone; public static Block blockThatch; public static Block blockTurnedPlanksBirch; public static Block blockTurnedPlanksOak; public static Item magicalBook; public static Enchantment shadowsBane; public static Logger log; @EventHandler public void preinit(FMLPreInitializationEvent event){ LangRegistry.retrieveEntries(); event.getModLog().info("[significant Advancements] " + LangRegistry.langEntries.get("log.preinit.text")); dataFolder = event.getModConfigurationDirectory(); //Initialize the config configFile = event.getSuggestedConfigurationFile(); config = new Configuration(configFile); log = event.getModLog(); materialsTab = new MaterialsCreativeTab("Significant Advancements Materials"); blockGranite = new BlockGranite(Material.rock); blockSmoothSandstone = new BlockSmoothSandstone(Material.rock); blockThatch = new BlockThatch(Material.leaves); //TODO Find out what Hay's material really is. blockTurnedPlanksBirch = new BlockTurnedPlanksBirch(Material.wood); blockTurnedPlanksOak = new BlockTurnedPlanksOak(Material.wood); magicalBook = new MagicalBook("item.magicalBook.name", 1, MODID + ":magicalBook"); shadowsBane = new EnchantmentShadowsBane(100, 10); } @EventHandler public void init(FMLInitializationEvent event){ log.info("[significant Advancements] " + LangRegistry.langEntries.get("log.init.text")); GameRegistry.registerItem(magicalBook, magicalBook.getUnlocalizedName(), MODID); GameRegistry.registerBlock(blockGranite, ItemBlockGranite.class, blockGranite.getLocalizedName()); GameRegistry.registerBlock(blockSmoothSandstone, blockSmoothSandstone.getUnlocalizedName()); GameRegistry.registerBlock(blockThatch, blockThatch.getUnlocalizedName()); GameRegistry.registerBlock(blockTurnedPlanksBirch, blockTurnedPlanksBirch.getUnlocalizedName()); GameRegistry.registerBlock(blockTurnedPlanksOak, blockTurnedPlanksOak.getUnlocalizedName()); //Render KeyInputHandler FMLCommonHandler.instance().bus().register(new KeyInputHandler()); //Load the config config.load(); config.get(Configuration.CATEGORY_GENERAL, "dismantler", true).comment = "If you want the dismantler mechanic turned on, leave this as is. If you want it off (rarly wanted ), change this to false."; dismantlerState = config.get(Configuration.CATEGORY_GENERAL, "dismantler", true).getBoolean(); config.save(); KeyBindings.init(); } @EventHandler public void postinit(FMLPostInitializationEvent event){ log.info("[significant Advancements] " + LangRegistry.langEntries.get("log.postinit.text")); try { Dismantler.retrieve(); } catch (SAException e) { e.printStackTrace(); } //Attempt to create cache file if it doesn't already exist PlayerUtils.createCache(); //Add items and blocks to creative tabs. materialsTab.addBlock(blockGranite); materialsTab.addBlock(blockSmoothSandstone); materialsTab.addBlock(blockThatch); materialsTab.addBlock(blockTurnedPlanksBirch); materialsTab.addBlock(blockTurnedPlanksOak); //Register Recipes GameRegistry.addRecipe(new ItemStack(blockThatch), new Object[]{ "xxx", "xxx", "xxx", 'x', Blocks.hay_block }); GameRegistry.addShapelessRecipe(new ItemStack(blockTurnedPlanksBirch), new ItemStack(Blocks.planks, 1, 2)); GameRegistry.addShapelessRecipe(new ItemStack(blockTurnedPlanksOak), new ItemStack(Blocks.planks, 1, 0)); } } BlockThatch: public class BlockThatch extends BlockRotatedPillar{ public BlockThatch(Material material) { super(material); this.setBlockName("thatch"); this.setBlockTextureName(SignificantAdvancements.MODID + ":" + this.getUnlocalizedName()); this.setHardness(0.5F); } @Override @SideOnly(Side.CLIENT) protected IIcon getSideIcon(int metadata) { return this.blockIcon; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { this.field_150164_N = icon.registerIcon(this.getTextureName() + "_top"); this.blockIcon = icon.registerIcon(this.getTextureName() + "_side"); } } BlockSmoothSandstone: public class BlockSmoothSandstone extends Block { public BlockSmoothSandstone(Material material) { super(material); this.setBlockName("smoothSandstone"); this.setBlockTextureName(SignificantAdvancements.MODID + ":" + this.getUnlocalizedName()); this.setHardness(1.5F); this.setHarvestLevel("pickaxe", 1); } } BlockTurnedPlanksBirch: public class BlockTurnedPlanksBirch extends Block { public BlockTurnedPlanksBirch(Material material) { super(material); this.setBlockName("turnedPlanksBirch"); this.setBlockTextureName(SignificantAdvancements.MODID + ":" + this.getUnlocalizedName()); this.setHardness(2F); } } BlockTurnedPlanksOak: public class BlockTurnedPlanksOak extends Block { public BlockTurnedPlanksOak(Material material) { super(material); this.setBlockName("turnedPlanksOak"); this.setBlockTextureName(SignificantAdvancements.MODID + ":" + this.getUnlocalizedName()); this.setHardness(2F); } } Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted March 31, 2015 Author Share Posted March 31, 2015 Nope, not working. Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted March 31, 2015 Author Share Posted March 31, 2015 Oh that's right. I forgot I changed that. lol Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted March 31, 2015 Author Share Posted March 31, 2015 well, that allowed the localizations to work. The textures still aren't working. Quote Link to comment Share on other sites More sharing options...
Alphafox_13 Posted April 1, 2015 Share Posted April 1, 2015 actually i don't think the problem is the ulocalised name its actually this: you have the images in assets/sa/blocks where as java/minecraft is looking for them at assets/sa/textures/blocks well actually there is a small thing with the unlocalised name your missing .substring(5) PS. i noramally add public static final String DIR = "sa"; just below the final String MODID and change it to this.setBlockTextureName(SignificantAdvancements.DIR + ":" + this.getUnlocalizedName().substring(5)); that way my file structure is independant of my ModID Quote Link to comment Share on other sites More sharing options...
HappyKiller1O1 Posted April 1, 2015 Share Posted April 1, 2015 If you go to your src folder, wherever it may be, you should be able to click main, resources, assets, YOURMODID, textures, blocks. I feel like you might of named "assets" "assets.sa". Quote I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat. Link to comment Share on other sites More sharing options...
HappyKiller1O1 Posted April 1, 2015 Share Posted April 1, 2015 diesieben07 is right, you should register them like: setBlockTexture(ModResources.MODID + ":" + "TextureName"); Quote I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat. Link to comment Share on other sites More sharing options...
BoonieQuafter-CrAfTeR Posted April 2, 2015 Share Posted April 2, 2015 Make a Blocks texture Folder and a lang file like this. your directory in you Mod folder should say this. yourmod>bin>assets>yourmod\textures\blocks put your png photo in this folder. remember it has to be a png. also you must have a .setBlockTextureName("Set the block name here") and use that name for the block texture in your folder. so if you have a texture in your block textures folder it has to be the exact same word as your set texture name. the language folder is only for your names for stuff. Quote Im serious don't look at it!! Link to comment Share on other sites More sharing options...
Awesome_Spider Posted April 2, 2015 Author Share Posted April 2, 2015 Ya, thanks for reminding me. I forgot that getUnlocalizedName returned "tile.someblock.name" instead of "someblock" I guess. And I also didn't do my directory right apparently. I'll fix it and test it tomorrow. For now this is solved. Thanks for all the help guys. Quote Link to comment Share on other sites More sharing options...
HappyKiller1O1 Posted April 2, 2015 Share Posted April 2, 2015 If you want to use "getUnlocalizedName" do this: this.setBlockName(MODID + ":" + this.getUnlocalizedName().substring(5)); This removes the first five characters of the unlocalized name so you get "someblock". Java won't read past characters like "." and ":" unless you use splitString() I believe. Quote I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat. Link to comment Share on other sites More sharing options...
Awesome_Spider Posted April 2, 2015 Author Share Posted April 2, 2015 Oh, that's a cool feature. I guess my intentions with using getUnlocalizedName were to avoid hard coding stuff as much as I could. I don't know why. Quote Link to comment Share on other sites More sharing options...
Awesome_Spider Posted April 2, 2015 Author Share Posted April 2, 2015 Ok, I tested it, it works now. Thanks everyone! Quote Link to comment Share on other sites More sharing options...
SanAndreaP Posted April 2, 2015 Share Posted April 2, 2015 Java won't read past characters like "." and ":" unless you use splitString() I believe. wut? False, you can store ANY valid character in a string. After all, a String is just an array of characters with some helper methods. You can't use ":" in a resource string twice, since it tells the ResourceLocation the String before the : is the resource domain and the the part after is the path. But this is specific to the way ResourceLocations work. Quote 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. Link to comment Share on other sites More sharing options...
Awesome_Spider Posted April 2, 2015 Author Share Posted April 2, 2015 If you want to use "getUnlocalizedName" do this: [snip] Please no. What? What's wrong with getSubString(5)? Quote 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.