Jump to content

Recommended Posts

Posted

I have an item that takes damage when held.

The only problem it bounces up and down and that dosen't look so cool.

 

[spoiler=My item code:]

package fluffy.lantern.items;

 

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemReed;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import fluffy.lantern.Lantern;

import fluffy.lantern.handler.TickHandler;

 

public class ItemCandleLanternon extends ItemReed{

 

public ItemCandleLanternon(int id) {

super(id, Lantern.lanternOn);

 

this.canRepair = false;

this.setMaxDamage(Lantern.lanternFuelCapacity);

 

}

 

public int getItemStackLimit()

{

return 1;

}

 

public boolean isItemTool(ItemStack ist)

{

return false;

}

 

public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)

{

if (!par2World.isRemote)

{

int damage = par1ItemStack.getItemDamage();

EntityPlayer player = (EntityPlayer)par3Entity;

 

if (!player.capabilities.isCreativeMode && (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().itemID == par1ItemStack.itemID)){

if (damage >= this.getMaxDamage())

{

this.killItemLantern(par2World, player, par1ItemStack);

return;

}else{

par1ItemStack.setItemDamage(damage + 1);

}

}

}

super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);

}

 

private void killItemLantern(World world, EntityPlayer p, ItemStack ist)

{

world.playSoundAtEntity(p, "fluffy:Lanternoff", 0.7F, 1F);

ist.setItemDamage(this.getMaxDamage());

ist.itemID = Lantern.lanternoffItem.itemID;

}

 

 

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister icon)

{

this.itemIcon = icon.registerIcon("Fluffy:Lanternon");

}

}

 

 

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.