Jump to content

Simple Block Texture Not Showing Properly


LamachHead

Recommended Posts

So, I am trying to learn modding with Forge, and failed right on the start. I am trying to add a simple block - Coal Block, craftable with coal etc, ya know. Everything looks fine but the texture does not seem to load properly. I've tried whatever, but couldn't find a solution or where the issue is.

 

Here is my code (it's my "learning mod", bear with possible stupidity please):

 

base mod file:

 

package sandro;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;     
import net.minecraft.client.Minecraft;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;     
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.SidedProxy;
import sandro.core.ClientPacketHandler; 
import sandro.core.ServerPacketHandler;
import sandro.core.ClientProxy;
import sandro.core.CommonProxy;   
  
import java.awt.Color;
import java.io.PrintStream;
import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraft.src.*;
import net.minecraftforge.common.MinecraftForge;
        
@Mod(modid="modSandro",name="modSandro",version="0.1")     
@NetworkMod(clientSideRequired=true,serverSideRequired=false,
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"modSandro" }, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec = @SidedPacketHandler(channels = {}, packetHandler = ServerPacketHandler.class))

public class modSandro {
   
  @SidedProxy(clientSide = "sandro.core.ClientProxy", serverSide = "sandro.core.CommonProxy") //Tells Forge the location of your proxies
  public static CommonProxy proxy;
    
  @Instance("modSandro")
  public static modSandro instance = new modSandro();
                                                     
  public static Block coalblock;
  
private void initBlocks() {
	coalblock = new BlockCoal(215, 0);
	coalblock.setBlockName("CoalBlock");
	GameRegistry.registerBlock(coalblock, "CoalBlock");
	LanguageRegistry.addName(coalblock, "Coal Block");
}
    
@Mod.Init
public void load(FMLInitializationEvent event)
{
	LanguageRegistry.instance().addStringLocalization("itemGroup.Sandro", "en_US", "Sandro's Features");
	initBlocks(); 
	initItems();
	initEntities(); 
	initRecipes(); 
	proxy.init();
}
    
private void initItems() {

}
  
private void initEntities()	{

}
  
private void initRecipes() {

	GameRegistry.addRecipe(new ItemStack(coalblock, 1), new Object[] {"XXX","XXX","XXX", Character.valueOf('X'), Item.coal}); 
	GameRegistry.addRecipe(new ItemStack(Item.coal, 1), new Object[] {"X", Character.valueOf('X'), coalblock}); 
}
}

 

 

Block file:

 

package sandro;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;  
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.*;        
import net.minecraft.creativetab.CreativeTabs;
import sandro.modSandro;     
import sandro.core.ClientProxy;  
import sandro.core.CommonProxy;

public class BlockCoal extends Block {
  public BlockCoal(int i, int j)
{
    super(i, j, Material.rock);
    setHardness(3.0F);
    setResistance(5.0F);
    setStepSound(super.soundStoneFootstep); 
    setCreativeTab(CreativeTabs.tabBlock);
  }
  @Override
  public String getTextureFile() {
    return CommonProxy.COAL_BLOCK_TEXTURE;
  }
  
  @SideOnly(Side.CLIENT)
  public int getBlockTextureFromSide(int side) {
    return 1;
  }
}

 

 

ClientProxy.java:

 

package sandro.core;
                                   
import sandro.*;
import sandro.core.*;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ClientProxy extends CommonProxy {  
              
@SideOnly(Side.CLIENT)
  public void init(){
                                        
    MinecraftForgeClient.preloadTexture(COAL_BLOCK_TEXTURE); 
  } 
}

 

 

CommonProxy.java:

 

package sandro.core;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;   
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import sandro.modSandro;

public class CommonProxy implements IGuiHandler{

  public static String COAL_BLOCK_TEXTURE = "/gfx/Coalblock.png";
        
  public void registerRenderInformation() {
  }
  @Override
  public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  return null;
  }
  @Override
  public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  return null;
  }
  public void registerTiles(){
  }
  public void registerBlocks(){
  }
  public void addNames(){
  }
  public void addRecipes(){
  }
public void init() {
}
}

 

 

Here is what I get in-game:

tex1.jpg

The block's texture is messed up, but apparently it is somehow loaded. If I replace the texture with a red one, the block is red, but the texture is not rendered as it should.

This is the actual png texture:

Coalblock.png

 

I have tried to figure out where did I make a mistake for hours, but all in vain. Posting here as a last resort, if anyone can point me in the right direction of the error...

 

 

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.