Jump to content

Recommended Posts

Posted

The last problem is solved, directly after this the next one comes up:

My shurikens are all rendered same; all of them have the same texture...  :-\

 

What have I done wrong?

 

The corresponding Item class:

public class MoreToolsShuriken extends Item {

private int damage = 6;
private int shurikenType = 0;

public MoreToolsShuriken(int ID) {
	super(ID);
}

public MoreToolsShuriken(int ID, int Damage, int ShurikenType) {
	super(ID);
	this.damage = Damage;
	this.shurikenType = ShurikenType;
}

public MoreToolsShuriken setDamage(int Damage){
	this.damage = Damage;
	return this;
}

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
     
	EntityShuriken shuriken;

	switch (this.shurikenType){ 
	case 1: shuriken = new EntityShurikenGold(world, player, this, damage);
	case 2: shuriken = new EntityShurikenCopper(world, player, this, damage);
	case 3: shuriken = new EntityShurikenGlass(world, player, this, damage);
	case 4: shuriken = new EntityShurikenDiamond(world, player, this, damage);
	case 5: shuriken = new EntityShurikenBloodCrystal(world, player, this, damage);

	default: shuriken = new EntityShuriken(world, player, this, damage); 
	}

	world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F);
     	
     if (!world.isRemote)
     {
    	 world.spawnEntityInWorld(shuriken);
     }
     
     if (!player.capabilities.isCreativeMode){
    	 if (-- stack.stackSize == 0)
    		 return null;
     }
     return stack;
}

}

The Intialzation of these Items:

 

shurikenIron 			= new MoreToolsShuriken(shurikenIronID, 4, 0).setUnlocalizedName(PicInit + "shurikenIron").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenGold			= new MoreToolsShuriken(shurikenGoldID, 6, 1).setUnlocalizedName(PicInit + "shurikenGold").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenCopper 			= new MoreToolsShuriken(shurikenCopperID, 5, 2).setUnlocalizedName(PicInit + "shurikenCopper").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenDiamond			= new MoreToolsShuriken(shurikenDiamondID, 7, 4).setUnlocalizedName(PicInit + "shurikenDiamond").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenBloodCrystal	= new MoreToolsShuriken(shurikenBloodCrystalID, 9, 5).setUnlocalizedName(PicInit + "shurikenBloodCrystal").setCreativeTab(MoreTools.tabMoreWeapons);
	shurikenGlass 			= new MoreToolsShuriken(shurikenGlassID, 4, 3).setUnlocalizedName(PicInit + "shurikenGlass").setCreativeTab(MoreTools.tabMoreWeapons);

The EntityShurkien Class:

 

public class EntityShuriken extends EntityThrowable
{
private int damage = 2;
private Item itemDrop;

    public EntityShuriken(World par1World)
    {
        super(par1World);
    }

    public EntityShuriken(World par1World, EntityLiving par2EntityLiving)
    {
        super(par1World, par2EntityLiving);
    }
    
    public EntityShuriken(World world, EntityLiving shotBy, Item itemDrop, int Damage)
    {
        super(world, shotBy);
        this.damage = Damage;
        this.itemDrop = itemDrop;
    }

public EntityShuriken(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
        	par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (byte)damage);
        } else {
        	if (!this.worldObj.isRemote)
            {
                if (itemDrop != null){
                	this.dropItem(itemDrop.itemID, 1);
                }
            }
        }
        if (!this.worldObj.isRemote)
        {
            this.setDead();
        }
    }
}

The Render Class:

 

@SideOnly(Side.CLIENT)
public class RenderShuriken extends Render
{
    private Item itemIcon;
    private int field_94150_f = 0;

    public RenderShuriken(Item par1, int par2)
    {
        this.itemIcon = par1;
        this.field_94150_f = par2;
    }

    public RenderShuriken(Item par1)
    {
        this(par1, 0);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {    	
        Icon icon = itemIcon.getIconFromDamage(this.field_94150_f);
    	
    	if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.loadTexture("/gui/items.png");
            Tessellator tessellator = Tessellator.instance;

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
}

And last but not least the initialization of the renderer:

 

public static void registerEntities() {
	setUpEntity(EntityShuriken.class, "Iron Shuriken", 0, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenIron));
	setUpEntity(EntityShurikenCopper.class, "Copper Shuriken", 1, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenCopper));
	setUpEntity(EntityShurikenGold.class, "Gold Shuriken", 2, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenGold));
	setUpEntity(EntityShurikenDiamond.class, "Diamond Shuriken", 3, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenDiamond));
	setUpEntity(EntityShurikenBloodCrystal.class, "Blood Crystal Shuriken", 4, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenBloodCrystal));
	setUpEntity(EntityShurikenGlass.class, "Glass Shuriken", 5, MoreTools.instance, 128, 1, true, new RenderShuriken(MoreToolsItems.shurikenGlass));
	}

private static void setUpEntity(Class<? extends Entity> EntityClass, String EntityName, int ModID, Object ModObject, int trackingRange, int updateFrequency, boolean sendsVelocityUpdate, Render renderer){
	EntityRegistry.registerGlobalEntityID(EntityClass, EntityName, EntityRegistry.findGlobalUniqueEntityId());
	EntityRegistry.registerModEntity(EntityClass, EntityName, ModID, ModObject, trackingRange, updateFrequency, sendsVelocityUpdate);
	RenderingRegistry.registerEntityRenderingHandler(EntityClass, renderer);
}

 

 

I hope, somebody can help me with this problem...

Thanks in advance!!!  :D

 

(If you need more source code, please tell me!)

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.