Java Code Examples for net.minecraft.item.ItemStack#isItemDamaged()

The following examples show how to use net.minecraft.item.ItemStack#isItemDamaged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentRepairOther.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world,	EntityPlayer player) {
	int i = -1;
	int c = 0;
	ItemStack stack;
	do {
		c++;
		i = world.rand.nextInt(40);
		stack = player.inventory.getStackInSlot(i);
	} while((stack == null || stack == itemStack || !stack.isItemDamaged()) && c < 100);
	if(stack != null && stack.isItemDamaged()) {
		//stack.setItemDamage(stack.getItemDamage()-5);
		//par1ItemStack.damageItem(5, (EntityLivingBase) par3EntityPlayer);
		PacketBuffer out =  new PacketBuffer(Unpooled.buffer());
		out.writeInt(PacketHandlerServer.REPAIRING);
		out.writeInt(i);
		out.writeInt(player.inventory.currentItem);
		CToSMessage packet = new CToSMessage(out);
		DragonArtifacts.artifactNetworkWrapper.sendToServer(packet);
	
		//par1ItemStack.setItemDamage(par1ItemStack.getItemDamage()+1);
	}
	return itemStack;
}
 
Example 2
Source File: ItemHook.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public static boolean isItemDamaged(ItemStack stack) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.SHOW_ITEM_COOLDOWNS)) {
        if(CooldownManager.isOnCooldown(stack)) {
            return true;
        }
    }
    return stack.isItemDamaged();
}
 
Example 3
Source File: ComponentRepairOther.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
	public void onHeld(ItemStack itemStack, World world, Entity entity, int slot, boolean isWorn) {
		//onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
//		int del = par1ItemStack.stackTagCompound.getInteger("repairDelay");
//		if(del > 0) {
//			--del;
//		}
//		else 
		if(entity instanceof EntityPlayer){
			if(ArtifactTickHandler.repairCount % 200 == 0) {
				//par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1);
				EntityPlayer player = (EntityPlayer)entity;
				int i = -1;
				int c = 0;
				ItemStack stack;
				do {
					c++;
					i = world.rand.nextInt(player.inventory.getSizeInventory());
					stack = player.inventory.getStackInSlot(i);
				} while((stack == null || stack == itemStack || !stack.isItemDamaged()) && c < 100);
				if(stack != null && stack.isItemDamaged()) {
					stack.setItemDamage(stack.getItemDamage()-1);
					itemStack.damageItem(1, player);
					//par1ItemStack.setItemDamage(par1ItemStack.getItemDamage()+1);
				}
//				del = 200;
			}
		}
//		par1ItemStack.stackTagCompound.setInteger("repairDelay", del);
	}
 
Example 4
Source File: GTTileDisassembler.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean canInputBeUsed(ItemStack input) {
	return !input.isEmpty() && input.getCount() > 0 && !input.isItemDamaged()
			&& !input.getItem().hasContainerItem(input);
}