Метадата для .obj

Версия Minecraft
1.7.10
22
1
0
Как правильно привязать текстуру к блоку типа .obj с определенной метадатой?

Вот как у меня. Класс блока:
Код:
public class ColumnObj extends BlockContainer implements ITileEntityProvider {
 
    public IIcon[] icon_array;

 public static String[] ids = new String[] {
 "c1",
 "c2",
 "c3",
 "c4",
 "c5",
 "c6",
 "c7",
 "c8",
 "c9",
 "c10",
 "c11",
 "c12",
 "c13",
 "c14",
 "c15",
 "c16",
 "c17",
 "c18",
 "c19",
 "c20",
 "c21",
 "c22",
 "c23",
 "c24",
 "c25",
 "c26",
 "c27",
 "c28",
 "c29",
 "c30",
 "c31",
 "c32",
 "c33",
 "c34",
 "c35",
 "c36",
 "c37",
 "c38",
 "c39",
 "c40",
 "c41",
 "c42",
 "c43",
 "c44",
 "c45",
 "c46",
 "c47",
 "c48",
 "c49",
 "c50",
 "c51",
 "c52",
 };

 public ColumnObj(String unlocalisedName) {
 super(Material.rock);
     setBlockName("column");
     setCreativeTab(CreativeTabManager.getTab("sao.townblocks"));
     setBlockTextureName(Reference.MOD_ID + ":column");
 }
 
 @SideOnly(Side.CLIENT)
 public IIcon getIcon(int side, int ids) {
 if (ids >= 0 && ids < ColumnObj.ids.length) {
 return icon_array[ids];
 }
 return super.getIcon(side, ids);
 }

 
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item ids, CreativeTabs table, List list) {
        for (int j = 0; j < ColumnObj.ids.length; ++j) {
            list.add(new ItemStack(ids, 1, j));
        }
    }
    
 @SideOnly(Side.CLIENT)
 public void registerBlockIcons(IIconRegister ir) {
 super.registerBlockIcons(ir);
 icon_array = new IIcon[ids.length];
 for (int i = 0; i < ids.length; ++i) {
 icon_array[i] = ir.registerIcon(getTextureName() + "/" + ids[i]);
 }
 }
    
 @Override
 public TileEntity createNewTileEntity(World world, int metadata) {
 return new ColumnTileEntity();
 }
 
    @Override
    public int damageDropped(int ids) {
        return ids;
    }
    

    
 public int getRenderType() {
 return -1;
 }

 public boolean isOpaqueCube() {
 return false;
 }

 public boolean renderAsNormalBlock() {
 return false;
 }
 

}


Класс TileEntity блока:

Код:
public class ColumnTileEntityR extends TileEntitySpecialRenderer {

 public final static column model = new column();
 public final static ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "/textures/blocks/column/" + ColumnObj.ids.length + ".png");

 @Override 
 public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
 render((ColumnTileEntity)tile, x, y, z, f);
 }

 private void render(ColumnTileEntity tile, double x, double y, double z, float f) {
 GL11.glPushMatrix();
 GL11.glTranslated(x, y, z);
 GL11.glTranslatef(0.5F, 0.0F, 0.5F);
 GL11.glScalef(1.5F, 1.0F, 1.5F);
 bindTexture(texture);
 model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
 GL11.glPopMatrix();
 }

}

725b6d42a00b4c06b316e22ad6102625.png

На самом деле должны быть разные текстуры. Что я сделал не так? Заранее спасибо
 
5,018
47
783
Создавай абстрактный класс с этими текстурами, от него расширяй, создавай новый(помимо самого блока obj) и уже там в методах с текстурой накладывай любую свою.
 
22
1
0
Maxik001 написал(а):
Создавай абстрактный класс с этими текстурами, от него расширяй, создавай новый(помимо самого блока obj) и уже там в методах с текстурой накладывай любую свою.

Наложить то текстуру надо в рендерере, а метадата не находит необходимое
 
5,018
47
783
MrQuest написал(а):
Maxik001 написал(а):
Создавай абстрактный класс с этими текстурами, от него расширяй, создавай новый(помимо самого блока obj) и уже там в методах с текстурой накладывай любую свою.

Наложить то текстуру надо в рендерере, а метадата не находит необходимо
Ща погоди, на примере грибов тебе скину


Короче смотри. 
У меня так сделано
Берешь класс своего obj - Блока
Код:
public class BigMushroom extends BasicMushroom implements ITileEntityProvider {
 List<TimeForCoord> time =  new ArrayList<TimeForCoord>();
 private String textureMushroomName;
 public int timePlaced;
 public static boolean placeTime;

 protected String customName = (String)textureMushroomName;
 
 public BigMushroom() {
 
 super(Material.circuits);

 setHardness(2F);
 setStepSound(soundTypeMetal);
 //ENGLISH GUIDE
 // if mushroom is hybrid then set the value "Yes" if not hybrid - "No"
 //RUSSIAN GUIDE
 // esli grib gibriniy to togda stavte libo "Da" libo "Net" 
 ConstantMushroom.hybridMushroomFalse = "No";
 
 //name
 ConstantMushroom.nameMushroomBig = "Big Basic Mushroom";
 setCreativeTab(MushroomMain.tabSelection);
 setBlockTextureName(MushroomMain.MODID + ":glassMy");
 
 setBlockName(MushroomMain.MODID + ":big" );
 this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); 
 }
 

 @SideOnly(Side.CLIENT)
 @Override
 public ResourceLocation getTexture(){
 return null;// тут вернуть текстуру шляпки(customTexture)
 }
 @Override
 public ResourceLocation getTextureStipe() {
 // TODO Auto-generated method stub
 return null;
 }
 @Override
 public ResourceLocation getTexturePart() {
 // TODO Auto-generated method stub
 return null;
 }
 //   }
 @Override
 public TileEntity createNewTileEntity(World world, int metadata) {
 return new TileEntityBigMushroom();
 }

 public int getRenderType() {
 return -1;
 }

 public boolean isOpaqueCube() {
 return false;
 }

 public boolean renderAsNormalBlock() {
 return false;
 }
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entity, int side, float hitX, float hitY, float hitZ)
    {


        return false;
        
    }
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
    {
        return null;
    }
  public boolean canPlaceBlockAt(World world, int x, int y, int z)
    {
 
        return World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || world.getBlock(x, y - 1, z) == Blocks.glowstone;
    }
 
  @Override
    public Item getItemDropped(int par1, Random par2Random, int par3)
    {
   
        return MyItems.myceliumDust;
    }

 public static int time2;

 @Override
 public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
 time.add(new TimeForCoord(x,y,z,0));
 
 world.scheduleBlockUpdate(x, y, z, this, 0);
 }
там пишешь примерно так. Дальше создаешь абстрактный класс
Код:
public abstract class BasicMushroom extends Block{
 public BasicMushroom(Material material) {
 super(material);
 }
 @SideOnly(Side.CLIENT)
 public abstract ResourceLocation getTexture();
 public abstract ResourceLocation getTextureStipe();
 public abstract ResourceLocation getTexturePart();
 
}
в рендере перед тем, как биндишь текстуру пишешь это(перед bindTexture то есть)
Код:
if(tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord) instanceof BasicMushroom && 
 ((BasicMushroom)tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord)).getTexturePart() != null){ 
 bindTexture(((BasicMushroom)tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord)).getTexturePart());
 } else
 bindTexture(texture_grow_default3);
...
Потом создаешь класс, расширяя от абстрактного, своего нового предмета(показываю на одиночном, а не на мете)
Код:
public class OpyataMushrooms extends SmallMushroom{
 public static String nameMushroomOpyata;
 public OpyataMushrooms() {
 super();
 setBlockTextureName(MushroomMain.MODID + ":LochoOpyataMushroom");
 setHardness(2F);
 nameMushroomOpyata = "Opyata";
 setStepSound(soundTypeMetal);
 setCreativeTab(MushroomMain.tabSelection);
 setBlockName(MushroomMain.MODID + ":Opyata" );
}
 public static ResourceLocation customTextureStipe = new ResourceLocation("MushroomCraft:textures/newMushroom/legOpyata.png");
 public static ResourceLocation customTexture = new ResourceLocation("MushroomCraft:textures/newMushroom/pileusFullOpyata.png");
 public static ResourceLocation customTexturePart = new ResourceLocation("MushroomCraft:textures/newMushroom/pileusPartOpyata.png");
 @SideOnly(Side.CLIENT)
 @Override
 public ResourceLocation getTextureStipe() {
 // TODO Auto-generated method stub
 return customTextureStipe;
 }
 @Override
 public ResourceLocation getTexturePart() {
 // TODO Auto-generated method stub
 return customTexturePart;
 }
 @Override
 public ResourceLocation getTexture(){
 return customTexture;// тут вернуть текстуру шляпки(customTexture)
 }
 }
 И уже в нем, приссваеешь ту текстуру, которая тебе нужна. Ну у меня вот так сделано.
 
22
1
0
Maxik001 написал(а):
MrQuest написал(а):
Maxik001 написал(а):
Создавай абстрактный класс с этими текстурами, от него расширяй, создавай новый(помимо самого блока obj) и уже там в методах с текстурой накладывай любую свою.

Наложить то текстуру надо в рендерере, а метадата не находит необходимо
Ща погоди, на примере грибов тебе скину


Короче смотри. 
У меня так сделано
Берешь класс своего obj - Блока
Код:
public class BigMushroom extends BasicMushroom implements ITileEntityProvider {
 List<TimeForCoord> time =  new ArrayList<TimeForCoord>();
 private String textureMushroomName;
 public int timePlaced;
 public static boolean placeTime;

 protected String customName = (String)textureMushroomName;
 
 public BigMushroom() {
 
 super(Material.circuits);

 setHardness(2F);
 setStepSound(soundTypeMetal);
 //ENGLISH GUIDE
 // if mushroom is hybrid then set the value "Yes" if not hybrid - "No"
 //RUSSIAN GUIDE
 // esli grib gibriniy to togda stavte libo "Da" libo "Net" 
 ConstantMushroom.hybridMushroomFalse = "No";
 
 //name
 ConstantMushroom.nameMushroomBig = "Big Basic Mushroom";
 setCreativeTab(MushroomMain.tabSelection);
 setBlockTextureName(MushroomMain.MODID + ":glassMy");
 
 setBlockName(MushroomMain.MODID + ":big" );
 this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); 
 }
 

 @SideOnly(Side.CLIENT)
 @Override
 public ResourceLocation getTexture(){
 return null;// тут вернуть текстуру шляпки(customTexture)
 }
 @Override
 public ResourceLocation getTextureStipe() {
 // TODO Auto-generated method stub
 return null;
 }
 @Override
 public ResourceLocation getTexturePart() {
 // TODO Auto-generated method stub
 return null;
 }
 //   }
 @Override
 public TileEntity createNewTileEntity(World world, int metadata) {
 return new TileEntityBigMushroom();
 }

 public int getRenderType() {
 return -1;
 }

 public boolean isOpaqueCube() {
 return false;
 }

 public boolean renderAsNormalBlock() {
 return false;
 }
 public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entity, int side, float hitX, float hitY, float hitZ)
    {


        return false;
        
    }
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
    {
        return null;
    }
  public boolean canPlaceBlockAt(World world, int x, int y, int z)
    {
 
        return World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || world.getBlock(x, y - 1, z) == Blocks.glowstone;
    }
 
  @Override
    public Item getItemDropped(int par1, Random par2Random, int par3)
    {
   
        return MyItems.myceliumDust;
    }

 public static int time2;

 @Override
 public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
 time.add(new TimeForCoord(x,y,z,0));
 
 world.scheduleBlockUpdate(x, y, z, this, 0);
 }
там пишешь примерно так. Дальше создаешь абстрактный класс
Код:
public abstract class BasicMushroom extends Block{
 public BasicMushroom(Material material) {
 super(material);
 }
 @SideOnly(Side.CLIENT)
 public abstract ResourceLocation getTexture();
 public abstract ResourceLocation getTextureStipe();
 public abstract ResourceLocation getTexturePart();
 
}
в рендере перед тем, как биндишь текстуру пишешь это(перед bindTexture то есть)
Код:
if(tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord) instanceof BasicMushroom && 
 ((BasicMushroom)tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord)).getTexturePart() != null){ 
 bindTexture(((BasicMushroom)tile.getWorldObj().getBlock(tile.xCoord,tile.yCoord, tile.zCoord)).getTexturePart());
 } else
 bindTexture(texture_grow_default3);
...
Потом создаешь класс, расширяя от абстрактного, своего нового предмета(показываю на одиночном, а не на мете)
Код:
public class OpyataMushrooms extends SmallMushroom{
 public static String nameMushroomOpyata;
 public OpyataMushrooms() {
 super();
 setBlockTextureName(MushroomMain.MODID + ":LochoOpyataMushroom");
 setHardness(2F);
 nameMushroomOpyata = "Opyata";
 setStepSound(soundTypeMetal);
 setCreativeTab(MushroomMain.tabSelection);
 setBlockName(MushroomMain.MODID + ":Opyata" );
}
 public static ResourceLocation customTextureStipe = new ResourceLocation("MushroomCraft:textures/newMushroom/legOpyata.png");
 public static ResourceLocation customTexture = new ResourceLocation("MushroomCraft:textures/newMushroom/pileusFullOpyata.png");
 public static ResourceLocation customTexturePart = new ResourceLocation("MushroomCraft:textures/newMushroom/pileusPartOpyata.png");
 @SideOnly(Side.CLIENT)
 @Override
 public ResourceLocation getTextureStipe() {
 // TODO Auto-generated method stub
 return customTextureStipe;
 }
 @Override
 public ResourceLocation getTexturePart() {
 // TODO Auto-generated method stub
 return customTexturePart;
 }
 @Override
 public ResourceLocation getTexture(){
 return customTexture;// тут вернуть текстуру шляпки(customTexture)
 }
 }
 И уже в нем, приссваеешь ту текстуру, которая тебе нужна. Ну у меня вот так сделано.



Кое что подправил :)
Проблема именно в метадате, я глянул ошибку, код загружает третью текстуру для всех блоков с этим ID...
 
Сверху