Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello Guys,

 

I want to make a tool, which can be upgraded and then add another texture on it.

 

Like this:

VRJgcW.png

 

Thanks in advance ^^

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.

  • Author

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?

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.

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.

  • Author

Ok, I figured out the problem, but i don't know how to fix it. It seems that the renderPass is the problem, because it renders anything fine "if(pass == 0)", but "if(pass == 1)" just get not called or something like that, pls help :(

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.

  • Author

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

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.

  • Author

I read code of other render classes like EnderZoo, it was inverted. in first Person, It got rendered like I want. but in the inventory it use just two render passes.

I've tried other things in the handleRenderType Method. But it don't work

  • Author

I can't show you code, because I have no. In the handleRenderType method I've tried other things "returnType == || type == ItemRenderType.EQUIPPED ItemRenderType.INVENTORY;" but that not worked

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.