Jump to content

[1.8] set the texture of this espefic item based on nbt tag?? is posible<solved>


perromercenary00

Recommended Posts

well i think bows behave this way but not understand how they do it

 

i have this item is a clip loader for a gun and i wanna change this especific clip texture to show the amount of bullets remainded but wen i swich this item texture it swichs for all the other bullet clips ass well 

am storing the bullets cuantity in a nbt Tag named "municionRestante"

 

first am setting the texture for all clips in my texturex class  whith

registrarTextura.item(MercenaryModItems.bulletsClip,0,"bulletsClip_empty");

 

and i tink there is were the trouble begin there must be another metod someting like

 

bulletclip.setThisWhithEspecificTexture("modmercenario:textura16");

 

 

soo ?

¿what must be done to set diferent texturex for diferent instances of the same item 

 

 

Link to comment
Share on other sites

AFAIK, this is not possible with 1.8 yet.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hi

 

It's possible but not straightforward.

 

This link talks a bit more about it.

http://greyminecraftcoder.blogspot.com.au/2014/12/item-rendering-18.html

 

This link is an example, based on item metadata.

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe11_item_variants

 

If that's not suitable, look at Item.getModel().  (I'm writing an example for that but it's not finished yet...)

 

-TGG

 

 

Link to comment
Share on other sites

 

 

well i modify mi textures class to work whith itemStack hoping this could work but naa it still change the texture for all the clips at time , may if i put the texture change part in other method but where

 

package mercenarymod.items.armasdefuego.colt1911;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import mercenarymod.materialesMercenarios;
import mercenarymod.Mercenary;
import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import mercenarymod.items.MercenaryModItems;
import mercenarymod.utilidades.nbtMercenaria;
import mercenarymod.utilidades.registrarTextura;
import mercenarymod.utilidades.chat;
import mercenarymod.utilidades.util;


import net.minecraft.block.state.IBlockState;

public class cargadorColt1911 extends Item{

public static String name = "cargadorColt1911";
public static int meta;

public static int bullets=0;

public cargadorColt1911(){

	setUnlocalizedName(Mercenary.MODID + "_" + name);
	GameRegistry.registerItem(this, name);
	setCreativeTab(Mercenary.herramientas);
	this.setHasSubtypes(true);
	this.maxStackSize = 1;

	;}



public ItemStack onItemRightClick(ItemStack cargador, World worldIn, EntityPlayer playerIn)
  {
	  
bullets = 0 + (int)(Math.random()*10);

	nbtMercenaria.setInttag(cargador, "municionRestante", bullets);
	//tiempoCargador.habilitar( worldIn,playerIn, cargador);


	if ((bullets<7)&(bullets>0)){	
	registrarTextura.itemStack(cargador,0,"suspensionderedstone"+bullets);
	}

	if (bullets=={	
		registrarTextura.itemStack(cargador,0,"papa");
		}

	if (bullets==9){	
		registrarTextura.itemStack(cargador,0,"patadecabra");
		}



      return cargador;
  }


public String getUnlocalizedName(ItemStack stack)
    {
        	int m= stack.getMetadata();
	if (m == 0){return name+"_vacio";}
                return name;
     }

@SideOnly(Side.CLIENT)
    public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
    {
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn, 1, 7));
        }

@SideOnly(Side.CLIENT)
    public void addInformation(ItemStack cargador, EntityPlayer player, List list, boolean aBoolean)
    {
int municion=nbtMercenaria.getInttag(cargador, "municionRestante");	
String lore="balas="+municion;	


       if(lore != "")
       {
          list.add(lore);
       }
    }


}//fin de la classe

 

alredy text puting in addInformation

and nop

all the bulletclips change the texture for the same at the same time

Link to comment
Share on other sites

i wass reading the exaple from ItemVariants

 

for wath i understand youare setting the diferentas values of color an emptiness to metadata

and thats mi trouble

 

i do the bulletsclip whit 7 meta sub items representing all the states of emptiness from 0 bullets to sevent this clip only hold sevent bullets and have 8 diferent textures for the meta items representing from empty clip to seven bullets

doing  this way i could only make clips to 15 bullets and that for colt1911 is fine but i have anothers guns whit clips to 20 30 and 60 bullets

 

so  i think if i store the munition cuantity in NBT tags i gona use more less code and more simple but lose the grafical display of the bullets in the clip and lose the hability to load the clip in the worktable

 

well thast another cuestion,it is posible to make recipes based on nbt tags ?

 

Link to comment
Share on other sites

it cost me but i solved and solved other issue

 

using the code for the custom bow from robin4002 i realize how to change the model of the item in hand whithout mess whit the item in inventory this way i can set the in hand texture based in whatever i want soo NBTtag goes there

 

and in the same shoot using this you can set a 2d item icon for inventory and at the same define a 3d model for the item in hand

 

 

package mercenarymod.items.pruebas;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.stats.StatList;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import mercenarymod.materialesMercenarios;
import mercenarymod.Mercenary;
import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import mercenarymod.items.MercenaryModItems;
import mercenarymod.utilidades.nbtMercenaria;
import mercenarymod.utilidades.registrarTextura;
import mercenarymod.utilidades.chat;
import mercenarymod.utilidades.util;
import net.minecraft.block.state.IBlockState;
import mercenarymod.utilidades.nbtMercenariaConTiempoInt;


//######################################################################################3
public class cartuchodePrueba extends Item{

public static String name = "cartuchodePrueba";
public static int meta;

public static int bullets;

//######################################################################################3	
public cartuchodePrueba(){

	setUnlocalizedName(Mercenary.MODID + "_" + name);
	GameRegistry.registerItem(this, name);
	setCreativeTab(Mercenary.herramientas);
	this.setHasSubtypes(false);
	this.maxStackSize = 1;

	;}

//######################################################################################3	
 @Override
public ModelResourceLocation getModel(ItemStack cargador, EntityPlayer playerIn, int useRemaining){


ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:cargadorColt1911_zero", "inventory");


//bullets=nbtMercenariaConTiempoInt.habilitar(cargador, "municionRestante");
bullets=nbtMercenaria.getInttag(cargador, "municionRestante");	

           
   		 	        	
        	
        	if(bullets==0){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_zero" , "inventory");}
        	if(bullets==1){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_uno" , "inventory");}
        	if(bullets==2){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_dos" , "inventory");}
        	if(bullets==3){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_tres", "inventory");}
        	if(bullets==4){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_cuatro" , "inventory");}
        	if(bullets==5){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_cinco" , "inventory");}
        	if(bullets==6){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_seis" , "inventory");}
        	if(bullets==7){modelresourcelocation = new ModelResourceLocation( "modmercenario:cargadorColt1911_siete" , "inventory");}
            
            
        
        return modelresourcelocation;
    }

//####################################################################################	
public ItemStack onItemRightClick(ItemStack cargador, World worldIn, EntityPlayer playerIn)
  {


Random r=new Random(100);
  
bullets = 0 + (int)(Math.random()*7);
nbtMercenaria.setInttag(cargador,"municionRestante",bullets);


	//chat.chatda(playerIn, "bullets="+bullets);
      return cargador;
  }

//######################################################################################3	
public String getUnlocalizedName(ItemStack stack)
    {
        
	int m= stack.getMetadata();

	if (bullets == 0){return name+"_vacio";}

	return name;
    
    }

//######################################################################################3	
/*
@SideOnly(Side.CLIENT)
    public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
    {
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn, 1, 7));
                
    }
*/
//######################################################################################3	
@SideOnly(Side.CLIENT)
    public void addInformation(ItemStack cargador, EntityPlayer player, List list, boolean aBoolean)
    {
int municion=nbtMercenaria.getInttag(cargador, "municionRestante");	
String lore="balas="+municion;	


       if(lore != "")
       {
          list.add(lore);
       }
    }

//######################################################################################3	
}//fin de la classe

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.