1

[HELP]Multi-texture block!

AquilaRealeIF's Avatar AquilaRealeIF9/4/13 10:32 am
1 emeralds 345 5
9/4/2013 3:31 pm
bmanrules's Avatar bmanrules
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!

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)));
}
}
Posted by AquilaRealeIF's Avatar
AquilaRealeIF
Level 2 : Apprentice Network
4

Create an account or sign in to comment.

5

bmanrules
09/04/2013 3:31 pm
Level 57 : Grandmaster Programmer
bmanrules's Avatar
Sure, send me a PM and I'll be glad to help
1
AquilaRealeIF
09/04/2013 2:07 pm
Level 2 : Apprentice Network
AquilaRealeIF's Avatar
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?
1
bmanrules
09/04/2013 11:34 am
Level 57 : Grandmaster Programmer
bmanrules's Avatar
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)):


//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
1
AquilaRealeIF
09/04/2013 11:05 am
Level 2 : Apprentice Network
AquilaRealeIF's Avatar
Here you are man!
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;
}

}


This is one of the codes, however I don't know how to put the BottomTexture using this code.
1
bmanrules
09/04/2013 10:56 am
Level 57 : Grandmaster Programmer
bmanrules's Avatar
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.
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome