Jump to content

[1.7.10] How to make Multi-Layered Textures like Tinkers Construct?


benfah

Recommended Posts

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

I've tried it, but it returns just a blank Item

 

package me.benfah.benfahsmod.items.pyrosword;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;








import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.IItemRenderer;
import me.benfah.benfahsmod.Reference;

import com.google.common.collect.Multimap;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemPyroSword extends ItemSword{






public ItemPyroSword(ToolMaterial material) {
	super(material);
	this.setUnlocalizedName("pyro_sword");
	this.setTextureName(Reference.MOD_ID + ":pyro_sword");
}






@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
	// TODO Auto-generated method stub
}
@Override
public int getColorFromItemStack(ItemStack stack, int renderPass) {


	return super.getColorFromItemStack(stack, renderPass);
}



private HashMap<String, IIcon> textures = new HashMap<String, IIcon>();


private IIcon sword;
private IIcon overlay;


@Override
public IIcon getIcon(ItemStack stack, int pass)
    {
	IIcon i = itemIcon;
	if(pass == 0) {
		if(stack.stackTagCompound == null) {
			return itemIcon;
		}
		i = (IIcon) textures.get(stack.stackTagCompound.getString("icon").toLowerCase());
		if(i == null) {
			i = itemIcon;
		}
	}
	else {
		if(stack.stackTagCompound == null) {
			return (IIcon) textures.get("overlay_upgrade1");

		}
		i = (IIcon) textures.get("overlay_"+stack.stackTagCompound.getString("icon").toLowerCase());
		if(i == null) {
			i = (IIcon) textures.get("overlay_upgrade1");
		}
	}
	return i;
    }





@Override
public IIcon getIconFromDamageForRenderPass(int damage, int pass) {
	if(pass == 0) {
		return this.sword;
	}
	else {
		return this.overlay;
	}
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderPasses(int metadata) {

	return 0;
}

@SideOnly(Side.CLIENT)
@Override
public boolean requiresMultipleRenderPasses()
{
	return true;
}

@Override
public void registerIcons(IIconRegister i) {

	this.sword = i.registerIcon(Reference.MOD_ID + ":pyro_sword");	
	this.overlay = i.registerIcon(Reference.MOD_ID + ":" + "pyro_sword_t1");

	textures.put("overlay_upgrade1", overlay);

}




}

 

Do anybody know what's wrong?

Link to comment
Share on other sites

Your code never sets the NBT tag to have a value for "icon"

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

Well, insert some debugging statements and figure out what the program is doing.

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

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

Ok, I've fixed it, but another problem occurs, "if(pass == 2)" get not called. Do you know why the problem occurs?

 

There are only two passes: pass 0 and pass 1.

Pass 2 will never happen.

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

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.