Jump to content

[1.7.10] [Solved] Textures not working.


Awesome_Spider

Recommended Posts

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:

 

8UOdQOv.png

 

The blocks not working are BlockThatch, BlockSmoothSandstone, BlockTurnedPlanksBirch, BlockTurnedPlanksOak, and BlockGranite.

 

But I clearly have the files in there:

 

UhghB6m.png

 

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);
    }
}

 

 

Link to comment
Share on other sites

actually i don't think the problem is the ulocalised name its actually this:

UhghB6m.png

 

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

Link to comment
Share on other sites

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". xD

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

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.

Im serious don't look at it!!

Link to comment
Share on other sites

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.

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

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.

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

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.