1
[HELP]Multi-texture block!
Hey guys, I'm creating a new mod and I found a problem.
When I try to put 3 differents texture to a block, it give me errors!
Actually I have the source with only one texture, can anyone help me?
I want to put a top texture and a bottom texture.
I searched on lots of tutorials here, on youtube, but nothing!
When I try to put 3 differents texture to a block, it give me errors!
Actually I have the source with only one texture, can anyone help me?
I want to put a top texture and a bottom texture.
I searched on lots of tutorials here, on youtube, but nothing!
Click to reveal
package AquilaReale.WorldOfDarkness.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import AquilaReale.WorldOfDarkness.common.WorldOfDarkness;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public class BlockDarkGrass extends Block{
public BlockDarkGrass(int par1, Material par2Material) {
super(par1, Material.ground);
this.setCreativeTab(WorldOfDarkness.BlocksWorldOfDarkness);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(WorldOfDarkness.modid + ":" + (this.getUnlocalizedName().substring(5)));
}
}
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import AquilaReale.WorldOfDarkness.common.WorldOfDarkness;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public class BlockDarkGrass extends Block{
public BlockDarkGrass(int par1, Material par2Material) {
super(par1, Material.ground);
this.setCreativeTab(WorldOfDarkness.BlocksWorldOfDarkness);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(WorldOfDarkness.modid + ":" + (this.getUnlocalizedName().substring(5)));
}
}
Create an account or sign in to comment.
5
![bmanrules's Avatar](https://static.planetminecraft.com/files/avatar/146447_1.png)
Sure, send me a PM and I'll be glad to help
![AquilaRealeIF's Avatar](https://static.planetminecraft.com/files/avatar/950173_0.png)
Oh man thanks a lot! I had some small problem but i fixed them. If I have more problems, can ask you for fix them?
![bmanrules's Avatar](https://static.planetminecraft.com/files/avatar/146447_1.png)
It's actually fairly basic java, so I recommend looking up some java tutorials before getting too deep into modding
Here's the code taken from BlockGrass (You'll need to add @SideOnly(Side.CLIENT)):
and don't forget the registerIcon method. I'm on my phone at the moment so the code is a tad sloppy and untested, but it's the general idea of it. Check BlockGrass and Workbench if you're stuck
Here's the code taken from BlockGrass (You'll need to add @SideOnly(Side.CLIENT)):
//add these with the rest of your variables.
private Icon iconBlockTop;
private Icon iconBlockSide;
private Icon iconBlockBottom;
public Icon getIcon(int par1, int par2)
{
if (par1 == 1)
{
return this.iconBlockTop;
}
else
{
return this.iconBlockBottom;
}
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if (par5 == 1)
{
return this.iconBlockTop;
}
else if (par5 == 0)
{
return this.iconBlockBottom;
}
}
and don't forget the registerIcon method. I'm on my phone at the moment so the code is a tad sloppy and untested, but it's the general idea of it. Check BlockGrass and Workbench if you're stuck
![AquilaRealeIF's Avatar](https://static.planetminecraft.com/files/avatar/950173_0.png)
Here you are man!
This is one of the codes, however I don't know how to put the BottomTexture using this code.
Click to reveal
package AquilaReale.WorldOfDarkness.blocks;
import AquilaReale.WorldOfDarkness.common.WorldOfDarkness;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public class BlockDarkGrass extends Block{
private static String textureName;
@SideOnly(Side.CLIENT)
private Icon topTexture;
public BlockDarkGrass(int id, String grassTop){
super(id, Material.grass);
this.textureName = grassTop;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg){
this.blockIcon = reg.registerIcon(Tutorial.modID + ":" + textureName);
this.topTexture = reg.registerIcon(Tutorial.modID + ":" + textureName + "_top");
}
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topTexture;
}
return this.blockIcon;
}
}
import AquilaReale.WorldOfDarkness.common.WorldOfDarkness;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public class BlockDarkGrass extends Block{
private static String textureName;
@SideOnly(Side.CLIENT)
private Icon topTexture;
public BlockDarkGrass(int id, String grassTop){
super(id, Material.grass);
this.textureName = grassTop;
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg){
this.blockIcon = reg.registerIcon(Tutorial.modID + ":" + textureName);
this.topTexture = reg.registerIcon(Tutorial.modID + ":" + textureName + "_top");
}
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topTexture;
}
return this.blockIcon;
}
}
This is one of the codes, however I don't know how to put the BottomTexture using this code.
![bmanrules's Avatar](https://static.planetminecraft.com/files/avatar/146447_1.png)
Can you show us the code you used to make the top and bottom and the errors you got? You might want to look at BlockGrass or the Furnace code to find out how to do this.